Ubuntu 无法在 IP 多接口上分配静态(RTNETLINK 答案:文件存在)

Ubuntu 无法在 IP 多接口上分配静态(RTNETLINK 答案:文件存在)

我已经在计算机上安装了 Ubuntu 16.04 服务器版本。我有 4 个以太网接口,我想为所有接口分配静态 IP。

我已经阅读了一些问题和答案并应用了它们,例如从 eno2-3-4 中删除网关,因为它在 eno1 上可用,但没有运气

我的配置如下所示;

# The primary network interface
auto eno1
iface eno1 inet static
address 10.***.***.174
netmask 255.255.255.0
gateway 10.***.***.1
dns-nameservers 208.67.220.220 208.67.222.222

# The secondary network interface
auto eno2
iface eno2 inet static
address 10.***.***.175
netmask 255.255.255.0
dns-nameservers 208.67.220.220 208.67.222.222

# The tertiary network interface
auto eno3
iface eno3 inet static
address 10.***.***.176
netmask 255.255.255.0
dns-nameservers 208.67.220.220 208.67.222.222

# The quaternary network interface
auto eno4
iface eno4 inet static
address 10.***.***.177
netmask 255.255.255.0
dns-nameservers 208.67.220.220 208.67.222.222

当我检查错误日志时,出现以下错误

RTNETLINK answers: File exists
Failed to bring up eno1.
RTNETLINK answers: File exists
Failed to bring up eno2.
RTNETLINK answers: File exists
Failed to bring up eno3.

我尝试刷新 IP 地址和设备,尝试重启机器,但仍然没有成功。当我尝试时,systemctl restart (or start) networking.service我得到了上述错误。

我还需要更新其他文件吗?

答案1

我偶然发现了解决方案。有趣的是,我改变了缩进到下面,服务立即启动,没有任何错误..

# The primary network interface
auto eno1
iface eno1 inet static
    address 10.***.***.174
    netmask 255.255.255.0
    gateway 10.***.***.1
    dns-nameservers 208.67.220.220 208.67.222.222

# The secondary network interface
auto eno2
iface eno2 inet static
    address 10.***.***.175
    netmask 255.255.255.0
    dns-nameservers 208.67.220.220 208.67.222.222

# The tertiary network interface
auto eno3
iface eno3 inet static
    address 10.***.***.176
    netmask 255.255.255.0
    dns-nameservers 208.67.220.220 208.67.222.222

# The quaternary network interface
auto eno4
iface eno4 inet static
    address 10.***.***.177
    netmask 255.255.255.0
    dns-nameservers 208.67.220.220 208.67.222.222

相关内容