防火墙:
systemctl start firewalld # 启动,
systemctl enable firewalld # 开机启动
systemctl stop firewalld # 关闭
systemctl disable firewalld # 取消开机启动
firewall-cmd --help # 查看帮助
firewall-cmd --state # 查看运行状态
firewall-cmd --get-zone-of-interface=eth0 # 查看指定接口的 Zone 信息
firewall-cmd --zone=public --list-interfaces # 查看指定级别的接口
firewall-cmd --get-service # 查看所有级别被允许的信息
firewall-cmd --get-service --permanent # 查看重启后所有 Zones 级别中被允许的服务,即永久放行的服务
firewall-cmd --reload # 更新规则,不重启服务
firewall-cmd --complete-reload # 更新规则,重启服务
firewall-cmd --zone=external --add-masquerade # 打开端口转发
firewall-cmd --zone=external --add-forward-port=port=22:proto=tcp:toport=3753 # 转发 tcp 22 端口至 3753
firewall-cmd --zone=external --add-forward-port=port=22:proto=tcp:toaddr=192.168.1.100 # 转发 22 端口数据至另一个 ip 的相同端口上
firewall-cmd --zone=external --add-forward-port=port=22:proto=tcp:toport=2055:toaddr=192.168.1.100 # 转发 22 端口数据至另一 ip 的 2055 端口上
firewall-cmd --add-port=443/tcp # 打开443/TCP端口
firewall-cmd --permanent --add-port=3690/tcp # 永久打开3690/TCP端口,永久打开需要reload
firewall-cmd --permanent --remove-port=8080/tcp # 永久删除8080端口,禁止外网访问
firewall-cmd --permanent --query-port=8080/tcp # 查询端口是否开启
永久打开端口 8080-8099 :firewall-cmd --permanent --zone=public --add-port=8080-8099/tcp
linux命令
最新推荐文章于 2025-06-08 14:51:36 发布