如何设置networking接口eth0作为DHCP和eth0:1作为静态IP?

我试图configuration我的networking同时具有静态IP和DHCP IP

有问题的系统是Ubuntu服务器11.10只有附加的软件是LAMP包(networking服务器)和OpenSSH。

我尝试了下面这个configuration,取得了不错的成绩。 有时我只能得到DHCP IP,而不是静态IP,有时我只能得到静态IP而不是DCHP。

我的configuration有问题吗?


汽车
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth0:1
iface eth0:1 inet static
地址192.168.0.2
networking掩码255.255.255.0
网关192.168.0.1
广播192.168.0.255

auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp auto eth0:0 iface eth0:0 inet static address 192.168.0.2 netmask 255.255.255.0 

DHCP将获得网关信息。 双网关导致交通停止工作。 由于networking掩码已经假定广播是不必要的。

尝试删除自动eth0:1,并将其与第一个一起添加在这种方式:

 auto eth0 eth0:1 iface eth0 inet dhcp iface eth0:1 inet static address 192.168.0.2 netmask 255.255.255.0 gateway 192.168.0.1 broadcast 192.168.0.255 

指定两次自动为相同的物理iface时,我有问题。