Leif160519的blog
netstat -anp
firewall-cmd --query-port=666/tcp
若此提示 FirewallD is not running
表示为不可知的防火墙 需要查看状态并开启防火墙
systemctl status firewalld
running状态即防火墙已经开启
dead 状态即防火墙未开启
systemctl start firewalld
没有任何提示即开启成功
service firewalld start
关闭防火墙
systemctl stop firewalld
centos7.3 上述方式可能无法开启,可以先
systemctl unmask firewalld.service然后systemctl start firewalld.service
firewall-cmd --query-port=666/tcp
提示no表示未开
firewall-cmd --add-port=666/tcp --permanent
提示 success表示成功
firewall-cmd --reload
比如添加规则之后,需要执行此命令
firewall-cmd --query-port=666/tcp
提示yes表示成功
firewall-cmd --permanent --remove-port=666/tcp
iptables 有些版本需要安装iptables-services , yum install iptables-services 然后修改进目录 /etc/sysconfig/iptables 修改内容192.168.4.0网段的访问1882端口firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.4.0/24" port protocol="tcp" port="1882" accept"
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.81.0/24" port protocol="tcp" port="1882" reject"
“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill
标 题:centos 7.3 开放端口并对外开放