我有多个虚拟eth接口,其中一些具有与默认网关相同的网关。
当我绑定到一个虚拟eth接口的地址没有相同的默认网关作为eth0一切都按预期工作,并使用正确的源地址。 但是,当网关是相同的,为输出数据包select的源地址总是主要的eth0之一。 (在tcpdump中也可以看到)。 我究竟做错了什么?
ubuntu 8.1 / Linux 2.6.27
我假设源地址select应该像这样工作: http : //linux-ip.net/gl/ip-cref/node155.html
例如:(eth0和eth0:2具有相同的网关)
eth0 is 10.81.61.46 mask 255.255.240.0 eth0:1 10.250.50.70 mask 255.255.240.0 eth0:2 10.81.63.31 mask 255.255.240.0 route add default gw 10.81.48.254 dev eth0 ip rule add from 10.250.50.70 table second ip route add default via 10.250.48.254 table second ip rule add from 10.81.63.31 table third ip route add default via 10.81.48.254 table third (adding "src 10.81.63.31" makes no diff) wget --bind-address 10.81.61.46 whatismyip.net... Result OK: 10.81.61.46 wget --bind-address 10.250.50.70 whatismyip.net.. Result OK: 10.250.50.70 wget --bind-address 10.81.63.31 whatismyip.net.. Result Not OK: 10.81.61.46
请尝试通过添加地址
ip addr add 10.250.50.70/20 dev eth0 ip addr add 10.81.63.31/20 dev eth0
现在我在我的服务器上设置相同的configuration,它工作正常:
ip addr add x.20.28.100/24 dev eth0 ip addr add x.20.28.101/24 dev eth0 ip rule add from x.20.28.100 table 100 ip rule add from x.20.28.101 table 101 ip ro add default via x.20.28.1 table 100 ip ro add default via x.20.28.1 table 101 echo -n "RESULT: "; wget --bind-address x.20.28.100 http://www.whatismyip.com/automation/n09230945.asp -q -O - ; echo RESULT: x.20.28.100 echo -n "RESULT: "; wget --bind-address x.20.28.101 http://www.whatismyip.com/automation/n09230945.asp -q -O - ; echo RESULT: x.20.28.101
PS:你也可以试试http://proxy-check.com/
PS2:你有没有NAT?