1:查看防火状态
systemctl status firewalld
2:暂时关闭防火墙
systemctl stop firewalld
3:永久关闭防火墙
systemctl disable firewalld
4:重启防火墙
systemctl enable firewalld
5:永久关闭后重启
chkconfig iptables on
6:启动防火墙
systemctl start firewalld
7、禁止防火墙开机启动
systemctl disable firewalld.service
开放端口的方法:
方法一:命令行方式
1. 开放端口命令: /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
2.查看端口是否开放:/sbin/iptables -L -n
方法二:指定IP与端口
1.firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="5432" accept" //给指定IP开放指定端口 2.firewall-cmd --permanent --add-rich-rule="rule family="ipv4" port protocol="tcp" port="9501" accept" //开放指定端口 3.重新载入,使配置生效:systemctl restart firewalld.service 4.查看配置结果:firewall-cmd --list-all 5.删除规则:firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="11300" accept"