今天家里的服务器,SSH在日本可以成功访问,
在中国的内网中却访问不了。
查看下防火墙配置
sudo iptables -L -n -v
Chain INPUT (policy ACCEPT 43M packets, 81G bytes)
pkts bytes target prot opt in out source destination0 0 ACCEPT 6 -- * * 192.168.3.223 0.0.0.0/0 tcp dpt:8888
34623 2312K ACCEPT 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8888 -m geoip --source-country CN,JP
385 17628 DROP 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8888 -m geoip ! --source-country CN,JP
0 0 ACCEPT 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8888
Chain FORWARD (policy ACCEPT 27M packets, 23G bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 40M packets, 71G bytes)
pkts bytes target prot opt in out source destination
root@linux:~#
想起来之前配置了防火墙规则,允许CN和JP的IP访问,并且只允许了内网的192.168.3.223一台主机访问。
这下好办了,把192.168.3.0/24整个子网全部允许
sudo iptables -I INPUT -p tcp -s 192.168.3.0/24 --dport 8888 -j ACCEPT
root@linux:~# sudo iptables -L -n -v
Chain INPUT (policy ACCEPT 43M packets, 81G bytes)
pkts bytes target prot opt in out source destination
38 7792 ACCEPT 6 -- * * 192.168.3.0/24 0.0.0.0/0 tcp dpt:8888
0 0 ACCEPT 6 -- * * 192.168.3.223 0.0.0.0/0 tcp dpt:8888
34629 2312K ACCEPT 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8888 -m geoip --source-country CN,JP
385 17628 DROP 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8888 -m geoip ! --source-country CN,JP
0 0 ACCEPT 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8888
Chain FORWARD (policy ACCEPT 27M packets, 23G bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 40M packets, 71G bytes)
pkts bytes target prot opt in out source destination
root@linux:~#
sudo netfilter-persistent save
测试,内网的另外一台电脑SSH成功登录。
对了,把以前那条老的规则应该删掉
sudo iptables -D INPUT -p tcp -s 192.168.3.223 --dport 8888 -j ACCEPT
sudo iptables -L -n -v
Chain INPUT (policy ACCEPT 43M packets, 82G bytes)
pkts bytes target prot opt in out source destination
44 8176 ACCEPT 6 -- * * 192.168.3.0/24 0.0.0.0/0 tcp dpt:8888
34662 2315K ACCEPT 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8888 -m ge oip --source-country CN,JP
385 17628 DROP 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8888 -m ge oip ! --source-country CN,JP
0 0 ACCEPT 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8888
Chain FORWARD (policy ACCEPT 27M packets, 23G bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 40M packets, 71G bytes)
pkts bytes target prot opt in out source destination
root@linux:~#
成功,保存。
sudo netfilter-persistent save
没有评论:
发表评论