启动、停止firewall
# systemctl start\stop\restart\status firewalld
主配置文件:
/etc/firewalld/zones/public.xml
firewall命令:
开放服务:
# firewall-cmd --permanent --add-service=ssh
关闭服务:
# firewall-cmd --permanent --remove-service=ssh
查看已开放服务:
# firewall-cmd --list-services
开放端口:
# firewall-cmd --permanent --add-port=53/tcp
关闭端口:
# firewall-cmd --permanent --remove-port=53/tcp
查看已开放端口:
# firewall-cmd --list-port
端口转发:
# firewall-cmd --permanet --add-forward-port=port=81:proto=tcp:toport=80:toaddr=10.0.0.2
(注:此时别人访问10.0.0.2的81就是访问80)(貌似重启firewall后该转发就没了)
取消端口转发:
# firewall-cmd --permanet --remove-forward-port=port=81:proto=tcp:toport=80:toaddr=10.0.0.2
查看端口转发:
# firewall-cmd --list-forward-port
重新加载firewall:
# firewall-cmd --reload
或
# firewall-cmd --complete-reload (更彻底)
时间: 2024-10-21 00:09:37