CentOS-7.5 使用 iptables

CentOS-7.5 使用 iptables,第1张

1、关闭 firewalld

由于 firewalld 是 CentOS-7系列的默认防火墙,因此如果想使用iptables的话,需要将CentOS-7系列的默认防火墙 firewalld 关闭,并安装 iptables-services 

[root@shell ~]#

[root@shell ~]# systemctl  stop  firewalld.service            #关闭

[root@shell ~]# systemctl  disable  firewalld.service        #禁止开机自启动

[root@shell ~]# firewall-cmd  --state          #查看firewalld是否在运行

not  running

[root@shell ~]#

2、安装iptables防火墙

[root@shell ~]#

[root@shell ~]# yum install iptables-services                  #安装iptables服务

[root@shell ~]# systemctl  start  iptables

[root@shell ~]# systemctl  enable  iptables                      #设置iptables为开机自启动

[root@shell ~]#

[root@shell ~]# cat  /etc/sysconfig/iptables            #查看iptables默认配置

[root@shell ~]# 

[root@shell ~]#

[root@shell ~]# systemctl  start  iptables             #启动 iptables

[root@shell ~]# systemctl  status  iptables            #查看状态

[root@shell ~]#

[root@shell ~]# iptables  -L                  #查看当前防火墙规则

3、配置防火墙规则

CentOS7关闭防火墙设置的方法:

1、命令:/etc/init.d/iptablesstop。

出现三个OK,关闭成功,此时防火墙已经关闭,不需重启已经生效。

2、命令:/etc/init.d/iptables status。

关闭后查看状态,应该显示firewallisnotrunning。

一、查看防火墙状态:

命令:/etc/init.d/iptables status。

二、永久性关闭防火墙的方法:

1、命令:#chkconfig --level 2345iptables off,或者 #chkconfig iptables off。

2、2345代表“执行等级”。

(1)等级0表示:表示关机。

(2)等级1表示:单用户模式。

(3)等级2表示:无网络连接的多用户命令行模式。

(4)等级3表示:有网络连接的多用户命令行模式。

(5)等级4表示:不可用。

(6)等级5表示:带图形界面的多用户模式。

(7)等级6表示:重新启动。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/11086108.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-13
下一篇 2023-05-13

发表评论

登录后才能评论

评论列表(0条)

保存