LVS-DR和OpenVPN:返回没有被路由到vpn的数据包

我已经在两个额外的真实服务器上设置了一个负载平衡器,它由ldirectord和一个由它pipe理的主动 – 被动的mysql服务。

LVS以直接路由模式运行,因此客户端请求直接路由到当前处于活动状态的实际服务器。

真实的服务器ip:192.168.3.41
虚拟IP:192.168.3.100
客户端IP(我的工作站):192.168.100.117

我还在本地办公室网关和负载均衡器之间build立了一个OpenVPN PtP隧道,用于远程pipe理主机。

负载平衡器VPN IP:172.16.3.1
客户端VPN端点ip:172.16.3.2

这是问题:如果我尝试连接到使用真正的IP地址的一切工作正常,但我需要能够连接也使用虚拟IP,并且不起作用。

有一些networking故障排除,似乎在调用虚拟IP时,返回的数据包没有被路由到VPN隧道,真正的服务器正确答复,但数据包stream量停止时,返回到负载平衡器。

在侦听任何端口的客户端上启动NetCat,并尝试使用其真实IP作为源IP工作,而不是使用虚拟IP作为源从真实服务器连接。

此外,如果我尝试使用相同的虚拟IP连接到运行在负载平衡器本身上的服务(lighttpd在端口80上),它的工作原理!

由于这个原因,我怀疑与ldirectord有关的事情,但我无法弄清楚什么!

所以,总结一下:

客户端呼叫端口3306上的192.168.3.41:工作。
客户端呼叫端口80上的192.168.3.100(负载均衡器上的本地lighttpd):正在工作。
客户端呼叫端口3306上的192.168.3.100:不起作用,数据包从真实服务器返回到负载均衡器,并且不被路由到vpn。

这些是我的负载平衡器configuration:

FORWARD CHAIN:

