带有source选项的ip route命令

时间:2014-11-07 03:39:50

标签: linux networking

我的系统上有多个接口,可以满足不同的子网需求。我也有一个伪接口 这是用于隧道传输数据包的p-to-p驱动程序。我试图使用ip route命令添加路由 在隧道接口上发送数据包时,使用特定接口的源IP。

在这个例子中,我想使用发送数据包时在eth1.100上设置的11.11.11.1源IP 通过隧道到达60.60.60.1。这就是我的路线表的样子。

   /tmp # ip route show
   60.60.60.1 dev tsgw  scope link  src 11.11.11.1  >> Added this route.
   11.11.11.0/24 dev eth1.100  proto kernel  scope link  src 11.11.11.1
   default via 192.168.1.254 dev eth1.4094  metric 10
   192.168.1.0/24 dev eth1.4094  proto kernel  scope link  src 192.168.1.3 

如果我ping 60.60.60.1,它仍会选择我的接口,通过该接口编程默认路由。

PING 60.60.60.1 (60.60.60.1): 56 data bytes
19:35:32.848428 IP 192.168.1.3 > 60.60.60.1: ICMP echo request, id 16986, seq 0, length 64
19:35:33.848621 IP 192.168.1.3 > 60.60.60.1: ICMP echo request, id 16986, seq 1, length 64
19:35:34.848819 IP 192.168.1.3 > 60.60.60.1: ICMP echo request, id 16986, seq 2, length 64

我在设置源代码时遇到了什么问题?什么是正确的方法来解决这个问题?基本上 我希望发送所有采用tsgw接口的数据包使用特定的私有源IP。

eth1.100  Link encap:Ethernet  HWaddr 00:0B:86:B8:91:10
          inet addr:11.11.11.1  Bcast:11.11.11.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1602  Metric:1
          RX packets:560 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:97395 (95.1 KiB)  TX bytes:704 (704.0 B)


tsgw      Link encap:Point-Point Protocol  
          inet addr:127.0.0.2  P-t-P:127.0.0.2  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:960  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6240 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:1121650 (1.0 MiB)

1 个答案:

答案 0 :(得分:0)

您应该将源接口ping为eth1.100

ping 60.60.60.1 -I eth1.100

相关问题