关于在Centos7中即没有iptables文件的解决办法

28 篇文章 0 订阅

因为centos7默认的防火墙是firewalld防火墙,不是使用iptables,因此需要先关闭firewalld服务,或者干脆使用默认的firewalld防火墙。


1,关闭防火墙

systemctl stop firewalld 

2,移除自带防火墙

systemctl disable firewalld.service

3,安装防火墙服务

yum install iptables-services

4,启动防火墙服务

systemctl start iptables.service

5,启动报错

Job for iptables.service failed because the control process exited with error code. See "systemctl status iptables.service" and "journalctl -xe" for details.

解决办法: 依次执行以下命令:

iptables -A INPUT -p tcp --dport 443 -j ACCEPT  //开放443端口(HTTPS)

#保存上述规则

service iptables save

#然后开启服务

systemctl restart iptables.service

启动成功!!!

防火墙开机自启设置防火墙常用端口

vim /etc/sysconfig/iptables

添加以下内容:

-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -p udp --destination-port 32355:65535 -j ACCEPT

退出保存即可!

知识拓展

systemctl start iptables                     启动
systemctl status iptables                    查看运行状态
systemctl restart iptables.service           重启
systemctl stop iptables.service              停止
systemctl enable iptables.service            设置开机启动
systemctl disable iptables.service           禁止开机启动
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一蓑烟雨任平生/

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值