当前位置: 代码迷 >> 综合 >> CentOS6.9关闭防火墙(IPtables)
  详细解决方案

CentOS6.9关闭防火墙(IPtables)

热度:132   发布时间:2023-10-27 04:04:28.0

CentOS6.9版本 关闭防火墙(IPtables)

实验环境为CentOS6.9版本

查询防火墙状态,防火墙为开启状态

[root@test ~]# /etc/init.d/iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

临时关闭防火墙(重启后失效)

[root@test ~]# /etc/init.d/iptables stop		#关闭防火墙
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@test ~]# /etc/init.d/iptables status		#再次查看防火墙状态
iptables: Firewall is not running.				#防火墙已关闭

有的时候执行/etc/init.d/iptables stop 后查看防火墙并未关闭,可以重新执行几次

禁用IPtables的开机自启动来达到永久关闭防火墙

[root@test ~]# chkconfig | grep iptables		#查看防火墙的开机启动项
iptables       	0:off	1:off	2:on	3:on	4:on	5:on	6:off
#IPtables显示为开机自启动,数字代表运行级别

禁用开机自启动

[root@test ~]# chkconfig iptables off		#关闭IPtables的开机自启动
[root@test ~]# chkconfig | grep iptables	#查询IPtables的开机启动项,设置成功
iptables       	0:off	1:off	2:off	3:off	4:off	5:off	6:off
  相关解决方案