![编辑](https://linux22.com/image/635448/%E7%BC%96%E8%BE%91.png)
我有一个 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
第二节中删除声明来自行解决(我已经这样做了)或直接ifdown
致电ifup
(其行为并没有什么不同)。
我该如何阻止该错误发生?它不会阻止任何工作,但仍然...
编辑
按照@bodhi.zazen 的建议进行更改后发布我的新配置:
# 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 已配置
答案1
您正在使用较旧的(遗留的)语法。
新的语法更加简单:
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 答案:文件存在...”错误是非特定的。
其他解决方案:
编辑/etc/udev/rules.d/70-persistent-net.rules
并删除引用 eth0 的条目