firewalld 指定IP訪問某端口


1. 打開firewalld防火牆

systemctl start firewalld.service

 

2. 添加防火牆規則(對指定ip開放指定端口)

(以下紅色字體需要根據實際情況修改)

(1) Postgresql端口設置。允許192.168.142.166訪問5432端口

firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="5432" accept"

 

(2)redis端口設置。允許192.168.142.166訪問6379端口

firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="6379" accept"

 

(3)beanstalkd端口設置。允許192.168.142.166訪問11300端口

firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="11300" accept"

 

3. 重啟防火牆,使配置生效

systemctl restart firewalld.service

 

4. 查看配置結果,驗證配置

firewall-cmd --list-all

5. 刪除規則

示例:

firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="11300" accept" systemctl restart firewalld.service


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM