Ubuntu 上的“ip route get”返回默认路由而不是静态路由

Ubuntu 上的“ip route get”返回默认路由而不是静态路由

几天来,我们一直在尝试解决这个看似简单的路由问题。我们正尝试通过 OpenVPN 隧道路由流量。具体来说,到 10.0.1.136 的流量应通过我们的隧道接口路由。因此,我们通过 ip route 添加了路由“10.0.1.0/24 via 10.0.2.1 dev tun0 metric 101”。但是,如下所示,如果我们执行“ip route get 10.0.1.136”,则会选择 eth0 接口。

我们已经尝试过:

  • 删除缓存
  • 删除默认路由
  • 专门为 10.0.1.136 添加路由
  • 将路由设为“静态”

我们遗漏了什么?我们的路由表中是否存在任何明显问题?

xx@xx:~$ ip route
default via 192.168.10.150 dev eth0 
10.0.0.2 via 10.0.2.1 dev tun0  metric 101 
10.0.1.0/24 via 10.0.2.1 dev tun0  metric 101 
10.0.2.0/24 dev tun0  proto kernel  scope link  src 10.0.2.50 
169.254.0.0/16 dev eth0  scope link  metric 1000 
172.16.0.0/16 via 172.16.0.100 dev tap0 
192.168.10.0/24 dev eth0  proto kernel  scope link  src 192.168.10.100 
192.168.20.0/24 via 192.168.10.1 dev eth0 

xx@x:~$ sudo ip route get 10.0.1.136
10.0.1.136 via 192.168.10.150 dev eth0  src 192.168.10.100 
    cache 

xx@xx:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 44:8a:5b:57:a7:68  
          inet addr:192.168.10.100  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::468a:5bff:fe57:a768/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:711182 errors:0 dropped:237 overruns:0 frame:0
          TX packets:715366 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:88619834 (88.6 MB)  TX bytes:86802607 (86.8 MB)

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:12623 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12623 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1388042 (1.3 MB)  TX bytes:1388042 (1.3 MB)

tap0      Link encap:Ethernet  HWaddr 16:20:92:30:1c:9d  
          inet addr:172.16.0.100  Bcast:172.16.0.255  Mask:255.255.255.0
          inet6 addr: fe80::1420:92ff:fe30:1c9d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4759 errors:0 dropped:183 overruns:0 frame:0
          TX packets:6654 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:497307 (497.3 KB)  TX bytes:469035 (469.0 KB)

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:10.0.2.50  P-t-P:10.0.2.50  Mask:255.255.255.0
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:264830 errors:0 dropped:0 overruns:0 frame:0
          TX packets:259659 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:21013005 (21.0 MB)  TX bytes:23064408 (23.0 MB)

相关内容