互联网负载均衡器和后端之间的路由配置

互联网负载均衡器和后端之间的路由配置

由于缺乏路由经验,我遇到了一个问题。我需要配置接下来的东西(所有这些都在我的虚拟化计算机上运行,​​如果可行,我会将其传递给硬件)

[互联网] ---- [DMZR]--/--[网关]---/---[负载均衡器]---/---[后端]

互联网:192.168.10.0/24 网关:10.10.10.0/29 负载均衡器:10.10.10.0/29 | 10.10.1.0/24 后端:10.10.1.0/24

负载均衡器有 2 个网卡,一个与网关在同一个网络上:10.10.10.0/29,另一个与后端在同一个网络上 10.10.1.0/24。从负载均衡器的 eth1 可以上网吗?问题出在后端。我甚至无法访问网关,但我无法访问负载均衡器的另一侧(10.10.10.2)。很奇怪,非常奇怪。我应该说,昨天我在主机上使用 ip 192.168.1.239、网关 192.168.1.2,当我更改为 192.168.2.5 gw 1​​92.168.2.1 时,我无法让它再次工作。

我的配置:

Host: 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0e:0c:85:6f:bf brd ff:ff:ff:ff:ff:ff
    inet6 fe80::20e:cff:fe85:6fbf/64 scope link 
       valid_lft forever preferred_lft forever
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN 
    link/ether 00:0e:0c:85:6f:bf brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.5/24 brd 192.168.10.255 scope global br0
    inet6 fe80::20e:cff:fe85:6fbf/64 scope link 
       valid_lft forever preferred_lft forever
4: dmzbr: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN 
    link/ether fe:54:00:32:14:a7 brd ff:ff:ff:ff:ff:ff
    inet 10.10.10.1/29 brd 10.10.10.7 scope global dmzbr
    inet6 fe80::24f2:a2ff:fe69:6cdb/64 scope link 
       valid_lft forever preferred_lft forever
5: mzbr: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN 
    link/ether fe:54:00:59:d7:d1 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::7cfd:aaff:fe31:45dd/64 scope link 
       valid_lft forever preferred_lft forever

iproute 节目主持人:

10.10.10.0/29 dev dmzbr  proto kernel  scope link  src 10.10.10.1 
10.10.1.0/24 via 10.10.10.1 dev dmzbr 
192.168.10.0/24 dev br0  proto kernel  scope link  src 192.168.10.5 
default via 192.168.10.1 dev br0 

iptables 主机

10.10.10.0/29 dev dmzbr  proto kernel  scope link  src 10.10.10.1 
10.10.1.0/24 via 10.10.10.1 dev dmzbr 
192.168.10.0/24 dev br0  proto kernel  scope link  src 192.168.10.5 
default via 192.168.10.1 dev br0 

iptables 网络地址转换

Chain PREROUTING (policy ACCEPT 2206 packets, 439K bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 3271 packets, 212K bytes)
 pkts bytes target     prot opt in     out     source               destination         
   86  5582 MASQUERADE  all  --  *      br0     10.10.10.0/29        0.0.0.0/0           

Chain OUTPUT (policy ACCEPT 2816 packets, 179K bytes)
 pkts bytes target     prot opt in     out     source               destination         

配置负载均衡器

auto lo eth0 eth1
iface lo inet loopback
iface eth0 inet static
        address         10.10.10.2
        netmask         255.255.255.248
        network         10.10.10.0
        broadcast       10.10.10.7
        gateway         10.10.10.1


iface eth1 inet static
        address         10.10.1.3
        netmask         255.255.255.0
        network         10.10.1.0
        broadcast       10.10.1.255
        gateway         10.10.1.3

ip 路由显示

10.10.10.0/29 dev eth0  proto kernel  scope link  src 10.10.10.2 
192.168.10.0/24 via 10.10.10.1 dev eth0 
default via 10.10.10.1 dev eth0 

iptables -nvL

Chain INPUT (policy ACCEPT 22897 packets, 22M bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  eth0   eth1    0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     all  --  eth0   eth0    0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     all  --  eth1   eth0    0.0.0.0/0            0.0.0.0/0           

Chain OUTPUT (policy ACCEPT 15503 packets, 1443K bytes)
 pkts bytes target     prot opt in     out     source               destination         

iptables -t nat

Chain PREROUTING (policy ACCEPT 430 packets, 35328 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 2 packets, 168 bytes)
 pkts bytes target     prot opt in     out     source               destination         
   59  3889 MASQUERADE  all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           

Chain OUTPUT (policy ACCEPT 30 packets, 1976 bytes)
 pkts bytes target     prot opt in     out     source               destination         

配置后端

face eth0 inet static
        address         10.10.1.4
        netmask         255.255.255.0
        network         10.10.1.0
        broadcast       10.10.1.255
        gateway         10.10.1.3

ip 路由显示

10.10.10.0/29 via 10.10.1.3 dev eth0
10.10.1.0/24 dev eth0 proto kernel scope link src 10.10.1.4
default via 10.10.1.3 dev eth0

iptables 上没有过滤任何内容,所有策略均接受

nat 上的 iptables 没有采用任何策略来接受。

多谢你们!!!!!

答案1

您是否已在负载均衡器上启用 IP 转发?

cat /proc/sys/net/ipv4/ip_forward

相关内容