#允許192.168.142.166訪問5432端口 [root@henry ~]# firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="5432" accept" --permanent #允許所有IP訪問80端口 --permanent 表示永久生效,不加重啟就會失效 [root@henry ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent #刪除某條規則 [root@henry ~]# firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="11300" accept" #查看規則 [root@henry ~]# firewall-cmd --list-all #每次修改規則之后都要重啟firewalld才會生效 [root@henry ~]# systemctl restart firewalld