v5tech / notes

notes
https://ameizi.gitee.io/notes
MIT License
1.52k stars 378 forks source link

Centos7防火墙配置 #173

Open v5tech opened 6 years ago

v5tech commented 6 years ago

firewall

查看状态

systemctl status firewalld

firewall-cmd --state
firewall-cmd --get-active-zones

firewall-cmd --permanent --zone=public --list-all

开放4222、5222端口

firewall-cmd --permanent --zone=public --add-port=4222/tcp

firewall-cmd --permanent --zone=public --add-port=5222/tcp

启用配置

systemctl enable firewalld

iptables

查看iptables

iptables-save

开放4222、5222端口

iptables -A IN_public_allow -p tcp -m tcp --dport 4222 -m conntrack --ctstate NEW -j ACCEPT

iptables -A IN_public_allow -p tcp -m tcp --dport 5222 -m conntrack --ctstate NEW -j ACCEPT

保存iptables配置

iptables-save