一) iptables 常用选项和参数 二种查看方法 和 区别 iptables -nL --line-numbers # 人类友好 可阅读 iptables -S # 他输出的结果,可以直接跟在 iptables 后面 [root@git /root]#iptables -S | head -5 -P INPUT ACCEPT -P FORWARD DROP -P OUTPUT ACCEPT -N DOCKER -N DOCKER-ISOLATION-STAGE-1 [root@git /root]#iptables -P FORWARD ACCEPT [root@git /root]#iptables -S | head -5 -P INPUT ACCEPT -P FORWARD ACCEPT -P OUTPUT ACCEPT ## 清除iptables规则 iptables -F # -F flush 清空所有规则 iptables -X # -X 清空 所有用户自定义的chain规则。 iptables -A #在后面增加一条规则 -I #插入在最前面。也可以指定插入到某条规则前面。 -D #删除 -L #list -P # -P policy 默认策略 -R # replace 替换 二) firewall-cmd 和 firewall-config(gui) firewall-cmd --list-all-zones ##查看所有zone, #其中系统自带“预置”的9个区域zone # 1. Change the target permanently ## --permanent 选项,永久生效。 firewall-cmd --permanent --zone=public --set-target=ACCEPT # 2. Reload to apply changes firewall-cmd --reload firewall-cmd --get-default-zone ## 相当是个模板,对将来有效。 ## set-default-zone firewall-cmd --get-active-zones ## 现在的情况。 网卡interface 处于哪个区域zone