centos7 开放端口 防火墙配置

Published on Aug. 22, 2023, 12:11 p.m.

firewalld is not running centos 7

#安装防火墙
rpm -qa firewalld
# expected output: firewalld-0.6.3-2.el7_7.2.noarch

# if not installed, install it
yum install firewalld

# check the status of the service (running and enabled)
systemctl status firewalld

# if the service is not running, start it
systemctl start firewalld

# if the service has exited, restart it(check for error if any)
systemctl restart firewalld

# if the service is not enabled, enable it
systemctl enable firewalld

参考链接
https://stackoverflow.com/questions/24729024/open-firewall-port-on-centos-7

centos 开放端口

#开放端口
firewall-cmd --zone=public --add-port=8081/tcp --permanent
#多个端口
firewall-cmd --zone=public --add-port=38800-38899/udp --permanent
#查看开放端口
firewall-cmd --zone=public --permanent --list-ports
#重启防火墙
systemctl restart firewalld.service
#防火墙设置开机启动
systemctl enable firewalld.service
#查看防火墙状态
systemctl status firewalld.service

参考链接
https://stackoverflow.com/questions/24729024/open-firewall-port-on-centos-7

更多参考
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-firewalld-on-centos-7