RTNETLINK回答:添加ipv6地址后文件存在

RTNETLINK回答:添加ipv6地址后文件存在

我已经在这件事上用头撞墙一段时间了,但没有取得任何进展。

我的系统具有静态分配的 ipv4 和 ipv6 地址。启动后运行systemctl status networking结果如下:

● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
  Drop-In: /run/systemd/generator/networking.service.d
       └─50-insserv.conf-$network.conf
   Active: failed (Result: exit-code) since Sat 2016-08-27 14:48:50 MST; 8min ago
     Docs: man:interfaces(5)
  Process: 3301 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
  Process: 3275 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --exclude=lo)" ] && udevadm settle (code=exited, status=0/SUCCESS)
 Main PID: 3301 (code=exited, status=1/FAILURE)

Aug 27 14:48:25 phoenix systemd[1]: Starting Raise network interfaces...
Aug 27 14:48:28 phoenix ifup[3301]: /sbin/ifup: waiting for lock on /run/network/ifstate.ens160
Aug 27 14:48:50 phoenix ifup[3301]: RTNETLINK answers: File exists
Aug 27 14:48:50 phoenix ifup[3301]: Failed to bring up ens160.
Aug 27 14:48:50 phoenix systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Aug 27 14:48:50 phoenix systemd[1]: Failed to start Raise network interfaces.
Aug 27 14:48:50 phoenix systemd[1]: networking.service: Unit entered failed state.
Aug 27 14:48:50 phoenix systemd[1]: networking.service: Failed with result 'exit-code'.

但界面实际上已启动并正常运行。

如果我运行systemctl restart networking,它会失败。运行ifdown ens160只是说接口没有配置。

如果我用 强制关闭接口,它就会关闭,然后用或ifdown --force ens160恢复。ifup ens160systemctl restart networking

如果我注释掉 ipv6 部分,启动后就没问题了。

这是我的接口文件:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto ens160
iface ens160 inet static
    address XXX.XXX.XXX.3/24
    gateway XXX.XXX.XXX.1
    dns-search example.org
    dns-nameservers ::1 127.0.0.1

# This is an IPv6 interface
iface ens160 inet6 static
    address XXXX:XXXX:XXXX:XXXX::3/64
    gateway XXXX:XXXX:XXXX:XXXX::1

这是在 vmware 集群上安装了普通 Ubuntu 16.04.1 服务器,仅安装了 bind9 和 ssh 服务器。唯一进行的配置更改是正确配置的 bin9 和静态 IP 更改。

我有多个安装在做同样的事情。

我做了很多搜索,但没有找到符合这种情况的内容。我的谷歌能力通常很强,但这次却让我失败了。

我能得到的任何帮助将不胜感激。

答案1

由于它在注释掉网关行时起作用,因此您会遇到不幸的竞争条件:一旦接口的链接建立,Linux 就开始执行邻居发现并接受路由器广告,尽管接口尚未完全配置,但它可以将 IPv6 路由放入路由表中。当脚本稍后尝试添加默认路由时,您会得到

RTNETLINK answers: File exists

要解决此问题,您可以

  • 注释掉网关行(这是推荐的方法,前提是路由在您的网络中正确公布)
  • 或通过以下方式禁用 RA 的接受
    sysctl -w net.ipv6.conf.device.accept_ra=0
    
    (设备是实际设备,defaultall)。

相关内容