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
输入 reboot 重启
来源: http://www.bubuko.com/infodetail-3123947.html