Firewall

從 dmz 內部的一個埠轉發到 dmz 外部的伺服器

  • March 29, 2011

我們在 dmz 外部的伺服器和 dmz 內部的伺服器之間執行 mysql 複製,為此我們需要埠轉發。我們已經設置了它,但它最近停止了工作。就在我們添加一條規則(規則編號 01500)之前,該規則將允許 nrpe 的流量(使用 naigos 進行監控)。

該設置由執行 mysql (5.1.22-rc-community-log) 的舊版 redhat 5 伺服器組成,該伺服器應從執行 mysql (5.1.42-log) 的 freebsd 8.0-RELEASE 伺服器(這是 192.168.10.10) 接收數據) 在執行 freebsd 8.0-RELEASE-p2 的網關後面。

請注意,我將用 abcd 樣式的 ips 替換所有公共 ips…

如果我從網關遠端登錄到 192.168.10.10:3306,它將連接到正確伺服器上的 mysql。如果我遠端登錄到 localhost:3306、127.0.0.1:3306 或 abcf:3306,它將立即拒絕連接。在 abce 上遠端登錄到 abcf:3306 做同樣的事情。

我排除了它以允許流量,因為:

natd 程序如下所示:

/sbin/natd -redirect_port tcp 192.168.10.10:3306 3306 -n bce0  

/etc/hosts.allow 看起來像:

ALL : ALL : allow

網關防火牆看起來像:

00100 allow ip from any to any via lo0  
00200 deny ip from any to 127.0.0.0/8  
00300 deny ip from 127.0.0.0/8 to any  
00400 deny ip from 192.168.10.0/24 to any in via bce0  
00500 deny ip from a.b.c.d/26 to any in via bce1  
00600 deny ip from any to 10.0.0.0/8 via bce0  
00700 deny ip from any to 172.16.0.0/12 via bce0  
00800 deny ip from any to 192.168.0.0/16 via bce0  
00900 deny ip from any to 0.0.0.0/8 via bce0  
01000 deny ip from any to 169.254.0.0/16 via bce0  
01100 deny ip from any to 192.0.2.0/24 via bce0  
01200 deny ip from any to 224.0.0.0/4 via bce0  
01300 deny ip from any to 240.0.0.0/4 via bce0  
01400 allow tcp from a.b.c.e to me dst-port 3306  
01500 allow tcp from a.b.c.d/26 to me dst-port 5666  
01600 deny tcp from any to me dst-port 3306 in via bce0  
01700 divert 8668 ip from any to any via bce0  
01800 deny ip from 10.0.0.0/8 to any via bce0  
01900 deny ip from 172.16.0.0/12 to any via bce0  
02000 deny ip from 192.168.0.0/16 to any via bce0  
02100 deny ip from 0.0.0.0/8 to any via bce0  
02200 deny ip from 169.254.0.0/16 to any via bce0  
02300 deny ip from 192.0.2.0/24 to any via bce0  
02400 deny ip from 224.0.0.0/4 to any via bce0  
02500 deny ip from 240.0.0.0/4 to any via bce0  
02600 allow tcp from any to any established  
02700 allow ip from any to any frag  
02800 allow tcp from any to me dst-port 22 setup  
02900 allow tcp from any to me dst-port 25 setup  
03000 allow tcp from any to me dst-port 53 setup  
03100 allow udp from any to me dst-port 53  
03200 allow udp from me 53 to any  
03300 allow udp from any 53 to any  
03400 allow udp from any to any dst-port 53  
03500 allow tcp from any to me dst-port 80 setup  
03600 allow tcp from any to me dst-port 443 setup  
03700 allow icmp from me to any  
03800 allow tcp from any to any setup  
03900 allow udp from me to any dst-port 53 keep-state  
04000 allow udp from me to any dst-port 123 keep-state  
04100 allow log ip from any to any  
65535 deny ip from any to any  

我在這裡遺漏了什麼 - 還是不應該允許交通?

感謝您的幫助,請詢問是否缺少資訊。

事實證明,mysql 流量的允許語句“阻止”了它,因為它被阻止到達將執行實際轉發的轉移規則。

通過添加此規則完成測試:

ipfw add 1350 skipto 1700 tcp from abce to me dst-port 3306

結果,規則 1400 和 1600 將從我們的防火牆中刪除,然後 mysql 複製將保持正常。

引用自:https://serverfault.com/questions/251393