尝试配置eth0和eth1但无法启动eth1
尝试在Ubuntu 12.04上进行以下操作。
尝试配置eth0和eth1,eth0工作正常,但未能带来eth1。
以下是设置/etc/network/interfaces
:
auto eth0 eth1 iface eth0 inet static address 172.19.20.186 netmask 255.255.255.252 network 172.19.20.184 broadcast 172.19.20.187 gateway 172.19.20.185 iface eth1 inet static address 172.18.182.55 netmask 255.255.254.0 gateway 172.18.182.1 up route add -net 172.19.26.0/23 gw 172.19.20.185 dev eth0 up route add -net 172.19.24.0/23 gw 172.19.20.185 dev eth0 up route add default gw 172.18.182.1 dev eth1
当/etc/init.d/networking restart
完成后,给出以下错误:
$ /etc/init.d/networking restart RTNETLINK answers: File exists Failed to bring up eth1
即使ifdown eth1
和ifup eth1
给出上述错误。
任何人都可以帮忙解决这个问题吗?
我想你只需要一个默认网关。 您已设置3: gateway 172.19.20.185
, gateway 172.18.182.1
和up route add default gw 172.18.182.1 dev eth1
。
尝试以下interfaces文件:
auto eth0 eth1 iface eth0 inet static address 172.19.20.186 netmask 255.255.255.252 iface eth1 inet static address 172.18.182.55 netmask 255.255.254.0 gateway 172.18.182.1 up route add -net 172.19.26.0/23 gw 172.19.20.185 dev eth0 up route add -net 172.19.24.0/23 gw 172.19.20.185 dev eth0
编辑 :尝试这个手动配置接口,所以我们可以看到错误在哪里。
- 关闭所有接口:
ifconfig eth0 down; ifconfig eth1 down; ifconfig eth2 down; ifconfig eth3 down
ifconfig eth0 down; ifconfig eth1 down; ifconfig eth2 down; ifconfig eth3 down
- 配置eth0:
ifconfig eth0 172.19.20.186 netmask 255.255.255.252 up
- 配置eth1:
ifconfig eth1 172.18.182.55 netmask 255.255.254.0 up
- 设置默认网关:
route add default gw 172.18.182.1
- 设置第一个静态路由:
route add -net 172.19.26.0/23 gw 172.19.20.185 dev eth0
- 设置第二个静态路由:
route add -net 172.19.24.0/23 gw 172.19.20.185 dev eth0
有时在启动界面之前刷新界面的工作原理:
ip addr flush dev enp2s0
很可能你的NetworkManager与/ etc / network / interfaces冲突。 我不确定dhcp的情况,但是如果你使用NetworkManager GUI设置了静态IP,那么这些接口就会在两个不同的地方定义,因此会产生冲突。
尝试使用以下命令禁用网络管理器。
exec sudo -i systemctl stop NetworkManager.service systemctl disable NetworkManager.service mv /lib/systemd/system/NetworkManager.service NetworkManager.service.res
您可以再次启用您的网络管理员
exec sudo -i mv /lib/systemd/system/NetworkManager.service.res NetworkManager.service systemctl enable NetworkManager.service systemctl start NetworkManager.service
之后,/ etc / network / interfaces中的配置将在重新启动时进行。