Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
199 views
in Technique[技术] by (71.8m points)

linux 静态路由无效

我在一家云服务器厂商购买了两台服务器,子网互通,称为node1(172.16.0.2)以及node2(172.16.0.5),现在node1跟远程的一台服务器core(192.168.0.91)构建了ipsec隧道,node1已配置了iptables转发,并且全部放开了访问,core可以ping通node2,在node1抓包可以看到

11:40:04.069110 IP 192.168.0.91 > 172.16.0.5: ICMP echo request, id 27358, seq 549, length 64
11:40:04.069251 IP 172.16.0.2 > 172.16.0.5: ICMP echo request, id 27358, seq 549, length 64
11:40:04.069757 IP 172.16.0.5 > 172.16.0.2: ICMP echo reply, id 27358, seq 549, length 64

现在的问题:在node2上面做了静态路由,无法ping通core,在node1抓包看不到任何数据,这个是node2的路由表

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.16.0.1      0.0.0.0         UG    100    0        0 eth0
169.254.169.254 172.16.0.3      255.255.255.255 UGH   100    0        0 eth0
172.16.0.0      0.0.0.0         255.255.240.0   U     100    0        0 eth0
192.168.0.0     172.16.0.2      255.255.255.0   UG    0      0        0 eth0

求解,问题出在哪?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

node1 抓不到任何数据,说明它不能作为 node2 访问 core 的网关。

虽然 node1 与 node2 可以互通,且看起来在同个局域网,但是,它们只是逻辑上同网,以太帧不能在它们之间传输,因此互相不能作为网关设备,那么使用静态路由没用。

建议在 node1 架设 VPN 服务器,node2 与 core 采用 VPN 互联。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...