centos7如何安装和配置iptables

 时间:2026-02-13 08:20:26

1、首先要确认操作系统的版本和位数

[root@localhost ~]# cat /etc/redhat-release 

CentOS Linux release 7.2.1511 (Core) 

[root@localhost ~]# uname -a

Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

[root@localhost ~]# 

centos7如何安装和配置iptables

2、确认了是centos7的系统,要确认下是否已经安装了iptables.service

使用 rpm -qa|grep iptables命令进行验证

[root@localhost ~]# rpm -qa|grep iptables

iptables-1.4.21-16.el7.x86_64

结果只有一个,表面iptables.service 没有安装

centos7如何安装和配置iptables

3、使用yum install iptables-services命令秤棍安装防火墙,输入y继续

centos7如何安装和配置iptables

4、用rpm -qa|grep iptables命令进行验证

[root@localhost ~]# rpm -qa|grep iptables

iptables-1.4.21-18.2.el7_4.x86_64

iptables-services-1.4.21-18.2.el7_4.x86_64

只有两者同时有了才表明安装成功

centos7如何安装和配置iptables

5、启动醒关iptables.service,并查看规则

[root@localhost ~]# systemctl start iptables.service 

[root@localhost ~]# iptables -L                      

Chain INPUT (policy ACCEPT)

target     prot opt source               destination         

ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED

ACCEPT     icmp --  anywhere             anywhere            

ACCEPT     all  --  anywhere             anywhere            

ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ssh

REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)

target     prot opt source           搁羞怕    destination         

REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination         

[root@localhost ~]# 

centos7如何安装和配置iptables

6、开启8086端口

iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 8086 -j ACCEPT

iptables-save

centos7如何安装和配置iptables

  • Oracle 11g ORA-00845 在Linux 下的解决方案
  • VMware Workstation 10开启虚拟机时连接网卡
  • 怎么下载centos系统历史老版本
  • OracleVMVirtualBox如何安装Ubuntu引导步骤
  • Linux下安装SQL Server 2016方法
  • 热门搜索
    怎么腌糖蒜 苹果手机缓存怎么清理 端午节的画怎么画 眼睛散光是怎么回事 双休日加班工资怎么算 dr钻戒怎么样 拉肚子拉血怎么回事 现金流量表怎么填 鳄鱼龟怎么养 初中生厌学怎么办