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、配置防火墙规则

查看当前系统是否安装防火墙

安装 iptables

安装 iptables-services

查看iptables现有规则

防火墙是需要开启80端口,不然外网就不能访问到主机资源。

开启相尺悔笑关规则的命令:

保存配陵含置,并前戚重启:


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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存