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 # 永久生效,没有此参数重启后失效扫描二维码关注公众号,回复: 8663425 查看本文章重新加载后生效
[root@bogon ~]# firewall-cmd reload查看已开启端口
[root@bogon ~]# firewall-cmd --list-ports