Linux防火墙开放端口
centos 7 :
添加
firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent永久生效,没有此参数重启后失效)
重新载入
firewall-cmd --reload
查看
firewall-cmd --zone=public --query-port=80/tcp
删除
firewall-cmd --zone=public --remove-port=80/tcp --permanent
centos 6:
可在 /et/etc/sysconfig/iptables 配置,之后重启防火区即可:
如图示: -A INPUT -p tcp -m state --state NEW -m tcp --dport 8082 -j ACCEPT
防火墙命令:
查看防火墙状态: service iptables status
开启 :service iptables start
关闭 :service iptables stop
注:cent os7如果出现 redirecting to systemctl ...Failed to ...not loaded. 可通yum 安装:
yum install iptables-services
systemctl enable iptables.service //设置开机启动