5 月 182017
 

 

因CentOS 7 firewalld未支持出站规则,必要时仍需使用iptables进行防火墙管理

CentOS默认iptables规则

-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited

添加出站规则(先禁止,后允许)

iptables -I OUTPUT -j REJECT
iptables -I OUTPUT -p tcp --sport 22 -j ACCEPT
iptables -I OUTPUT -p icmp -j ACCEPT
iptables -I OUTPUT -p udp --dport 53 -j ACCEPT

添加出站规则(先允许,后禁止)

iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -A OUTPUT -p icmp -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
iptables -A OUTPUT -j REJECT

添加默认禁止出站规则后,所有已配置的允许入站规则,都需要配置相应的允许出站规则

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据