#开启或关闭防火墙
#centos7.X
systemctl start firewalld
systemctl stop firewalld
#rhel6.x
service iptables start
service iptables stop
#查看防火墙开启状态
#centos7.X
systemctl status firewalld
#rhel6.X
service iptables status
#说明:有显示数据就说明iptables是开启状态,如果没有开启会反馈iptables: Firewall is not running.
#开放防火墙端口
#centos7.X
#查看端口开放列表
运行firewall-cmd指令必须是firewalld为启动状态下
firewall-cmd —list-all
#开放端口
firewall-cmd —zone=public —add-port=端口号/tcp(对应协议名称) —permanent
#重新加载防火墙规则
firewall-cmd —reload