- 启动:
systemctl start firewalld
- 关闭:
systemctl stop firewalld
- 查看状态:
systemctl status firewalld
- 开机禁用 :
systemctl disable firewalld
- 开机启用 :
systemctl enable firewalld
重新加载配置
firewall-cmd --reload
重启防火墙
service firewalld restart
查看已经开放的端口
firewall-cmd --list-ports
关闭已开放的端口,以80端口为例
firewall-cmd --permanent --remove-port=80/tcp
批量开放80到90之间的所有端口
firewall-cmd --zone=public --add-port=80-90/tcp --permanent
批量关闭80到90之间的端口
firewall-cmd --permanent --remove-port=80-90/tcp --remove-port=80-90/tcp
限制单个ip,限制192.168.1.100这个ip访问80端口
firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='192.168.0.200' port protocol='tcp' port='80' reject"
批量限制ip,限制192.168.3.x的所有ip访问80端口
firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='192.168.3.0/24' port protocol='tcp' port='80' reject"
允许单个ip访问80端口
firewall-cmd --permanent --remove-rich-rule="rule family='ipv4' source address='192.168.0.200' port protocol='tcp' port='80' accept"
批量允许多ip访问80端口
firewall-cmd --permanent --remove-rich-rule="rule family='ipv4' source address='192.168.3.0/24' port protocol='tcp' port='80' accept"
查看rich-rule
firewall-cmd --zone=public --list-rich-rules
文章来源地址https://www.toymoban.com/news/detail-733992.html
文章来源:https://www.toymoban.com/news/detail-733992.html
到了这里,关于linux防火墙(firewall)对端口和IP开放与限制的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!