Chain FORWARD (policy DROP 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 95M 68G ACCEPT all -- * * 192.168.3.0/24 0.0.0.0/0 58M 8719M ACCEPT all -- tun+ * 0.0.0.0/0 0.0.0.0/0 17M 16G ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 

销售链:

 Chain POSTROUTING (policy ACCEPT 1377K packets, 84M bytes) pkts bytes target prot opt in out source destination 862K 51M MASQUERADE all -- * * 192.168.3.0/24 0.0.0.0/0 101K 6159K MASQUERADE all -- * bond1 172.16.3.0/24 0.0.0.0/0 

BOND 1接口:

 # ifconfig bond1 bond1 Link encap:Ethernet HWaddr 00:22:19:d5:6d:da inet addr:192.168.3.11 Bcast:192.168.3.255 Mask:255.255.255.0 UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1 RX packets:28854406358 errors:0 dropped:356 overruns:0 frame:0 TX packets:27339806726 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:11071114840327 (10.0 TiB) TX bytes:6071397046829 (5.5 TiB) 

TUN 0接口:

 # ifconfig tun0 tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:172.16.3.1 PtP:172.16.3.2 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1 RX packets:6047779884 errors:0 dropped:0 overruns:0 frame:0 TX packets:7219390246 errors:0 dropped:3234101 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:1060763811007 (987.9 GiB) TX bytes:5651690621029 (5.1 TiB) 

路由表:

 # route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 172.16.3.2 0.0.0.0 255.255.255.255 UH 0 0 0 tun0 192.168.100.0 172.16.3.2 255.255.255.0 UG 0 0 0 tun0 192.168.3.0 0.0.0.0 255.255.255.0 U 0 0 0 bond1 172.16.3.0 172.16.3.2 255.255.255.0 UG 0 0 0 tun0 0.0.0.0 xxx.xxx.xxx.xxx 0.0.0.0 UG 0 0 0 bond0 

内核参数:

 # sysctl -a|grep forw net.ipv4.conf.all.forwarding = 1 net.ipv4.conf.all.mc_forwarding = 0 net.ipv4.conf.default.forwarding = 1 net.ipv4.conf.default.mc_forwarding = 0 net.ipv4.conf.lo.forwarding = 1 net.ipv4.conf.lo.mc_forwarding = 0 net.ipv4.conf.eth0.forwarding = 1 net.ipv4.conf.eth0.mc_forwarding = 0 net.ipv4.conf.eth1.forwarding = 1 net.ipv4.conf.eth1.mc_forwarding = 0 net.ipv4.conf.eth2.forwarding = 1 net.ipv4.conf.eth2.mc_forwarding = 0 net.ipv4.conf.eth3.forwarding = 1 net.ipv4.conf.eth3.mc_forwarding = 0 net.ipv4.conf.bond0.forwarding = 1 net.ipv4.conf.bond0.mc_forwarding = 0 net.ipv4.conf.bond1.forwarding = 1 net.ipv4.conf.bond1.mc_forwarding = 0 net.ipv4.conf.bond2.forwarding = 1 net.ipv4.conf.bond2.mc_forwarding = 0 net.ipv4.conf.tun0.forwarding = 1 net.ipv4.conf.tun0.mc_forwarding = 0 net.ipv4.ip_forward = 1 # sysctl -a|grep arp net.ipv4.conf.all.proxy_arp = 0 net.ipv4.conf.all.arp_filter = 0 net.ipv4.conf.all.arp_announce = 0 net.ipv4.conf.all.arp_ignore = 0 net.ipv4.conf.all.arp_accept = 0 net.ipv4.conf.default.proxy_arp = 0 net.ipv4.conf.default.arp_filter = 0 net.ipv4.conf.default.arp_announce = 0 net.ipv4.conf.default.arp_ignore = 0 net.ipv4.conf.default.arp_accept = 0 net.ipv4.conf.lo.proxy_arp = 0 net.ipv4.conf.lo.arp_filter = 0 net.ipv4.conf.lo.arp_announce = 0 net.ipv4.conf.lo.arp_ignore = 0 net.ipv4.conf.lo.arp_accept = 0 net.ipv4.conf.eth0.proxy_arp = 0 net.ipv4.conf.eth0.arp_filter = 0 net.ipv4.conf.eth0.arp_announce = 0 net.ipv4.conf.eth0.arp_ignore = 0 net.ipv4.conf.eth0.arp_accept = 0 net.ipv4.conf.eth1.proxy_arp = 0 net.ipv4.conf.eth1.arp_filter = 0 net.ipv4.conf.eth1.arp_announce = 0 net.ipv4.conf.eth1.arp_ignore = 0 net.ipv4.conf.eth1.arp_accept = 0 net.ipv4.conf.eth2.proxy_arp = 0 net.ipv4.conf.eth2.arp_filter = 0 net.ipv4.conf.eth2.arp_announce = 0 net.ipv4.conf.eth2.arp_ignore = 0 net.ipv4.conf.eth2.arp_accept = 0 net.ipv4.conf.eth3.proxy_arp = 0 net.ipv4.conf.eth3.arp_filter = 0 net.ipv4.conf.eth3.arp_announce = 0 net.ipv4.conf.eth3.arp_ignore = 0 net.ipv4.conf.eth3.arp_accept = 0 net.ipv4.conf.bond0.proxy_arp = 0 net.ipv4.conf.bond0.arp_filter = 0 net.ipv4.conf.bond0.arp_announce = 0 net.ipv4.conf.bond0.arp_ignore = 0 net.ipv4.conf.bond0.arp_accept = 0 net.ipv4.conf.bond1.proxy_arp = 0 net.ipv4.conf.bond1.arp_filter = 0 net.ipv4.conf.bond1.arp_announce = 0 net.ipv4.conf.bond1.arp_ignore = 0 net.ipv4.conf.bond1.arp_accept = 0 net.ipv4.conf.bond2.proxy_arp = 0 net.ipv4.conf.bond2.arp_filter = 0 net.ipv4.conf.bond2.arp_announce = 0 net.ipv4.conf.bond2.arp_ignore = 0 net.ipv4.conf.bond2.arp_accept = 0 net.ipv4.conf.tun0.proxy_arp = 0 net.ipv4.conf.tun0.arp_filter = 0 net.ipv4.conf.tun0.arp_announce = 0 net.ipv4.conf.tun0.arp_ignore = 0 net.ipv4.conf.tun0.arp_accept = 0 

提前谢谢你帮助我。