我们正在 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 样式的 IP 替换所有公共 IP...
如果我从网关 telnet 到 192.168.10.10:3306,它将连接到正确服务器上的 mysql。如果我 telnet 到 localhost:3306、127.0.0.1:3306 或 abcf:3306,它将立即拒绝连接。在 abce 上 telnet 到 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
我这里是否遗漏了什么 - 或者不应该允许交通?
谢谢您的帮助,如果有任何信息缺失,请询问。
答案1
事实证明,mysql 流量的允许语句“阻止”了它,因为它无法到达执行实际转发的转移规则。
通过添加此规则进行测试:
ipfw 添加 1350 skipto 1700 tcp 从 abce 到我的目标端口 3306
结果,规则 1400 和 1600 将从我们的防火墙中删除,并且 mysql 复制将保持正常。