3月 17, 2019 |
Nix.Huang
iptables的设置更接近lvs中的描述,决定还是使用iptables
systemctl disable firewalld
yum install iptables-services
systemctl start iptables
systemctl start ip6tables
cat /etc/sysconfig/iptables
可以看到默认的iptables设置,只开放22端口,如果要开放其他的服务,按这一行设置即可。
*filter //filter 表设置规则
:INPUT ACCEPT [0:0] //INPUT链默认的policy为接受
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
//接受状态RELATED,ESTABLISHED
-A INPUT -p icmp -j ACCEPT //接受icmp报文
-A INPUT -i lo -j ACCEPT //接收lo地址的报文
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
//接收目的端口为22的syn报文,如果我们要开放其他端口,按这一行设置即可
-A INPUT -j REJECT --reject-with icmp-host-prohibited //拒绝input的其他报文
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
注意--dport选项是-m tcp模块中的选项,
Posted in: Linux