升级到16.04后,ifup无法提升eth0

我已将服务器从14.04升级到16.04。 我可以在syslog上看到以下错误:

ifup[478]: Internet Systems Consortium DHCP Client 4.2.4 ifup[478]: Copyright 2004-2012 Internet Systems Consortium. ifup[478]: All rights reserved. ifup[478]: For info, please visit https://www.isc.org/software/dhcp/ ifup[478]: Usage: dhclient [-4|-6] [-SNTP1dvrx] [-nw] [-p ] [-D LL|LLT] ifup[478]: [-s server-addr] [-cf config-file] [-lf lease-file] ifup[478]: [-pf pid-file] [--no-pid] [-e VAR=val] ifup[478]: [-sf script-file] [interface] ifup[478]: Failed to bring up eth0. systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE systemd[1]: Failed to start Raise network interfaces. systemd[1]: networking.service: Unit entered failed state. systemd[1]: networking.service: Failed with result 'exit-code'. 

如果我尝试手动执行此操作,也会出现相同的错误

 # ifup --verbose eth0 Configuring interface eth0=eth0 (inet) /bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d run-parts: executing /etc/network/if-pre-up.d/ethtool run-parts: executing /etc/network/if-pre-up.d/wireless-tools run-parts: executing /etc/network/if-pre-up.d/wpasupplicant /sbin/dhclient -1 -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases -I -df /var/lib/dhcp/dhclient6.eth0.leases eth0 Usage: dhclient [-4|-6] [-SNTP1dvrx] [-nw] [-p ] [-D LL|LLT] [-s server-addr] [-cf config-file] [-lf lease-file] [-pf pid-file] [--no-pid] [-e VAR=val] [-sf script-file] [interface] Failed to bring up eth0. 

我可以ping 8.8.8.8。 但无法解析任何域名。

我该怎么做才能恢复网络连接?

我在Raspberry Pi上全新安装服务器16.04时遇到了这个问题。 出于某种原因,默认情况下没有安装网络管理器,运行dist-upgrade然后重新启动后,我没有网络。

我按照这个博客的步骤重新开始工作。 从本质上讲,eth0的映射已经损坏。 通常,网络管理器可以自动修复此问题,但如果没有它,则必须自己进行修复。 为此,我先跑了:

 sudo networkctl 

它向我展示了我所有的网络接口,如lo,wlan0和一些叫做enc238897s9879c3的东西,它实际上应该是eth0。

为了纠正映射,我跑了:

 sudo ip link set enc238897s9879c3 name eth0 sudo systemctl restart networking 

并修复了它。 运行ifconfig显示我有一个IP,运行ping google.com显示我有互联网。

我遇到了同样的问题。 @rosencreuz给出的答案是正确的,但我把它缩小到这一个命令。

 # apt install isc-dhcp-client 

看起来升级是以某种方式弄乱了网络相关的包。 我做了以下导致解决问题的方法。 我不确定哪些是必要的。

 # apt install network-manager # systemctl enable systemd-networkd # systemctl enable systemd-resolved # systemctl start systemd-networkd # systemctl start systemd-resolved # apt install isc-dhcp-client # dpkg-reconfigure resolvconf 

如果要继续使用eth0作为接口名称,则需要添加/etc/default/grub

 net.ifnames=0 biosdevname=0 

GRUB_CMDLINE_LINUX="" 。 像这样:

 GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0 quiet" 

然后运行: update-grub并重启。