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
centos7的防火墙
查看防火墙命令:sudo systemctl status firewalld(查看后,看到active(running)就意味着防火墙打开了)
关闭防火墙命令:sudo systemctl stop firewalld
开启防火墙命令:sudo systemctl start firewalld
centos7设置允许通过的端口;
firewall-cmd --zone=public --add-port=8080/tcp --permanent
然后重启防火墙:systemctl restart firewalld
就OK了!
输入reboot重启