Joh*_*ltz 15 networking nat iptables load-balancing linux-networking
好的,...这可能已经得到了回答,不幸的是,我没有找到任何看起来像是解决方案的东西。
我看过这些页面,他们有一些有用的信息,但不是完整的解决方案:
我将使用 Debian 8、Ubuntu 16.04 Desktop 或 Ubuntu 16.04 Server(老实说,很可能是 Debian)。
好的,所以我将安装三个网卡,两个千兆位和板载 100 mbps LAN 连接。ISP 连接将通过两个网卡上的 PPPoE 身份验证使用千兆 LAN 卡(如果这甚至可能,否则我将在 DSL 调制解调器上使用非桥接模式)。两个网络都将分配一个静态 IP。目前(这将改变)主要连接有一组五个。我需要将来自这些 IP 地址之一的流量路由到网络上的正确服务器。
以下是我的问题:
请温柔点,这是我第一次尝试过这样的事情:)。
编辑 1
忘记添加网络拓扑:
编辑 2
刚刚意识到一些事情......为了进行 PPPoE 身份验证,我将不得不强制对特定接口上的凭据进行身份验证。这是怎么做的?
我在这里发布了这个问题:
创建具有两个 Internet 连接和一个 LAN 连接的多宿主 linux 负载平衡器
更新 1
仍然无法让多跳循环工作。我尝试按照以下网站中列出的步骤进行操作,但没有成功:
我要么不断收到一条消息,指出该文件已存在或设备无效。这是/是我的设置/信息
配置文件
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)
Run Code Online (Sandbox Code Playgroud)
接口配置
# 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
Run Code Online (Sandbox Code Playgroud)
以太币
这是我的主要 WAN 连接。
ETH1
这是我的辅助 WAN 连接。
以太坊2
这是我的内部 LAN 连接。
我能够让路由在一个 WAN 接口上工作并链接到内部 LAN,但是,我无法复制它,也不知道为什么。
在几个朋友的帮助下,我帮助我研究了这一点,我终于能够让它发挥作用。
必须运行此脚本才能正确转发 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
Run Code Online (Sandbox Code Playgroud)
然后我安装了Net-ISP-Balance。脚本运行并安装后,我去了两次WhatsMyIP,果然,两个接口都在路由流量,因为在我刷新后 whatsmyip 显示了两个 IP 地址。
免责声明这适用于我的特定网络布局、配置和设置。您的结果可能会有所不同。