Jer*_*ers 8 networking linux routing opensuse multi-homed
抽象的:
在我现有的网络设置中添加辅助 ISP 时,我有(我认为是路由)问题:传入流量Router1没有得到答复,但本地流量和传入流量Router0工作正常。
我怎样才能让当前运行良好的部件正常工作,同时通过Router1工作来获取流量?
细化:
我在下面绘制了一张图表,其中包含了基本情况(实际上,每个 LAN 上都有更多设备,但它们无关紧要)。
情况是这样的:
LAN0is192.168.x.0/24和LAN1is 192.168.y.0/24。两者都适用于内部流量(例如使用cURL 的http)。LAN0一直通过Router0并连接ISP0到Internet.LAN1一直都有Router1,但现在连接ISP1到了Internet。LAN0并具有默认路由,Router0可以很好地处理传出和传入流量。LAN1并具有默认路由,Router1可以很好地处理传出和传入流量。LAN0,并LAN1一直工作得很好。Router1for 的传入流量WindowsB正确到达:我可以通过 RDP 从WindowsC.Router1forLinuxB到达(根据tcpdump),但没有像curl http://e.f.g.hfronLinuxC显示的那样回复,并在 LinuxB显示中显示tcpdump:它仅显示 - 根据tcpdump 输出格式- 设置了SYN标志的数据包:
LinuxB:/tmp/LinuxB.eth1.80 # tcpdump -i eth1 'port 80'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
13:35:19.489779 IP i.j.k.l.57512 > 192.168.y.2.http: Flags [S], seq 816356596, win 65535, options [mss 1460,nop,wscale 4,nop,nop,TS val 1287047182 ecr 0,sackOK,eol], length 0
13:35:19.788841 IP i.j.k.l.57512 > 192.168.y.2.http: Flags [S], seq 816356596, win 65535, options [mss 1460,nop,wscale 4,nop,nop,TS val 1287047478 ecr 0,sackOK,eol], length 0
13:35:19.888835 IP i.j.k.l.57512 > 192.168.y.2.http: Flags [S], seq 816356596, win 65535, options [mss 1460,nop,wscale 4,nop,nop,TS val 1287047578 ecr 0,sackOK,eol], length 0
13:35:19.989412 IP i.j.k.l.57512 > 192.168.y.2.http: Flags [S], seq 816356596, win 65535, options [mss 1460,nop,wscale 4,nop,nop,TS val 1287047678 ecr 0,sackOK,eol], length 0
13:35:20.089685 IP i.j.k.l.57512 > 192.168.y.2.http: Flags [S], seq 816356596, win 65535, options [mss 1460,nop,wscale 4,nop,nop,TS val 1287047778 ecr 0,sackOK,eol], length 0
13:35:20.190836 IP i.j.k.l.57512 > 192.168.y.2.http: Flags [S], seq 816356596, win 65535, options [mss 1460,nop,wscale 4,nop,nop,TS val 1287047877 ecr 0,sackOK,eol], length 0
13:35:20.392123 IP i.j.k.l.57512 > 192.168.y.2.http: Flags [S], seq 816356596, win 65535, options [mss 1460,nop,wscale 4,nop,nop,TS val 1287048072 ecr 0,sackOK,eol], length 0
13:35:20.693692 IP i.j.k.l.57512 > 192.168.y.2.http: Flags [S], seq 816356596, win 65535, options [mss 1460,sackOK,eol], length 0
13:35:21.197162 IP i.j.k.l.57512 > 192.168.y.2.http: Flags [S], seq 816356596, win 65535, options [mss 1460,sackOK,eol], length 0
13:35:22.204134 IP i.j.k.l.57512 > 192.168.y.2.http: Flags [S], seq 816356596, win 65535, options [mss 1460,sackOK,eol], length 0
13:35:24.115961 IP i.j.k.l.57512 > 192.168.y.2.http: Flags [S], seq 816356596, win 65535, options [mss 1460,sackOK,eol], length 0
13:35:27.852374 IP i.j.k.l.57512 > 192.168.y.2.http: Flags [S], seq 816356596, win 65535, options [mss 1460,sackOK,eol], length 0
13:35:31.967049 IP i.j.k.l.57512 > 192.168.y.2.http: Flags [S], seq 816356596, win 65535, options [mss 1460,sackOK,eol], length 0
Run Code Online (Sandbox Code Playgroud)
这是LinuxB路由表:
LinuxB:/tmp/LinuxB.eth1.80 # route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.x.1 0.0.0.0 UG 0 0 0 eth0
loopback * 255.0.0.0 U 0 0 0 lo
link-local * 255.255.0.0 U 0 0 0 eth0
192.168.x.0 * 255.255.255.0 U 0 0 0 eth0
192.168.x.0 * 255.255.255.0 U 0 0 0 eth1
Run Code Online (Sandbox Code Playgroud)
由于通过 RDP from WindowsCto连接WindowsB工作正常,我认为这确实是一个路由问题。这是WindowsB路由表:
C:\temp>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 0c 29 35 77 e1 ...... AMD PCNET Family PCI Ethernet Adapter - Packet Scheduler Miniport
0x3 ...00 0c 29 35 77 eb ...... VMware Accelerated AMD PCNet Adapter - Packet Scheduler Miniport
===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.x.1 192.168.x.4 10
0.0.0.0 0.0.0.0 192.168.y.1 192.168.y.4 5
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.x.0 255.255.255.0 192.168.x.4 192.168.x.4 10
192.168.x.4 255.255.255.255 127.0.0.1 127.0.0.1 10
192.168.x.255 255.255.255.255 192.168.x.4 192.168.x.4 10
192.168.y.0 255.255.255.0 192.168.y.4 192.168.y.4 10
192.168.y.4 255.255.255.255 127.0.0.1 127.0.0.1 10
192.168.y.255 255.255.255.255 192.168.y.4 192.168.y.4 10
224.0.0.0 240.0.0.0 192.168.x.4 192.168.x.4 10
224.0.0.0 240.0.0.0 192.168.y.4 192.168.y.4 10
255.255.255.255 255.255.255.255 192.168.x.4 192.168.x.4 1
255.255.255.255 255.255.255.255 192.168.y.4 192.168.y.4 1
Default Gateway: 192.168.y.1
===========================================================================
Persistent Routes:
Network Address Netmask Gateway Address Metric
0.0.0.0 0.0.0.0 192.168.y.1 5
0.0.0.0 0.0.0.0 192.168.x.1 10
Run Code Online (Sandbox Code Playgroud)
那么我怎样才能让路由LinuxB变成这样:
LinuxB,192.168.x.1以便传出流量继续使用Router0/ISP0LAN0于的传入请求LAN0LAN1于的传入请求LAN1Router0( a.b.c.d/ 192.168.x.1) 通过继续回答传入请求192.168.x.1Router1( e.f.g.h/ 192.168.y.1) 通过192.168.y.1Router1故障转移或负载平衡Router0后记:
下面的PNG 图像是通过免费的在线PlantUML引擎在UML文本上生成的。如果您想查看原始 UML 文本,请将PNG 图像链接粘贴到此PlantUML 表单中,然后按。Submit
很久以前我就有一个 shell 脚本来做类似的事情,但是抱歉,我能找到它。所以我只能给大家提供一下我当时实施的解决方案。我主要是凭记忆写的,所以缺少一些例子:
我的每个上行链路有一个路由表(ip 路由...表 101、ip 路由...表 102)。这会进入 /etc/iproute2/rt_tables。
101 ISP1 102 ISP2
您还需要设置这些表:
ip 路由通过 $Gateway1 dev $Interface1 表 isp1 添加默认值 ip 路由通过 $Gateway2 dev $Interface2 表 isp2 添加默认值
#不要忘记默认表:
ip 路由通过 $DefaultGateway dev $DefaultInterface 添加默认值
启用 iptables 连接跟踪 (modprobe nf_conntrack)
设置 ip 规则,确保通过接口流出的流量使用正确的路由表
从 $Ip1 表 isp1 添加 ip 规则 从 $Ip2 表 isp2 添加 ip 规则
设置一条 ip 规则(ip 规则添加...),声明“标记为 0x201 的数据包应查找路由表 201”,每个上行链路一条规则。
一切就绪后,您应该能够接收和发起与任何 WAN 上行链路的连接,甚至平衡传出连接。
这些就是基础知识。iptables +“ip 路由”+“ip 规则”就可以了。
| 归档时间: |
|
| 查看次数: |
432 次 |
| 最近记录: |