CentOS 7.2 里iptables防火墙怎么关闭

2026年09月10日 02:17
有4个网友回答
网友(1):

centos从7开始默认用的是firewalld,这个是基于iptables的,虽然有iptables的核心,但是iptables的服务是没安装的。所以你只要停止firewalld服务即可:
sudo systemctl stop firewalld.service && sudo systemctl disable firewalld.service
如果你要改用iptables的话,需要安装iptables服务:
sudo yum install iptables-services
sudo systemctl enable iptables && sudo systemctl enable ip6tables
sudo systemctl start iptables && sudo systemctl start ip6tables

网友(2):

  你好,从《linux就该这么学》的教材得知 CentOS 7系列默认采用firewall作为系统防火墙,既然你已经问iptables怎么关闭了,默认的就是您已经停用firewall且安装好iptables了,有关关闭iptables的命令开关的命令有以下几个:
  查询防火墙状态:
  [root@localhost ~]# service iptables status
  停止防火墙:
  [root@localhost ~]# service iptables stop
  启动防火墙:
  [root@localhost ~]# service iptables start
  重启防火墙:
  [root@localhost ~]# service iptables restart
  永久关闭防火墙:
  [root@localhost ~]# chkconfig iptables off
  永久关闭后启用:
  [root@localhost ~]# chkconfig iptables on
  希望能够帮助你!并且推荐你看看《Linux 就该这么学》,是以rhel7作为教学的系统来编写的教材,一直在更新,同时百度搜索以后 打开官网每天都有很多linux技巧,咨讯,以及技术干货!

网友(3):

1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
  2、iptables防火墙(这里iptables已经安装,下面进行配置)
vi/etc/sysconfig/iptables #编辑防火墙配置文件
# sampleconfiguration for iptables service
# you can edit thismanually or use system-config-firewall
# please do not askus to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT[0:0]
:OUTPUT ACCEPT[0:0]
-A INPUT -m state--state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -jACCEPT
-A INPUT -i lo -jACCEPT
-A INPUT -p tcp -mstate --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -jACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080-j ACCEPT
-A INPUT -j REJECT--reject-with icmp-host-prohibited
-A FORWARD -jREJECT --reject-with icmp-host-prohibited
COMMIT
:wq! #保存退出
  

网友(4):

  由来征战地,不见有人还。