安装
1.下载
yum install -y firewalld
yum install -y firewall-config
2.启动
systemctl start firewalld # 启动
systemctl status firewalld #查看firewalld当前状态
systemctl enable firewalld # 开机启动
systemctl stop firewalld # 关闭
systemctl disable firewalld # 取消开机启动
使用
1.查看开放端口命令
firewall-cmd --list-ports
- 添加开放端口
firewall-cmd --zone=public --add-port=5000/tcp --permanent #对外网全部开放
firewall-cmd --zone=public --permanent --add-rich-rule 'rule family=ipv4 source address=192.168.0.1/24 port port=22 protocol=tcp accept' #添加端口开放
firewall-cmd --permanent --remove-rich-rule 'rule family=ipv4 source address=192.168.0.1/2 port port=5000 protocol=tcp accept' #删除端口开放