CentOS7 firewalld指定IP与端口访问

1、启动防火墙
[root@share ~]# systemctl start firewalld.service

2、指定IP与端口
[root@share ~]# firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.100.77" port protocol="tcp" port="5432" accept"

指定多个端口(连续)

[root@share ~]# firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.100.77" port protocol="tcp" port="13330-13339" accept"

指定ip段可以访问 
[root@share ~]# firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.100.0/24" port protocol="tcp" port="5432" accept"

3、重新载入,使配置生效

[root@share ~]# firewall-cmd --reload

4、查看配置结果

[root@share ~]# firewall-cmd --list-all
5、删除规则
[root@share ~]# firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.100.77" port protocol="tcp" port="445" accept"

你可能感兴趣的:(Linux)