linux - iptables 配置问题
迷茫
迷茫 2017-04-17 16:43:11
0
0
348

我有一台主机, 我试着使用iptables限制来自公网对其的访问,只开放22和655端口在公网里,同时允许121.201.24.85 这一ip不受这一限制。此外,这个机器做了nat网关,负责转发内网机器的请求。
问题是 在我这样配置之后,我无法在这台主机内部访问到公网,dns解析没问题,ping外网ip也通,感觉是到外网的tcp出了问题

iptables -A POSTROUTING -t nat -o eno1 -j MASQUERADE
iptables -I INPUT -d 58.51.101.7 -p tcp  -j DROP 
iptables -I INPUT -d 58.51.101.7  -p tcp --dport 22 -j ACCEPT
iptables -I INPUT -d 58.51.101.7  -p tcp --dport 655  -j ACCEPT
iptables -I INPUT -d 58.51.101.7  -p udp --dport 655  -j ACCEPT
iptables -I INPUT -s 121.201.24.85 -p tcp -j ACCEPT
iptables -I INPUT -s 58.51.101.7 -j ACCEPT

iptables -L

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  58.51.101.7          anywhere            
ACCEPT     tcp  --  121.201.24.85        anywhere            
ACCEPT     udp  --  anywhere             58.51.101.7          udp dpt:tinc
ACCEPT     tcp  --  anywhere             58.51.101.7          tcp dpt:tinc
ACCEPT     tcp  --  anywhere             58.51.101.7          tcp dpt:ssh
DROP       tcp  --  anywhere             58.51.101.7         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination  

求帮助

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!