linux关闭防火墙命令
1. Linux系统:Red Hat Enterprise Linux Server release 6.5 (Santiago)
临时关闭防火墙命令:
service iptables stop
service ip6tables stop
永久关闭防火墙命令:
chkconfig iptables off
chkconfig ip6tables off
查看防火墙状态命令:
service iptables status
[root@hadoop ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.5 (Santiago) [root@hadoop ~]# service iptables stop iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] [root@hadoop ~]# service ip6tables stop ip6tables: Setting chains to policy ACCEPT: filter [ OK ] ip6tables: Flushing firewall rules: [ OK ] ip6tables: Unloading modules: [ OK ] [root@hadoop ~]# service iptables status iptables: Firewall is not running. [root@hadoop ~]# service ip6tables status ip6tables: Firewall is not running. [root@hadoop ~]# chkconfig iptables off [root@hadoop ~]# chkconfig ip6tables off
2. linux系统:CentOS Linux release 7.5.1804 (Core)
前面说的几个命令,我在centos 7上用着都失效了。网上说,centos从7开始默认用的是firewalld,这个是基于iptables的,虽然有iptables的核心,但是iptables的服务是没安装的。所以你只要停止firewalld服务即可
[root@hadoop ~]# sudo systemctl stop firewalld.service && sudo systemctl disable firewalld.service Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
如果你要改用iptables的话,需要安装iptables服务,并对命令做一些修改
[root@hadoop ~]# service iptables stop #命令失效 Redirecting to /bin/systemctl stop iptables.service Failed to stop iptables.service: Unit iptables.service not loaded. [root@hadoop ~]# yum install iptables-services [root@hadoop ~]# /bin/systemctl stop iptables.service [root@hadoop ~]# /bin/systemctl stop ip6tables.service
永久关闭防火墙
[root@hadoop ~]# chkconfig iptables off #命令失效 Note: Forwarding request to 'systemctl disable iptables.service'. [root@hadoop ~]# systemctl disable iptables.service [root@hadoop ~]# systemctl disable ip6tables.service
查看防火墙是否关闭
[root@hadoop ~]# firewall-cmd --state
not running
总结:centos 7系统关闭防火墙有2种方式:
方式1:
关闭防火墙:systemctl stop firewalld.service
永久关闭防火墙:systemctl disable firewalld.service
方式2:
首先安装iptables服务:yum install iptables-services
关闭防火墙:/bin/systemctl stop iptables.service && /bin/systemctl stop ip6tables.service
永久关闭防火墙:systemctl disable iptables.service && systemctl disable ip6tables.service
查看防火墙是否关闭:firewall-cmd --state