centos7防火墙端口开放命令

Centos7

Centos7 的firewalld 取代了iptables

查看开放端口

 firewall-cmd --list-ports

开启端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

开启范围端口 8080 - 9090范围的端口

firewall-cmd  --zone=public  --add-port=8080-9090/tcp --permanent

命令含义

–zone                          #作用域
–add-port=80/tcp               #添加端口,格式为:端口/通讯协议
–permanent                     #永久生效,没有此参数重启后失效

防火墙命令

重启firewall

firewall-cmd --reload 
systemctl restart  firewalld     

查看防火墙状态

firewall-cmd  --state 
systemctl status  firewalld  

开启firewall

systemctl start firewalld.service   

停止firewall

systemctl stop firewalld.service     

禁止firewall开机启动

systemctl disable firewalld.service    

开机启动firewall

systemctl enable firewalld.service 

删除80端口

firewall-cmd --zone=public --remove-port=80/tcp --permanent

Centos6

查看开放端口

service iptables status

开启8080端口

/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

开启命令

service iptables start

关闭命令

service iptables stop 

永久关闭防火墙

chkconfig iptables off

可能发生的异常

1.启动或者关闭防火墙没任何的提示

[root@123 ~]# service iptables start
[root@123 ~]# service iptables stop

2.查看防火墙的状态直接提示模块未加载

[root@123 ~]# service iptables status
iptables: Firewall modules are not loaded.

修复方法

modprobe  ip_tables                 #加载ip_tables模块
modprobe  iptable_filter            #加载iptable_filter模块
[root@123 ~]# lsmod | grep iptable  #查看模块,有模块即解决了
iptable_filter          2173  0 
ip_tables               9567  1 iptable_filter
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

踩坑数十载

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

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

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

打赏作者

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

抵扣说明:

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

余额充值