引发第二个虚拟networking接口的问题

我遇到问题,添加第二个IP地址到一个接口。 下面是我的/etc/networking/interfaces

  # The loopback network interface auto lo iface lo inet loopback #eth0 is our main IP address auto eth0 iface eth0 inet static address 198.58.103.* netmask 255.255.255.0 gateway 198.58.103.1 #eth0:0 is our private address auto eth0:0 iface eth0:0 inet static address 192.168.129.134 netmask 255.255.128.0 #eth0:1 is for www.site.com auto eth0:1 iface eth0:1 inet static address 198.58.104.* netmask 255.255.255.0 gateway 198.58.104.1 

当我运行/etc/init.d/networking restart ,我得到一个有关启动eth0:1的失败错误eth0:1

 RTNETLINK answers: File exists Failed to bring up eth0:1. 

这是什么原因? 我没有任何问题,我第一次设置eth0eth0:0

编辑:

问题是你有2个默认网关的定义。 你需要删除其中的一个。 我想在eth0:1设备上的那个。

正在尝试添加已经存在的默认路由,正在抛出文件存在错误。


首先,我认为*作为主机号码是一个有效的数字,而不是字面上的“*”?

现在尝试这种方式。 我怀疑启动脚本中的自动行parsing有问题 – 只是一个预感,我没有看过。

 # The loopback network interface auto lo iface lo inet loopback # The primary network interface #eth0 is our main IP address auto eth0 iface eth0 inet static address 198.58.103.* netmask 255.255.255.0 gateway 198.58.103.1 # Put your nameserver address here! dns-nameservers xxxx #eth0:0 is our private address auto eth0:0 iface eth0:0 inet static address 192.168.129.134 netmask 255.255.128.0 #eth0:1 is for www.site.com auto eth0:1 iface eth0:1 inet static address 198.58.104.* netmask 255.255.255.0 # This shouldn't be here! remove it. #gateway 198.58.104.1 

其次,要摆脱恼人的resolv.conf错误运行:

 sudo dpkg-reconfigure resolvconf 

虽然这是一个单独的问题。

试试这个命令:

 sudo dpkg-reconfigure resolvconf 

另外这个:

 ifdown eth0:0 ifdown eth0:1 ifdown eth0 ifup eth0 

最后的ifup eth0同时启动ifup eth0别名,并且只设置一次路由。