1.查看防火墙状态:active (running) 即是开启状态
systemctl status Linux
2.查看已开发端口命令:
firewall-cmd --list-all
3.新增Linux开放端口:
firewall-cmd --zone=public --add-port=3306/tcp --permanent
4.开放端口后需要重新加载Linux:
firewall-cmd --reload
5.Linux的基本使用命令:
启动: systemctl start Linux 关闭: systemctl stop Linux 查看状态: systemctl status Linux 开机禁用 : systemctl disable Linux 开机启用 : systemctl enable Linux
6.配置Linux-cmd命令
查看版本: firewall-cmd --version 查看帮助: firewall-cmd --help 显示状态: firewall-cmd --state 查看所有打开的端口: firewall-cmd --zone=public --list-ports 更新Linux规则: firewall-cmd --reload 查看区域信息: firewall-cmd --get-active-zones 查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0 拒绝所有包:firewall-cmd --panic-on 取消拒绝状态: firewall-cmd --panic-off 查看是否拒绝: firewall-cmd --query-panic
7.systemctl相关命令
启动一个服务:systemctl start Linux.service 关闭一个服务:systemctl stop Linux.service 重启一个服务:systemctl restart Linux.service 显示一个服务的状态:systemctl status Linux.service 在开机时启用一个服务:systemctl enable Linux.service 在开机时禁用一个服务:systemctl disable Linux.service 查看服务是否开机启动:systemctl is-enabled Linux.service 查看已启动的服务列表:systemctl list-unit-files|grep enabled 查看启动失败的服务列表:systemctl --failed