- 本文针对Centos6和7
对于Centos6:
查看防火墙:
[root@CactiEZ ~]# service iptables status
关闭防火墙:
[root@CactiEZ ~]# service iptables stop
开启防火墙:
[root@CactiEZ ~]# service iptables start
永久关闭防火墙:
查询开启iptables是否启动
[root@CactiEZ ~]# chkconfig --list | grep iptables
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
由此可见:2/3/4/5都是开机启动,数字代表runlevel等级
[root@CactiEZ ~]# chkconfig iptables off
[root@CactiEZ ~]# chkconfig --list | grep iptables
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
永久开启防火墙:
[root@CactiEZ ~]# chkconfig iptables on
[root@CactiEZ ~]# chkconfig --list | grep iptables
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
对于Centos7:
查看防火墙:
[root@CactiEZ ~]# systemctl status firewald.service
关闭防火墙:
[root@CactiEZ ~]# systemctl stop firewald.service
开启防火墙:
[root@CactiEZ ~]# systemctl start firewald.service
永久关闭防火墙:
[root@CactiEZ ~]# systemctl disable firewald.service
永久开启防火墙:
[root@CactiEZ ~]# systemctl enable firewald.service