Centos7下没有iptables文件

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

systemctl stop firewalld 
systemctl mask firewalld

yum install -y iptables 
yum install iptables-services

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

systemctl start iptables.service
systemctl restart iptables.service // 重启防火墙使配置生效 
systemctl enable iptables.service // 设置防火墙开机启动

关于iptables的相关命令

service iptables status #检查是否安装了iptables 
yum install -y iptables #安装iptables 
yum update iptables #升级iptables 
yum install iptables-services #安装iptables-services 
systemctl disable iptables #禁止iptables服务 
systemctl stop iptables #暂停服务 
systemctl enable iptables #解除禁止iptables 
systemctl start iptables #开启服务

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

[root@momo sysconfig]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name          
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1718/nginx: master  
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1169/sshd           
tcp        0      0 0.0.0.0:443             0.0.0.0:*                                            
tcp6       0      0 :::3306                 :::*                    LISTEN      1008/mysqld         
udp        0      0 0.0.0.0:68              0.0.0.0:*                           784/dhclient        
udp        0      0 172.17.101.100:123      0.0.0.0:*                           907/ntpd            
udp        0      0 127.0.0.1:123           0.0.0.0:*                           907/ntpd            
udp        0      0 0.0.0.0:123             0.0.0.0:*                           907/ntpd            
udp        0      0 0.0.0.0:19791           0.0.0.0:*                           784/dhclient        
udp6       0      0 :::32332                :::*                                784/dhclient        
udp6       0      0 :::123                  :::*                                907/ntpd            
[root@momo sysconfig]# 

发现8080端口并没有被监听;
先关闭防火墙

systemctl stop iptables

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

  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值