Centos7下没有iptables文件

在安装tomcat的时候最后出现了需要开放8080端口,发现默认的Centos7并没有iptables文件,这里我来说下这种情况怎么办;
因为Centos7默认使用的是firewall作为防火墙,把它停掉再安装iptable
命令如下:

 
  1. systemctl stop firewalld 

  2. systemctl mask firewalld

  3. 检查是否安装iptables                  service iptables status
  4. yum install -y iptables

  5. yum install iptables-services

现在就看到/etc/sysconfig/目录下就有iptables文件了,我们就可以进行下一步配置了;
配置完成之后开启服务

 
  1. systemctl start iptables.service

  2. systemctl restart iptables.service // 重启防火墙使配置生效 

  3. systemctl enable iptables.service // 设置防火墙开机启动

关于iptables的相关命令

 
  1. service iptables status #检查是否安装了iptables 

  2. yum install -y iptables #安装iptables 

  3. yum update iptables #升级iptables 

  4. yum install iptables-services #安装iptables-services 

  5. systemctl disable iptables #禁止iptables服务 

  6. systemctl stop iptables #暂停服务 

  7. systemctl enable iptables #解除禁止iptables 

  8. systemctl start iptables #开启服务

我这边处理完之后还是不行,而且还影响到了现有服务器上的网站运行,然后进行了下一步排查;
查看端口监听状态

发现8080端口并没有被监听;

 

  1. [root@momo sysconfig]# netstat -lntup

  2. Active Internet connections (only servers)

  3. Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name          

  4. tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1718/nginx: master  

  5. tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1169/sshd           

  6. tcp        0      0 0.0.0.0:443             0.0.0.0:*                                            

  7. tcp6       0      0 :::3306                 :::*                    LISTEN      1008/mysqld         

  8. udp        0      0 0.0.0.0:68              0.0.0.0:*                           784/dhclient        

  9. udp        0      0 172.17.101.100:123      0.0.0.0:*                           907/ntpd            

  10. udp        0      0 127.0.0.1:123           0.0.0.0:*                           907/ntpd            

  11. udp        0      0 0.0.0.0:123             0.0.0.0:*                           907/ntpd            

  12. udp        0      0 0.0.0.0:19791           0.0.0.0:*                           784/dhclient        

  13. udp6       0      0 :::32332                :::*                                784/dhclient        

  14. udp6       0      0 :::123                  :::*                                907/ntpd            

  15.  

先关闭防火墙

systemctl stop iptables

我备份了下规则然后执行了iptables -F命令清空一下
之后将开启的端口号重新写入iptables文件;重启下服务
tomcat的8080端口首页访问就正常了,网站也可以正常访问了;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值