添加第二个IP到服务器

我有一个将托pipe多个域的Debian 7框。 我试图添加第二个IP,但每次我尝试/etc/init.d/network stop && /etc/init.d/network start ,我得到这个错误:

 RTNETLINK answers: File exists Failed to bring up eth0:0 

但是,新的IP仍然有效 – 我可以在浏览器中访问服务器。

这是我的接口文件:

 allow-hotplug eth0 iface eth0 inet static address 111.222.26.38 netmask 255.255.255.0 network 111.222.26.0 broadcast 111.222.26.255 gateway 111.222.26.1 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 1.2.3.4 1.2.3.5 1.2.3.6 dns-search my.tld auto eth0:0 iface eth0:0 inet static address 111.222.26.165 netmask 255.255.255.0 

我的路由表route -n

 Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 111.222.26.1 0.0.0.0 UG 0 0 0 eth0 111.222.26.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 

在Google上发布的类似问题中,大约有100%的问题是通过从第二节(我已经完成的)中删除gateway声明,或者通过简单地调用ifdownifup (其行为不同)来解决问题

我如何阻止这种错误发生? 这不是阻止任何工作,但仍然…

编辑

根据@ bodhi.zazen的build议进行更改后发布我的新configuration:

 # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 allow-hotplug eth0 iface eth0 inet static address 111.222.26.38 netmask 255.255.255.0 network 111.222.26.0 broadcast 111.222.26.255 gateway 111.222.26.1 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 111.222.3.119 111.222.3.117 111.222.5.233 dns-search my.tld iface eth0 inet static address 111.222.26.165 netmask 255.255.255.0 

重新启动盒子后,我得到的错误是:ifup:接口eth0已经configuration

您正在使用较旧的(遗留)语法。

新的语法非常简单:

 auto eth0 allow-hotplug eth0 iface eth0 inet static address 111.222.26.38 netmask 255.255.255.0 network 111.222.26.0 broadcast 111.222.26.255 gateway 111.222.26.1 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 1.2.3.4 1.2.3.5 1.2.3.6 dns-search my.tld iface eth0 inet static address 111.222.26.165 netmask 255.255.255.0 

请参阅 – https://wiki.debian.org/NetworkConfiguration#iproute2_method

此外,错误“RTNETLINK答案:文件存在…”错误是非特定的。

其他解决scheme

编辑/etc/udev/rules.d/70-persistent-net.rules并删除引用eth0的条目

有关详细信息,请参阅https://superuser.com/questions/618390/rtnetlink-answers-file-exists-maybe-because-assigned-a-new-mac-adress

另见http://www.linuxquestions.org/questions/linux-networking-3/rtnetlink-answers-file-exists-error-when-doing-ifup-on-alias-eth1-1-on-rhel5-710766/