firewalld 防火墙centos7
在centos7中iptables已经废弃不用
firewalld命令:
查看所有规则
firewall-cmd --list-all
用命令行 来 允许40ip 访问本机
firewall-cmd --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.7.40" accept"
放行40ip并永久生效并写入public.xml文件
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.7.40" accept"
另一种方法:修改规则文件
cd /etc/firewalld/zones
vim public.xml
<rule family="ipv4"> <source address="172.16.0.250"/> <!-- <port protocol="tcp" port="6379"/> --> <accept/> </rule> <rule family="ipv4"> <source address="192.168.7.40"/> <!-- <port protocol="tcp" port="3306"/> --> <accept/> </rule> <rule family="ipv4"> <source address="172.16.0.240"/> <accept/> </rule> <rule family="ipv4"> <source address="192.168.7.238"/> <accept/> </rule>