Linux命令
查看防火墙状态
# Linux
firewall-cmd --state
# Windows
netsh advfirewall show allprofiles
启动/关闭防火墙
# Linux
systemctl start/stop firewalld
# Windows
netsh advfirewall set allprofiles state on/off
添加端口
# Linux
firewall-cmd --zone=public --add-port=8080/tcp --permanent
# Windows
netsh advfirewall firewall add rule name="Open Port 8080" dir=in action=allow protocol=TCP localport=8080
查看已开放的端口
# Linux
firewall-cmd --zone=public --list-ports
# Windows
netsh advfirewall firewall show rule name=all
重新加载配置
# Linux
firewall-cmd --reload
# Windows
netsh advfirewall reload
删除端口
# Linux
firewall-cmd --zone=public --remove-port=8080/tcp --permanent
# Windows
netsh advfirewall firewall delete rule name="Open Port 8080" protocol=tcp localport=8080
其他常用firewalld命令:
# 开机禁用/启用
systemctl disable/enable firewalld
# 查看状态
firewall-cmd --state
# 重新加载配置
firewall-cmd --reload
# 查看区域信息
firewall-cmd --get-zones
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 小黎同志
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果