一 防火墙
查看防火墙状态 firewall-cmd --state
关闭防火墙 systemctl stop firewalld.service
打开防火墙 systemctl start firewalld.service
禁止开机启动启动防火墙 systemctl disable firewalld.service
查看开放端口 firewall-cmd --zone=public --list-ports
二 iptables 命令
安装iptables yum install iptables-services
开启iptables防火墙的命令是 systemctl start iptables.service
重启iptables防火墙:systemctl restart iptables.service
关闭iptables防火墙 systemctl stop iptables.service
查看iptables防火墙状态 systemctl status iptables.service
三 使用编辑文件的方式开放特定的端口
主要是编辑/etc/sysconfig/iptables文件,里面内容有:
-A INPUT -j REJECT--reject-with icmp-host-prohibited
-A FORWARD -j REJECT--reject-with icmp-host-prohibited
COMMIT
如果要放行80端口,就在这这三行的前面添加一行内容:
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT