创build一个带有两个互联网连接和一个局域网连接的多宿主linux负载均衡器

好的…这个可能已经被回答了,不幸的是,我还没有发现任何看起来可能是这个决议的东西。

我看了这些页面,他们有一些有用的信息,但不是完整的决议:

  1. 在Linux上负载均衡和NAT多个ISP连接
  2. 两个Internet连接和1个NIC,可能吗?
  3. Linux分割访问(多个互联网连接与负载平衡
  4. linux防火墙+负载均衡ISP连接

我将要么使用Debian 8,Ubuntu 16.04桌面或Ubuntu 16.04服务器(说实话,最有可能的是Debian)。

好的,所以我将有三个网卡安装两个千兆网卡和板载100 Mbps LAN连接。 ISP连接将通过两个nics上的PPPoE身份validation使用千兆局域网卡(如果这是甚至可能,否则,我会解决DSL调制解调器上的非桥接模式)。 这两个networking将有一个静态的IP分配给他们。 目前(这将改变)主连接有一个五人小组。 我需要将来自其中一个IP地址的stream量路由到networking上的适当服务器。

这是我的问题:

  1. 我如何设置? 我是否使用NAT,IP Chans,IP Masquerading,路由等等?
  2. 如何将从外部进入系统的stream量路由到networking上的特定IP地址?

请温柔一点,这是我以前第一次尝试过这样的东西:)。

编辑1

忘了添加networking拓扑:

内部网络布局

编辑2

刚刚意识到一些事情…为了做PPPoE身份validation,我将不得不在特定的接口上强制身份validation。 这是怎么做的?

我在这里发布了这个问题:

创build一个带有两个互联网连接和一个局域网连接的多宿主linux负载均衡器

更新1

仍然无法获得多跳循环工作。 我试图按照以下站点中列出的步骤运行:

  1. 在Linux上负载均衡和NAT多个ISP连接
  2. Linux – 双因特网连接/负载平衡
  3. HOWTO:Linux多path

我要么不断收到一个消息,说明文件已经存在或无效的设备。 这是/我的设置/信息

IFCONFIG

eth0 Link encap:Ethernet HWaddr ec:08:6b:04:8e:ac inet addr:172.16.0.2 Bcast:172.16.0.255 Mask:255.255.255.0 inet6 addr: fe80::ee08:6bff:fe04:8eac/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:9525 errors:0 dropped:0 overruns:0 frame:0 TX packets:7722 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:9306973 (8.8 MiB) TX bytes:949815 (927.5 KiB) eth1 Link encap:Ethernet HWaddr ec:08:6b:04:8c:95 inet addr:172.16.1.2 Bcast:172.16.1.255 Mask:255.255.255.0 inet6 addr: fe80::ee08:6bff:fe04:8c95/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:9 errors:0 dropped:0 overruns:0 frame:0 TX packets:42 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:558 (558.0 B) TX bytes:6344 (6.1 KiB) eth2 Link encap:Ethernet HWaddr 00:16:76:90:49:b7 inet addr:172.16.2.1 Bcast:172.16.2.255 Mask:255.255.255.0 inet6 addr: fe80::216:76ff:fe90:49b7/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3793 errors:0 dropped:0 overruns:0 frame:0 TX packets:79 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:283119 (276.4 KiB) TX bytes:10338 (10.0 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:32 errors:0 dropped:0 overruns:0 frame:0 TX packets:32 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:1858 (1.8 KiB) TX bytes:1858 (1.8 KiB) 

接口configuration

 # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback auto eth0 allow-hotplug eth0 iface eth0 inet static address 172.16.0.2 netmask 255.255.255.0 gateway 172.16.0.1 network 172.16.0.0 broadcast 172.16.0.255 auto eth1 allow-hotplug eth1 iface eth1 inet static address 172.16.1.2 netmask 255.255.255.0 gateway 172.16.1.1 network 172.16.1.0 broadcast 172.16.1.255 auto eth2 allow-hotplug eth2 iface eth2 inet static address 172.16.2.1 netmask 255.255.255.0 network 172.16.2.0 broadcast 172.16.2.255 

ETH0

这是我的主要WAN连接。

ETH1

这是我的辅助WAN连接。

ETH2

这是我的内部LAN连接。

我能够使路由在一个WAN接口上工作,并链接到内部局域网,但是,我无法复制,并且不知道为什么。

在几位朋友的帮助下,我帮助我研究了这个问题,最后我终于find了工作。

必须运行此脚本才能正确转发TCP / IP通信:

 #!/bin/sh PATH=/usr/sbin:/sbin:/bin:/usr/bin # Primary Connection - 2085426230 IF1=eth0 IP1=172.16.0.2 P1=172.16.0.1 P1_NET=172.16.0.0 # Secondary Connection - 2085420213 IF2=eth1 IP2=172.16.1.2 P2=172.16.1.1 P2_NET=172.16.1.0 # Local Network IF3=eth2 IP3=172.16.2.2 P3=172.16.2.1 P3_NET=172.16.2.0 T1=WAN1 T2=WAN2 # delete all existing rules. iptables -F iptables -t nat -F iptables -t mangle -F iptables -X # Always accept loopback and WAN traffic iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -i ${IF1} -j ACCEPT # Allow established connections, and those not coming from the outside iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A FORWARD -i ${IF1} -o ${IF3} -m state --state ESTABLISHED,RELATED -j ACCEPT # Allow outgoing connections from the LAN side. iptables -A FORWARD -i ${IF3} -o ${IF1} -j ACCEPT # Masquerade. iptables -t nat -A POSTROUTING -o ${IF1} -j MASQUERADE # Enable routing. echo 1 > /proc/sys/net/ipv4/ip_forward 

然后我安装了Net-ISP-Balance 。 一旦脚本运行和安装,我去了WhatsMyIP两次,果然,两个接口的路由stream量为whatsmyip显示两个IP地址后,我刷新。

免责声明这适用于我特定的networking布局,configuration和设置。 你的结果可能有所不同