大网数据广告活动
服务器运维问答

"RTNETLINK answers: File exists" /etc/network/interfaces Does'nt contain 2 gateways, so what's wrong?

· 52CE 我爱测

This is my /etc/network/interfaces file contents The only way this is taking effect is when the system reboots. I'm trying to get it effected manually. My attempts below. auto eth0 iface eth0 inet static address 192.168.1.57 netm…

问题原文

原帖链接 · wolfgang · CC BY-SA 3.0

This is my /etc/network/interfaces file contents

The only way this is taking effect is when the system reboots.

I'm trying to get it effected manually. My attempts below.

auto eth0
    iface eth0 inet static
           address 192.168.1.57
           netmask 255.255.255.0
           gateway 192.168.1.1
           up ip addr add 192.168.0.57/24 dev eth0 label eth0:1
           down ip addr del 192.168.0.57/24 dev eth0 label eth0:1
           up ip route add 192.168.0.0/24 via 192.168.0.1 dev eth0:1 metric 20
           down ip route del 192.168.0.0/24 via 192.168.0.1 dev eth0:1 metric 20

First tried to run sudo ifup eth0

and i receive

RTNETLINK answers: File exists
Failed to bring up eth0.

The /etc/network/interfaces only work when i reboot the system

Other than that i've tried

sudo /etc/init.d/networking restart

sudo service network-manager restart

sudo service networking restart

But none of them will bring up the changes in the interfaces file

My only option was sudo ifup eth0 and that gives the above error.

what is wrong?

已采纳解答

原帖链接 · dtoubelis · CC BY-SA 4.0

Edit your configuration file to remove the indentation before the iface stanza so that it looks like this,

auto eth0
iface eth0 inet static
   address 192.168.1.57
   netmask 255.255.255.0
   gateway 192.168.1.1
   up ip addr add 192.168.0.57/24 dev eth0 label eth0:1
   down ip addr del 192.168.0.57/24 dev eth0 label eth0:1
   up ip route add 192.168.0.0/24 via 192.168.0.1 dev eth0:1 metric 20
   down ip route del 192.168.0.0/24 via 192.168.0.1 dev eth0:1 metric 20

The message you receive is just indication that the interface is already up, so you need to do ifdown before you do ifup. However, you need to be careful if you are connecting via ssh - you may lock yourself out. This is a way to do it:

sudo ifdown eth0 && sudo ifup eth0

Note, how these two commands are executed on the same line. And just a precaution, make sure you can access the server console or able to reboot the server if something goes wrong.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-09-22)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。