找不到设备eth0

我是ubuntu的新手,需要安装ubuntu xenial服务器(16.04)版本才能将MongoDB安装到VirtualBox中。 安装后我尝试从dhcp更改为静态ipv4地址。 所以我改变了/ etc / network / interfaces:

auto lo iface lo inet loopback allow-hotplug eth0 iface eth0 inet static address 192.168.56.5 netmask 255.255.255.0 gateway 192.168.56.1 

并重新启动服务器

 # but ifconfig -a shows only an enp0s3 interface without any IP address and lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host up loopback running MTU: ... 

(抱歉复制和粘贴不起作用所以我必须输入所有)

 did a reboot once more and tried sudo ifdown and afterwards ifup eth0 # but it gives allways : Cannot find device "eth0" Failed to bring up eth0 

VirtualBox网络适配器设置为仅主机适配器,我已经在192,168.56.4上使用Debian8运行另一个VirtualBox。

有没有人帮我?

您的网络接口是enp0s3 。 用此接口替换eth0条目。

改变自:

汽车公司
 iface lo inet loopback

 allow-hotplug eth0
 iface eth0 inet static
  地址192.168.56.5
  网络掩码255.255.255.0
  网关192.168.56.1

改成:

汽车公司
 iface lo inet loopback

 allow-hotplug enp0s3
 iface enp0s3 inet static
  地址192.168.56.5
  网络掩码255.255.255.0
  网关192.168.56.1

您可以通过以下命令找到网络设备逻辑名称:

 sudo lshw -C network 

就我而言,我的逻辑网络设备名称是enp3s0。 所以我将设备名称从eth0替换为enp3s0并且它可以工作。