1. 程式人生 > >firewalld對指定IP開放指定埠的配置

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