Linux下打开和关闭防火墙
1.及时生效,重启后复原
关闭:service iptables stop 开启:service iptalbes start 查看状态:service iptables status(关闭状态的话会提示firewal is not running)
2.非及时性生效,重启后永久性生效
关闭:chkconfig iptbales off 开启:chkconfig iptables on 查看状态:chkconfig iptables --list
在开启了防火墙时,做如下设置,开启相关端口,
修改/etc/sysconfig/iptables 文件,添加以下内容:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT