firewalld 指定IP訪問某端口

firewalld 指定IP訪問某端口

1. 打開firewalld防火牆

systemctl start firewalld.service

 

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

(如下紅色字體須要根據實際狀況修改)html

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

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端口redis

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端口sql

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. 刪除規則

示例:tcp

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

post

好文要頂 關注我 收藏該文  字體

熱愛生活的小白
關注 - 3
粉絲 - 3spa

+加關注rest

0code

0

« 上一篇:linux 7 防火牆操做

posted @ 2018-07-30 11:41 熱愛生活的小白 閱讀(1121) 評論(0) 編輯 收藏

相關文章
相關標籤/搜索