admin管理员组文章数量:1130349
作者:张华 发表于:2020-08-19
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明
问题
升级了500M宽带,但电脑用网线直线WDNR4300路由器用perf3 -s与perf -c 192.168.99.1 -t 3测试时只不到200M.所以在一台式机上安装了软路由,测试结果立马上到接近1000M了.
但用了1000M的电力猫之后,速度又下降到120左右,改成有线连接之后,又马又上到1000M.
看来瓶颈在于WDNR4300与电力猫.
安装软路由
台式机上有两个之前做SR-IOV实验用的千兆网卡 (Winyao WY576T PCI-E X4 双口服务器千兆网卡 82576 1000M), 及一个Intel集成网卡.
- enp6s0f0与enp6s0f1通过passthough映射到KVM虚机. 注意不要使用macvtap+bridge模式,因为这样会造成无法从局域网ping macvtap设备上的IP,当在插一根网线到Intel集成网卡上后,默认路由总是在enp6s0f0上,从而导致无法访问台式机.enp6s0f0映射到openwrt虚机里是eth1用于生成br-lan, enp6s0f1映射到openwrt虚机里是eth0.
- 直接KVM安装导入OpenWRT x86镜像即可 (github直接下载)
网络拓扑
目前家中的网络拓扑是:
- 光猫,打电话改了桥接
- tplink千兆路由器(192.168.2.0/24)拨号, 下接一千兆交换机接NAS, TV, Camera等.
- 台式机的enp6s0f0接tplink,从软路由(192.168.98.0/24)出来后,enp6s0f1再接一千兆交换机.
- WNDR4300仍然从tplink出(192.168.99.0/24)
- 千兆电力猫连接软路由至卧室(电力猫速度太差,需要改成有线)
目前问题
- 台式机停电再来电自动启动的问题,改了BIOS但还未测试
- tplink上IPv6也要拨号但复用IPv4的拨号连接后是有IPv6地址的(光猫桥接并未挡住什么),客户端直接连接tplink也能拿到IPv6, 但tplink下挂的OpenWRT路由器却拿不到IPv6, 可能是OpenWrt镜像缺包吧,因为在WAN6那里找不到dhcpv6 client,只有dhcp client) ,原因见: https://agong.me/2019/soft-router-compile-ipv6-mppddial-by-top-navigation.html (20200824更新,就是这个原因). 那现在另外一个路由器以dhcp接在这个拨号路由器后lan口又如何获取IPv6地址呢?
- ubuntu在/etc/network/interfaces不定义时可以拿到IPv6,但要使用桥接如何定义也能拿到IPv6呢?
- 如何将无线网卡给KVM用,同时在openwrt虚机中用它做AP?
一级路由访问二级路由
当在一级redmi ax5路由(192.168.2.1)下又接了一个二级openwrt路由(192.168.2.47, 192.168.99.1).
那一级路由下的node1(192.168.2.111)如何访问二级路由下的t440p (192.168.99.136)呢?
1, 先照着这处贴子将redmi ax5的ssh打开, 必须重启,之后就可以通过root/admin 来ssh了(不影响web管理密码), 然后使用’passwd root’来修改密码.
http://192.168.2.1/cgi-bin/luci/;stok=5aa4576eb44e9e70dc1557c3e74b57a2/web/home#router
http://192.168.2.1/cgi-bin/luci/;stok=5aa4576eb44e9e70dc1557c3e74b57a2/api/misystem/set_config_iotdev?bssid=Xiaomi&user_id=longdike&ssid=-h;nvram set ssh%5Fen%3D1; nvram commit;
http://192.168.2.1/cgi-bin/luci/;stok=5aa4576eb44e9e70dc1557c3e74b57a2/api/misystem/set_config_iotdev?bssid=Xiaomi&user_id=longdike&ssid=-h%3B%20nvram%20set%20ssh_en%3D1%3B%20nvram%20commit%3B%20sed%20-i%20's%2Fchannel%3D.*%2Fchannel%3D%5C%22debug%5C%22%2Fg'%20%2Fetc%2Finit.d%2Fdropbear%3B%20%2Fetc%2Finit.d%2Fdropbear%20start%3B
http://192.168.2.1/cgi-bin/luci/;stok=5aa4576eb44e9e70dc1557c3e74b57a2/api/misystem/set_config_iotdev?bssid=Xiaomi&user_id=longdike&ssid=-h%3B%20echo%20-e%20'admin%5Cnadmin'%20%7C%20passwd%20root%3B
2, 在二级路由器上如下图关闭防火墙,
3, 在一级路由下添加静态路由
route add -net 192.168.99.0 netmask 255.255.255.0 gw 192.168.2.47
4, 在二级路由上将192.168.2.47作静态IP绑定(MAC/IP绑定即可)
5, 如果不行,似乎在一级路由器上上图中lan处防火墙设置中的forwarding不能是REJECT哦.
20210506更新
目前,set_config_iotdev已经被删除,所以已经无法为remi ax5做ssh
目前软路由win10上有两个虚机,一个openwrt(192.168.2.58, 192.168.99.1),一个ubuntu(192.168.2.67).
redmi ax5可以做静态映射ssh到192.168.2.67, 然后在192.168.2.67上添加静态路由:
hua@bastion:~$ cat /etc/rc.local
#!/bin/sh -e
route del -net 192.168.99.0 netmask 255.255.255.0 gw 192.168.2.58 >/dev/null 2>&1 &
sleep 2
route add -net 192.168.99.0 netmask 255.255.255.0 gw 192.168.2.58
exit 0
如果遇到下列错误,是需要将openwrt上的FORWARD规则给关闭:
hua@bastion:~$ ping -c1 192.168.99.136
PING 192.168.99.136 (192.168.99.136) 56(84) bytes of data.
From 192.168.2.58 icmp_seq=1 Destination Port Unreachable
对于通过vnc从外部访问t440p (192.168.99.136),本来想着再开一个wifi( 192.168.2.34),然后在redmi ax5做针对192.168.2.34作端口映射,但实际是在外部无法telnet它,应该是遇到了对称路由问题
DDNS
miwifi上集成的DDNS服务基本上都是收费的, 花生壳的二级域名壳域名不收费, 但这家公司喜欢删域名, 要求你实名制, 但实名制前又问你最喜欢的动物是什么, 答错了还弄不成实名制, 打电话给客服了, 让你把身份证扫描件发到800@oray人工审核, 但也没下文了, 等得头疼. 另外, 就是太喜欢删域名了, 申请的壳域名忽然就删了, 被删了也不知道的怎么被删的, 死得不明不白. 得了, 还是整个免费的吧. 申请一个dnsexit的二级域名, 然后用下列脚本更新.
bash -c 'cat > /data/ddns' << EOF
#!/bin/sh
myip=$(curl -s http://myip.dnsomatic/)
if [ -e "ip.txt" ]
then
old_ip=$(cat ip.txt)
if [ "$myip" == "$old_ip" ]
then
echo "Your IP $myip didn't change."
else
echo "$myip" > ip.txt
echo "The IP Changed from $old_ip to $myip"
change_dot_com=$(curl -s "http://update.dnsexit/RemoteUpdate.sv?login=<user>&password=<password>&host=<domain>&myip=${myip}")
echo "$change_dot_com"
sleep 2
fi
else
echo "$myip" > ip.txt
echo "Your IP is $myip"
fi
EOF
chmod +x /data/ddns
crontab -e
*/60 * * * * /data/ddns >/dev/null 2>&1
nslookup -vc quqi99.publicvm 8.8.8.8
防火墙
1, 默认REJET
config defaults
option syn_flood '0'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option drop_invalid '1'
option disable_ipv6 '0'
config zone
option name 'lan'
option network 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
config zone
option name 'wan'
list network 'wan'
list network 'wan6'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option masq '1'
option mtu_fix '1'
2, 打开22端口
config rule 'ssh'
option name 'ssh'
option src 'wan'
option dest_port '22'
option proto 'tcp'
option target 'ACCEPT'
option family 'ipv4'
3, 转发2222端口
config redirect 'wan2222rdr1'
option proto 'tcp'
option src_dport '2222'
option dest_ip '192.168.2.47'
option dest_port '22'
option src 'wan'
option name 'x86_openwrt'
option target 'DNAT'
option ftype '1'
option dest 'lan'
root@XiaoQiang:~# iptables-save |grep 47
-A zone_lan_postrouting -s 192.168.2.0/24 -d 192.168.2.47/32 -p tcp -m tcp --dport 22 -m comment --comment "!fw3: x86_openwrt (reflection)" -j SNAT --to-source 192.168.2.1
-A zone_lan_prerouting -s 192.168.2.0/24 -d 123.115.196.xxx/32 -p tcp -m tcp --dport 2222 -m comment --comment "!fw3: x86_openwrt (reflection)" -j DNAT --to-destination 192.168.2.47:22
-A zone_wan_prerouting -p tcp -m tcp --dport 2222 -m comment --comment "!fw3: x86_openwrt" -j DNAT --to-destination 192.168.2.47:22
转发端口时不需要为2222单独定义input规则, 另外, 联通除了封80, 443, 以外其实没有封其它端口, 可用https://tool.chinaz/port/ 检测 (检测时得做redirect规则, 且开服务)
https网站不好使
像csdn与baidu等网站出现HSTS相关的证书错误, 是因为广告过滤大师使用了KoolProxy签发的证书所致, 所以需要关闭广告过滤大师.
docker
vim /etc/docker/daemon.json
"data-root": "/mnt/udisk/docker",
/etc/init.d/dockerd restart
#install a better docker frontend - https://koolshare/thread-180474-1-1.html
docker pull portainer/portainer
#create a continer with portainer image, expose port 9000:9000/tcp and bind mount '/var/run/docker.sock:/var/run/docker.sock'
http://192.168.99.1:9000/#/init/admin
http://192.168.99.1:9000/#/dashboard
#intall docker search ubuntu
docker pull ubuntu
docker run -it ubuntu
docker ps -a
天翼云盘
天翼云盘是一个独立的家庭云空间,不等同于天翼云,无法获取S3登陆参数,也关闭了API - https://zhuanlan.zhihu/p/38592985
所以它无法使用s3fs加载块设备,但使用s3fs的方法类似于:
sudo apt install build-essential libfuse-dev libcurl4-openssl-dev libxml2-dev mime-support automake libtool s3fs
echo xxx:xxx |sudo tee /etc/passwd-s3fs && sudo chmod 600 /etc/passwd-s3fs && sudo chown $USER /etc/passwd-s3fs
sudo mkdir /mnt/tianyi && sudo chown $USER /mnt/tianyi
s3fs -o passwd_file=/etc/passwd-s3fs -o url=http://oos.ctyunapi bucket-dingjia /mnt/tianyi
df -h
fusermount -u /mnt/tianyi
它可以使用sharelist,但用途不大.
#sudo apt install nodejs npm -y && sudo npm install -g npm
git clone https://github/reruin/sharelist.git
cd sharelist && sudo chmod +x ./install.sh && sudo ./install.sh #http://127.0.0.1:33001/
#cd ./sharelist/ && node app.js #http://127.0.0.1:33001/
BaiduPCS-Web
# server side
# nfs GUI(http://192.168.99.1/cgi-bin/luci/admin/nas/nfs)是坏的(luci-app-nfs - https://github/coolsnowwolf/lede/issues/2957),只能使用CLI
echo '/mnt/sdb1/nfs *(rw,sync,no_root_squash,subtree_check)' >> /etc/exports
/etc/init.d/nfsd restart
# client side
showmount -e 192.168.99.1
sudo mount -t nfs 192.168.99.1:/mnt/sdb1/nfs /openwrt
sudo fuser -m -v /openwrt/
$ cat /etc/auto.direct |tail -n1
/openwrt -fstype=nfs4,rsize=32768,wsize=32768 192.168.99.1:/mnt/sdb1/nfs
win10上的nfs client乱码的问题,win10目前支持使用utf-8 - https://zhuanlan.zhihu/p/46254792
20210905更新
现在家中网络拓扑改成了:
- 弱电箱星际宝盒路由器: 192.168.99.0/24,只有我办公的机器用它。光猫改桥接后由它拨号,然后它分到客厅ac2100路由器,及房间办公交换机
- 客厅ac2100路由器: 192.168.2/24 (192.168.99.203),其他的打印机nas什么的避免改动太大仍然沿用192.168.2.0/24网段
弱电箱路由器由得做两件事:
- route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.99.203
- 将192.168.99.203做ip/mac绑定来固定IP
客厅路由器添加防火墙规则: - 两个路由器都添加:iptables -A FORWARD -s 192.168.99.0/24 -d 192.168.2.0/24 -j ACCEPT
另外在弱电箱路由器为所有转发的端口需在/etc/config/firewall中配置:
config redirect 'wan2222rdr1'
option proto 'tcp'
option src_dport '2222'
option dest_ip '192.168.99.203'
option dest_port '22'
option src 'wan'
option name 'ssh'
option target 'DNAT'
option ftype '1'
option dest 'lan'
这样会产生:
-A zone_lan_postrouting -s 192.168.99.0/24 -d 192.168.1.203/32 -p tcp -m tcp --dport 1194 -m comment --comment "!fw3: openvpn (reflection)" -j SNAT --to-source 192.168.1.1
-A zone_lan_prerouting -s 192.168.99.0/24 -d 123.115.xx.xx/32 -p tcp -m tcp --dport 1194 -m comment --comment "!fw3: openvpn (reflection)" -j DNAT --to-destination 192.168.1.203:1194
-A zone_wan_prerouting -p tcp -m tcp --dport 1194 -m comment --comment "!fw3: openvpn" -j DNAT --to-destination 192.168.99.203:1194
同时两个路由器都得配置INPUT规则
-A zone_wan_input -p tcp -m tcp --dport 22 -m comment --comment "!fw3: ssh" -j ACCEPT
最后,由于将以前常用的192.168.99.0/24改成了192.168.2.0/24,这样不要忘了更新v-p-n中的dns和99相关的路由信息
可在弱电箱路由器的resolve.conf中添加两个快一点的dns server:
223.5.5.5
180.76.76.76
如何访问二级华为路由器下的设备
遇到一个问题,现在换成小米笔记本了,没有有线网卡
二级路由器(192.168.3.0/24)通过192.168.99.213连接着一级路由路(192.168.99.0),
在一级路由器上有一台机器名为proxy (192.168.99.171).
在二级路由器上有一台机器名为mi, 无有线网卡 通过wifi连接(192.168.3.44).
目前在一级openwrt路由器上已经设置下列静态路由:
root@gw:~# ip route list |grep 3
192.168.3.0/24 via 192.168.99.213 dev br-lan metric 1
可以在proxy上ping到 mi
root@proxy:~# ping 192.168.3.44
PING 192.168.3.44 (192.168.3.44): 56 data bytes
64 bytes from 192.168.3.44: icmp_seq=0 ttl=63 time=5.054 ms
92 bytes from gw.lan (192.168.99.1): Redirect Host
64 bytes from 192.168.3.44: icmp_seq=1 ttl=63 time=11.008 ms
但是却无法在proxy上ssh到mi, 这是什么原因呢?
root@proxy:~# ssh hua@mi -v
OpenSSH_8.9p1 Ubuntu-3ubuntu0.1, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to mi [192.168.3.44] port 22.
debug1: Connection established.
debug1: identity file /root/.ssh/id_rsa type 0
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa_sk type -1
debug1: identity file /root/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: identity file /root/.ssh/id_ed25519_sk type -1
debug1: identity file /root/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /root/.ssh/id_xmss type -1
debug1: identity file /root/.ssh/id_xmss-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.1
怎么试怎么不行。最后发现了下列workaround:
- 打开华为路由路的DMZ,将mi加入DMZ, 这样通过 ssh hua@192.168.99.213可直接访问mi
- 若不开DMZ,在 huawei router 中创建一个端口映射2222到mi, 可通过 ssh hua@192.168.99.213 -p2222 -v访问mi
Reference
[1] https://hansendong.me/609/
[2] https://www.right/forum/forum.php?mod=viewthread&tid=4040453
作者:张华 发表于:2020-08-19
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明
问题
升级了500M宽带,但电脑用网线直线WDNR4300路由器用perf3 -s与perf -c 192.168.99.1 -t 3测试时只不到200M.所以在一台式机上安装了软路由,测试结果立马上到接近1000M了.
但用了1000M的电力猫之后,速度又下降到120左右,改成有线连接之后,又马又上到1000M.
看来瓶颈在于WDNR4300与电力猫.
安装软路由
台式机上有两个之前做SR-IOV实验用的千兆网卡 (Winyao WY576T PCI-E X4 双口服务器千兆网卡 82576 1000M), 及一个Intel集成网卡.
- enp6s0f0与enp6s0f1通过passthough映射到KVM虚机. 注意不要使用macvtap+bridge模式,因为这样会造成无法从局域网ping macvtap设备上的IP,当在插一根网线到Intel集成网卡上后,默认路由总是在enp6s0f0上,从而导致无法访问台式机.enp6s0f0映射到openwrt虚机里是eth1用于生成br-lan, enp6s0f1映射到openwrt虚机里是eth0.
- 直接KVM安装导入OpenWRT x86镜像即可 (github直接下载)
网络拓扑
目前家中的网络拓扑是:
- 光猫,打电话改了桥接
- tplink千兆路由器(192.168.2.0/24)拨号, 下接一千兆交换机接NAS, TV, Camera等.
- 台式机的enp6s0f0接tplink,从软路由(192.168.98.0/24)出来后,enp6s0f1再接一千兆交换机.
- WNDR4300仍然从tplink出(192.168.99.0/24)
- 千兆电力猫连接软路由至卧室(电力猫速度太差,需要改成有线)
目前问题
- 台式机停电再来电自动启动的问题,改了BIOS但还未测试
- tplink上IPv6也要拨号但复用IPv4的拨号连接后是有IPv6地址的(光猫桥接并未挡住什么),客户端直接连接tplink也能拿到IPv6, 但tplink下挂的OpenWRT路由器却拿不到IPv6, 可能是OpenWrt镜像缺包吧,因为在WAN6那里找不到dhcpv6 client,只有dhcp client) ,原因见: https://agong.me/2019/soft-router-compile-ipv6-mppddial-by-top-navigation.html (20200824更新,就是这个原因). 那现在另外一个路由器以dhcp接在这个拨号路由器后lan口又如何获取IPv6地址呢?
- ubuntu在/etc/network/interfaces不定义时可以拿到IPv6,但要使用桥接如何定义也能拿到IPv6呢?
- 如何将无线网卡给KVM用,同时在openwrt虚机中用它做AP?
一级路由访问二级路由
当在一级redmi ax5路由(192.168.2.1)下又接了一个二级openwrt路由(192.168.2.47, 192.168.99.1).
那一级路由下的node1(192.168.2.111)如何访问二级路由下的t440p (192.168.99.136)呢?
1, 先照着这处贴子将redmi ax5的ssh打开, 必须重启,之后就可以通过root/admin 来ssh了(不影响web管理密码), 然后使用’passwd root’来修改密码.
http://192.168.2.1/cgi-bin/luci/;stok=5aa4576eb44e9e70dc1557c3e74b57a2/web/home#router
http://192.168.2.1/cgi-bin/luci/;stok=5aa4576eb44e9e70dc1557c3e74b57a2/api/misystem/set_config_iotdev?bssid=Xiaomi&user_id=longdike&ssid=-h;nvram set ssh%5Fen%3D1; nvram commit;
http://192.168.2.1/cgi-bin/luci/;stok=5aa4576eb44e9e70dc1557c3e74b57a2/api/misystem/set_config_iotdev?bssid=Xiaomi&user_id=longdike&ssid=-h%3B%20nvram%20set%20ssh_en%3D1%3B%20nvram%20commit%3B%20sed%20-i%20's%2Fchannel%3D.*%2Fchannel%3D%5C%22debug%5C%22%2Fg'%20%2Fetc%2Finit.d%2Fdropbear%3B%20%2Fetc%2Finit.d%2Fdropbear%20start%3B
http://192.168.2.1/cgi-bin/luci/;stok=5aa4576eb44e9e70dc1557c3e74b57a2/api/misystem/set_config_iotdev?bssid=Xiaomi&user_id=longdike&ssid=-h%3B%20echo%20-e%20'admin%5Cnadmin'%20%7C%20passwd%20root%3B
2, 在二级路由器上如下图关闭防火墙,
3, 在一级路由下添加静态路由
route add -net 192.168.99.0 netmask 255.255.255.0 gw 192.168.2.47
4, 在二级路由上将192.168.2.47作静态IP绑定(MAC/IP绑定即可)
5, 如果不行,似乎在一级路由器上上图中lan处防火墙设置中的forwarding不能是REJECT哦.
20210506更新
目前,set_config_iotdev已经被删除,所以已经无法为remi ax5做ssh
目前软路由win10上有两个虚机,一个openwrt(192.168.2.58, 192.168.99.1),一个ubuntu(192.168.2.67).
redmi ax5可以做静态映射ssh到192.168.2.67, 然后在192.168.2.67上添加静态路由:
hua@bastion:~$ cat /etc/rc.local
#!/bin/sh -e
route del -net 192.168.99.0 netmask 255.255.255.0 gw 192.168.2.58 >/dev/null 2>&1 &
sleep 2
route add -net 192.168.99.0 netmask 255.255.255.0 gw 192.168.2.58
exit 0
如果遇到下列错误,是需要将openwrt上的FORWARD规则给关闭:
hua@bastion:~$ ping -c1 192.168.99.136
PING 192.168.99.136 (192.168.99.136) 56(84) bytes of data.
From 192.168.2.58 icmp_seq=1 Destination Port Unreachable
对于通过vnc从外部访问t440p (192.168.99.136),本来想着再开一个wifi( 192.168.2.34),然后在redmi ax5做针对192.168.2.34作端口映射,但实际是在外部无法telnet它,应该是遇到了对称路由问题
DDNS
miwifi上集成的DDNS服务基本上都是收费的, 花生壳的二级域名壳域名不收费, 但这家公司喜欢删域名, 要求你实名制, 但实名制前又问你最喜欢的动物是什么, 答错了还弄不成实名制, 打电话给客服了, 让你把身份证扫描件发到800@oray人工审核, 但也没下文了, 等得头疼. 另外, 就是太喜欢删域名了, 申请的壳域名忽然就删了, 被删了也不知道的怎么被删的, 死得不明不白. 得了, 还是整个免费的吧. 申请一个dnsexit的二级域名, 然后用下列脚本更新.
bash -c 'cat > /data/ddns' << EOF
#!/bin/sh
myip=$(curl -s http://myip.dnsomatic/)
if [ -e "ip.txt" ]
then
old_ip=$(cat ip.txt)
if [ "$myip" == "$old_ip" ]
then
echo "Your IP $myip didn't change."
else
echo "$myip" > ip.txt
echo "The IP Changed from $old_ip to $myip"
change_dot_com=$(curl -s "http://update.dnsexit/RemoteUpdate.sv?login=<user>&password=<password>&host=<domain>&myip=${myip}")
echo "$change_dot_com"
sleep 2
fi
else
echo "$myip" > ip.txt
echo "Your IP is $myip"
fi
EOF
chmod +x /data/ddns
crontab -e
*/60 * * * * /data/ddns >/dev/null 2>&1
nslookup -vc quqi99.publicvm 8.8.8.8
防火墙
1, 默认REJET
config defaults
option syn_flood '0'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option drop_invalid '1'
option disable_ipv6 '0'
config zone
option name 'lan'
option network 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
config zone
option name 'wan'
list network 'wan'
list network 'wan6'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option masq '1'
option mtu_fix '1'
2, 打开22端口
config rule 'ssh'
option name 'ssh'
option src 'wan'
option dest_port '22'
option proto 'tcp'
option target 'ACCEPT'
option family 'ipv4'
3, 转发2222端口
config redirect 'wan2222rdr1'
option proto 'tcp'
option src_dport '2222'
option dest_ip '192.168.2.47'
option dest_port '22'
option src 'wan'
option name 'x86_openwrt'
option target 'DNAT'
option ftype '1'
option dest 'lan'
root@XiaoQiang:~# iptables-save |grep 47
-A zone_lan_postrouting -s 192.168.2.0/24 -d 192.168.2.47/32 -p tcp -m tcp --dport 22 -m comment --comment "!fw3: x86_openwrt (reflection)" -j SNAT --to-source 192.168.2.1
-A zone_lan_prerouting -s 192.168.2.0/24 -d 123.115.196.xxx/32 -p tcp -m tcp --dport 2222 -m comment --comment "!fw3: x86_openwrt (reflection)" -j DNAT --to-destination 192.168.2.47:22
-A zone_wan_prerouting -p tcp -m tcp --dport 2222 -m comment --comment "!fw3: x86_openwrt" -j DNAT --to-destination 192.168.2.47:22
转发端口时不需要为2222单独定义input规则, 另外, 联通除了封80, 443, 以外其实没有封其它端口, 可用https://tool.chinaz/port/ 检测 (检测时得做redirect规则, 且开服务)
https网站不好使
像csdn与baidu等网站出现HSTS相关的证书错误, 是因为广告过滤大师使用了KoolProxy签发的证书所致, 所以需要关闭广告过滤大师.
docker
vim /etc/docker/daemon.json
"data-root": "/mnt/udisk/docker",
/etc/init.d/dockerd restart
#install a better docker frontend - https://koolshare/thread-180474-1-1.html
docker pull portainer/portainer
#create a continer with portainer image, expose port 9000:9000/tcp and bind mount '/var/run/docker.sock:/var/run/docker.sock'
http://192.168.99.1:9000/#/init/admin
http://192.168.99.1:9000/#/dashboard
#intall docker search ubuntu
docker pull ubuntu
docker run -it ubuntu
docker ps -a
天翼云盘
天翼云盘是一个独立的家庭云空间,不等同于天翼云,无法获取S3登陆参数,也关闭了API - https://zhuanlan.zhihu/p/38592985
所以它无法使用s3fs加载块设备,但使用s3fs的方法类似于:
sudo apt install build-essential libfuse-dev libcurl4-openssl-dev libxml2-dev mime-support automake libtool s3fs
echo xxx:xxx |sudo tee /etc/passwd-s3fs && sudo chmod 600 /etc/passwd-s3fs && sudo chown $USER /etc/passwd-s3fs
sudo mkdir /mnt/tianyi && sudo chown $USER /mnt/tianyi
s3fs -o passwd_file=/etc/passwd-s3fs -o url=http://oos.ctyunapi bucket-dingjia /mnt/tianyi
df -h
fusermount -u /mnt/tianyi
它可以使用sharelist,但用途不大.
#sudo apt install nodejs npm -y && sudo npm install -g npm
git clone https://github/reruin/sharelist.git
cd sharelist && sudo chmod +x ./install.sh && sudo ./install.sh #http://127.0.0.1:33001/
#cd ./sharelist/ && node app.js #http://127.0.0.1:33001/
BaiduPCS-Web
# server side
# nfs GUI(http://192.168.99.1/cgi-bin/luci/admin/nas/nfs)是坏的(luci-app-nfs - https://github/coolsnowwolf/lede/issues/2957),只能使用CLI
echo '/mnt/sdb1/nfs *(rw,sync,no_root_squash,subtree_check)' >> /etc/exports
/etc/init.d/nfsd restart
# client side
showmount -e 192.168.99.1
sudo mount -t nfs 192.168.99.1:/mnt/sdb1/nfs /openwrt
sudo fuser -m -v /openwrt/
$ cat /etc/auto.direct |tail -n1
/openwrt -fstype=nfs4,rsize=32768,wsize=32768 192.168.99.1:/mnt/sdb1/nfs
win10上的nfs client乱码的问题,win10目前支持使用utf-8 - https://zhuanlan.zhihu/p/46254792
20210905更新
现在家中网络拓扑改成了:
- 弱电箱星际宝盒路由器: 192.168.99.0/24,只有我办公的机器用它。光猫改桥接后由它拨号,然后它分到客厅ac2100路由器,及房间办公交换机
- 客厅ac2100路由器: 192.168.2/24 (192.168.99.203),其他的打印机nas什么的避免改动太大仍然沿用192.168.2.0/24网段
弱电箱路由器由得做两件事:
- route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.99.203
- 将192.168.99.203做ip/mac绑定来固定IP
客厅路由器添加防火墙规则: - 两个路由器都添加:iptables -A FORWARD -s 192.168.99.0/24 -d 192.168.2.0/24 -j ACCEPT
另外在弱电箱路由器为所有转发的端口需在/etc/config/firewall中配置:
config redirect 'wan2222rdr1'
option proto 'tcp'
option src_dport '2222'
option dest_ip '192.168.99.203'
option dest_port '22'
option src 'wan'
option name 'ssh'
option target 'DNAT'
option ftype '1'
option dest 'lan'
这样会产生:
-A zone_lan_postrouting -s 192.168.99.0/24 -d 192.168.1.203/32 -p tcp -m tcp --dport 1194 -m comment --comment "!fw3: openvpn (reflection)" -j SNAT --to-source 192.168.1.1
-A zone_lan_prerouting -s 192.168.99.0/24 -d 123.115.xx.xx/32 -p tcp -m tcp --dport 1194 -m comment --comment "!fw3: openvpn (reflection)" -j DNAT --to-destination 192.168.1.203:1194
-A zone_wan_prerouting -p tcp -m tcp --dport 1194 -m comment --comment "!fw3: openvpn" -j DNAT --to-destination 192.168.99.203:1194
同时两个路由器都得配置INPUT规则
-A zone_wan_input -p tcp -m tcp --dport 22 -m comment --comment "!fw3: ssh" -j ACCEPT
最后,由于将以前常用的192.168.99.0/24改成了192.168.2.0/24,这样不要忘了更新v-p-n中的dns和99相关的路由信息
可在弱电箱路由器的resolve.conf中添加两个快一点的dns server:
223.5.5.5
180.76.76.76
如何访问二级华为路由器下的设备
遇到一个问题,现在换成小米笔记本了,没有有线网卡
二级路由器(192.168.3.0/24)通过192.168.99.213连接着一级路由路(192.168.99.0),
在一级路由器上有一台机器名为proxy (192.168.99.171).
在二级路由器上有一台机器名为mi, 无有线网卡 通过wifi连接(192.168.3.44).
目前在一级openwrt路由器上已经设置下列静态路由:
root@gw:~# ip route list |grep 3
192.168.3.0/24 via 192.168.99.213 dev br-lan metric 1
可以在proxy上ping到 mi
root@proxy:~# ping 192.168.3.44
PING 192.168.3.44 (192.168.3.44): 56 data bytes
64 bytes from 192.168.3.44: icmp_seq=0 ttl=63 time=5.054 ms
92 bytes from gw.lan (192.168.99.1): Redirect Host
64 bytes from 192.168.3.44: icmp_seq=1 ttl=63 time=11.008 ms
但是却无法在proxy上ssh到mi, 这是什么原因呢?
root@proxy:~# ssh hua@mi -v
OpenSSH_8.9p1 Ubuntu-3ubuntu0.1, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to mi [192.168.3.44] port 22.
debug1: Connection established.
debug1: identity file /root/.ssh/id_rsa type 0
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa_sk type -1
debug1: identity file /root/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: identity file /root/.ssh/id_ed25519_sk type -1
debug1: identity file /root/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /root/.ssh/id_xmss type -1
debug1: identity file /root/.ssh/id_xmss-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.1
怎么试怎么不行。最后发现了下列workaround:
- 打开华为路由路的DMZ,将mi加入DMZ, 这样通过 ssh hua@192.168.99.213可直接访问mi
- 若不开DMZ,在 huawei router 中创建一个端口映射2222到mi, 可通过 ssh hua@192.168.99.213 -p2222 -v访问mi
Reference
[1] https://hansendong.me/609/
[2] https://www.right/forum/forum.php?mod=viewthread&tid=4040453
本文标签: 路由
版权声明:本文标题:软路由 (by quqi99) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/jiaocheng/1763955411a2974557.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论