尝试配置eth0和eth1,但无法启动eth1


14

尝试在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给予上述错误。

谁能帮助解决这个问题?


您可能需要检查两件事:1.可能是ethI而不是eth1的错字。2.可能您没有在虚拟机上添加网络接口

Answers:


15

我认为您只需要一个默认网关。您已经设置了3: gateway 172.19.20.185,gateway 172.18.182.1和up route add default gw 172.18.182.1 dev eth1。

尝试以下接口文件:

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

编辑:尝试手动配置接口,这样我们就可以看到错误在哪里。

  1. 关闭所有接口: ifconfig eth0 down; ifconfig eth1 down; ifconfig eth2 down; ifconfig eth3 down
  2. 配置eth0: ifconfig eth0 172.19.20.186 netmask 255.255.255.252 up
  3. 配置eth1: ifconfig eth1 172.18.182.55 netmask 255.255.254.0 up
  4. 设置默认网关: route add default gw 172.18.182.1
  5. 设置第一条静态路线: route add -net 172.19.26.0/23 gw 172.19.20.185 dev eth0
  6. 设置第二条静态路由: route add -net 172.19.24.0/23 gw 172.19.20.185 dev eth0

感谢您的回复。尝试了您提供的选项,但仍给出相同的错误。eth1是否需要安装任何驱动程序
— Test1234 2013年

是的,eth1也在那里,eth2和eth3也在那里。如果尝试配置eth2和eth3而不是eth1,则会出现相同的错误。下面是ifconfig -a eth1 eth1链接快照:以太网HWaddr 6c:3b:e5:b1:40:4d inet地址:172.18.182.55 Bcast:172.18.183.255掩码:255.255.254.0 inet6地址:fe80 :: 6e3b: e5ff:feb1:404d / 64范围:链接
— Test1234 2013年

ifup和ifdown显示相同的错误... eth2和eth3的ipconfig -a在下面.... eth2链接encap:以太网HWaddr 6c:3b:e5:b1:40:4e广播多播MTU:1500公制:1 ...... eth3 Link encap:以太网HWaddr 6c:3b:e5:b1:40:4f广播多播MTU:1500指标:1 ........重发服务器,但仍然是相同的问题
— Test1234

1
1.关闭所有接口:ifdown eth0 eth1 eth2 eth3对于此步骤,它给出以下错误信息……ifdown:未配置接口eth1 ifdown:未配置接口eth2 ifdown:未配置接口eth3……用于步骤2到步骤6的其他步骤,则没有给出任何错误
— Test1234 2013年

很好...试图连接ip地址,它正在工作,问题已解决...感谢一堆,您采取的措施有助于解决问题
— Test1234 2013年


0

您的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进行配置。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.