linux防火墙单独针对一个端口进行限制设置

*filter
:INPUT ACCEPT [345:35776]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [324:38238]

-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT       ----开启ssh22端口,防止登陆不上
-A FORWARD -j ACCEPT
-A OUTPUT -j ACCEPT

 

-A INPUT -s 10.199.77.124 -p tcp -m tcp --dport 8085 -j ACCEPT
-A INPUT -s 114.247.0.58 -p tcp -m tcp --dport 8085 -j ACCEPT            ---允许114.247.0.58访问8085端口
-A INPUT -p tcp -m tcp --dport 8085 -j DROP                                          ---禁用22端口

-A INPUT -j ACCEPT                                                                               ---不限制端口,像没开防火墙一样
 

-A INPUT -j REJECT --reject-with icmp-host-prohibited              -----这两句必须加上
-A FORWARD -j REJECT --reject-with icmp-host-prohibited

COMMIT

你可能感兴趣的:(linux防火墙单独针对一个端口进行限制设置)