在具有多个IP的Ubuntu服务器上设置默认传出IP

我有一个服务器(10.04 LTS)与1个NIC和2个虚拟IP。 我的/ etc / interfaces是:

auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 11.22.176.5 network 11.22.176.0 netmask 255.255.255.192 broadcast 11.22.176.63 gateway 11.22.176.1 auto eth0:0 iface eth0:0 inet static address 11.22.178.30 network 11.22.178.0 netmask 255.255.255.128 broadcast 11.22.178.127 gateway 11.22.178.1 auto eth0:1 iface eth0:1 inet static address 11.22.178.36 network 11.22.178.0 netmask 255.255.255.128 broadcast 11.22.178.127 gateway 11.22.178.1 

我有一个networking脚本,报告它看到的IP。 所以:

 "curl --interface eth0:0 http://server/reportIP" correctly reports "11.22.178.30" "curl --interface eth1:1 http://server/reportIP" correctly reports "11.22.178.36" 

然而

“curl http:// server / reportIP ”报告一个随机IP(来自3个IP地址),而我总是想看到主IP(11.22.176.5)。

那么除非特意通过虚拟接口,否则我如何强制使用默认IP?

编辑:路由的结果-n

 Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 11.22.176.0 0.0.0.0 255.255.255.192 U 0 0 0 eth0 11.22.178.0 0.0.0.0 255.255.255.128 U 0 0 0 eth0 0.0.0.0 11.22.176.1 0.0.0.0 UG 0 0 0 eth0 0.0.0.0 11.22.178.1 0.0.0.0 UG 100 0 0 eth0 0.0.0.0 11.22.178.1 0.0.0.0 UG 100 0 0 eth0 0.0.0.0 11.22.178.1 0.0.0.0 UG 100 0 0 eth0 

我不知道它是如何与多个子接口,但尝试下面:

在/ etc / networking / interfaces中,添加eth0:1代替所需的子接口:

 up route add -net 0.0.0.0/0 gw 11.22.178.1 dev eth0:1 

只是添加一个DEFAULT路线并不完全是我们想要的。 强迫curl脱离特定的IP使用

 --interface 11.22.178.30 

我知道手册它说接口,IP或主机…但只有IP工作。 可能是CURL中的一个错误。

问候