Iptables More Strict

合并简化后的配置文件

[root@ctos ~]# cat /etc/sysconfig/iptables

# Generated by iptables-save v1.4.7 on Wed Aug  5 20:11:35 2015
*filter
:INPUT DROP [3:635]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
-A INPUT -d 192.168.0.31/32  -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -d 192.168.0.31/32 -p tcp -m multiport --dports 21,22,80 -m state --state NEW -j ACCEPT
-A OUTPUT -s 192.168.0.31/32  -m state --state RELATED,ESTABLISHED -j ACCEPT
COMMIT

# Completed on Wed Aug  5 20:11:35 2015

解释

统一配置 iptables的INPUT规则,放行进来的请求

iptables -t filter -I INPUT -d 192.168.0.31  -m state --state ESTABLISHED,RELATED

将INPUT的新建21 22 80 请求合并

iptables -t filter -I -d 192.168.0.31 -p tcp -m multiport --destination-ports 21,22,80 -m state --state NEW -j ACCEPT

统一配置 iptables的OUTPUT规则,只要是已经建立的连接(外部请求进来的),以后只需要放行进来的请求了

iptables -t filter -I OUTPUT -s 192.168.0.31 -m state --state ESTABLISHED,RELATED -j ACCEPT

相关文章: