![升级到 16.04 后 ifup 无法启动 eth0](https://linux22.com/image/990030/%E5%8D%87%E7%BA%A7%E5%88%B0%2016.04%20%E5%90%8E%20ifup%20%E6%97%A0%E6%B3%95%E5%90%AF%E5%8A%A8%20eth0.png)
我已将服务器从 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 <port>] [-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 <port>] [-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。但无法解析任何域名。
我该怎么做才能恢复网络连接?
答案1
我在 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
显示我可以上网。
答案2
看起来升级不知怎么搞乱了与网络相关的软件包。我做了以下操作,问题得以解决。但我不确定哪些是必要的。
# 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
答案3
我遇到了同样的问题。@rosencreuz 给出的答案是正确的,但我将范围缩小到仅此一个命令。
# apt install isc-dhcp-client
答案4
如果要继续使用eth0
接口名称,则需要添加
/etc/default/grub
:
net.ifnames=0 biosdevname=0
里面GRUB_CMDLINE_LINUX=""
。像这样:
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0 quiet"
然后运行:update-grub
并重新启动。