在CentOS 6系统中,通过以下命令重新启动iptables会不会停止网站?
$ service iptables restart
默认情况下,不。 /etc/init.d/iptables脚本在重新启动时执行以下操作:
restart() { [ "x$IPTABLES_SAVE_ON_RESTART" = "xyes" ] && save stop start }
尽pipe存在保存现有规则的问题,但未经修改的stop的作用是禁用所有规则:
[root@bill ~]# service iptables stop iptables: Setting chains to policy ACCEPT: mangle nat filte[ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] [root@bill ~]# iptables -L -n -v Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination
假设(a)你保存规则stop ,并且你现有的规则是你想要的,或者(b)你不保存stop规则,并且你在/etc/sysconfig/iptables提出的规则集在语法上和function上是正确的,当start将规则放回原处时,服务应该不中断。
状态表不受停止防火墙规则的影响,因此stop之前有状态规则允许通过的任何stream量在start后应该继续保持。 但是,NAT规则确实会(暂时)被stop擦除,所以如果您使用NAT,则可能会受到重新启动的影响。