1.启动firewalld
systemctl start firewalld.service
2.永久开放80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
3.查看开放的端口
firewall-cmd --list-ports
4.重新加载防火墙生效
firewall-cmd --reload
5.禁止192.168.0.79访问22端口
firewall-cmd --zone=public --add-rich-rule="rule family='ipv4' source address='192.168.0.79' port port=22 protocol=tcp drop" --permanent
firewall-cmd --zone=public --add-rich-rule="rule family='ipv4' source address='36.156.32.13' drop" --permanent
6.取消禁止
firewall-cmd --zone=public --remove-rich-rule="rule family='ipv4' source address='192.168.0.79' port port=22 protocol=tcp drop" --permanent
参考:https://www.cnblogs.com/vicowong/p/11210144.html