CentOS 开启防火墙及指定端口

CentOS 开启防火墙及指定端口

1. CentOS7

查看防火墙状态
[root@bogon ~]# firewall-cmd --state

开启防火墙
[root@bogon ~]# systemctl start firewalld.service

重启防火墙
[root@bogon ~]# systemctl restart firewalld.service

关闭防火墙
[root@bogon ~]# systemctl stop firewalld.service

开启指定端口
[root@bogon ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent

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

重新加载后生效
[root@bogon ~]# firewall-cmd reload

查看已开启端口
[root@bogon ~]# firewall-cmd --list-ports

posted @ 2020-01-17 13:52  千藏  阅读(2098)  评论(0)    收藏  举报