centos 6.x 7.x防火墙开启端口范围IP地址 配置
#centos 6.x
#在开启防火墙的情况下打开nfs
iptables -L -n
#开启端口
iptables -A INPUT -p tcp --dport 892 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 892 -j ACCEPT
service iptables save
service iptables restart
#删除规则
iptables --delete OUTPUT 3
#查看该台机器的端口范围
cat /proc/sys/net/ipv4/ip_local_port_range
#开启端口范围开启防火墙
iptables -A INPUT -s 192.168.75.132 -p tcp --dport 1000:60000 -j ACCEPT
iptables -A INPUT -s 192.168.75.132 -p tcp --dport 1000:60000 -j ACCEPT
#centos7.x为某个ip打开端口范围
firewall-cmd --permanent --add-rich-rule=“rule family=‘ipv4’ source address=‘192.168.75.128’ protocol=‘tcp’ port port=‘1000-60000’ accept”
firewall-cmd --permanent --add-rich-rule=“rule family=‘ipv4’ source address=‘192.168.75.129’ accept”
firewall-cmd --permanent --add-rich-rule=“rule family=‘ipv4’ source address=‘192.168.75.128’ accept”
firewall-cmd --permanent --add-rich-rule=“rule family=‘ipv4’ source address=‘192.168.75.130’ accept”
#查看公共区域开放的端口
firewall-cmd --zone=public --list-all
#重新加载配置
firewall-cmd --reload
开放端口范围
firewall-cmd --permanent --zone=public --add-port=1000-60000/tcp
#删除规则
firewall-cmd --permanent --remove-rich-rule=“rule family=“ipv4” source address=“192.168.75.129” port protocol=‘tcp’ port=‘1000-60000’ accept”
firewall-cmd --permanent --remove-rich-rule=“rule family=“ipv4” source address=“192.168.75.128” port protocol=‘tcp’ port=‘1000-60000’ accept”
firewall-cmd --permanent --remove-rich-rule=“rule family=“ipv4” source address=“192.168.75.130” port protocol=‘tcp’ port=‘1000-60000’ accept”
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31506529/viewspace-2650856/,如需转载,请注明出处,否则将追究法律责任。