无网络:无法启动 eth0

无网络:无法启动 eth0

网络服务启动失败/重启后无法启动。

Restarting networking (via systemctl): networking.serviceJob for networking.service failed because the control process exited with error code.

我仍然可以通过远程控制台访问服务器,但无法进行其他操作,因为没有网络,就没有出路。

systemctl status networking.service 说:

● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor prese
t: enabled)
  Drop-In: /run/systemd/generator/networking.service.d
           └─50-insserv.conf-$network.conf
   Active: failed (Result: exit-code) since Mo 2016-04-18 06:53:11 UTC; 43s ago
     Docs: man:interfaces(5)
  Process: 3551 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=
1/FAILURE)
  Process: 3546 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [
 -n "$(ifquery --read-environment --list --exclude=lo)" ] && udevadm settle (cod
e=exited, status=0/SUCCESS)
 Main PID: 3551 (code=exited, status=1/FAILURE)

Apr 18 06:53:11 h2502988.stratoserver.net ifup[3551]: For info, please visit htt
ps://www.isc.org/software/dhcp/
Apr 18 06:53:11 h2502988.stratoserver.net ifup[3551]: Usage: dhclient [-4|-6] [-
SNTP1dvrx] [-nw] [-p <port>] [-D LL|LLT]
Apr 18 06:53:11 h2502988.stratoserver.net ifup[3551]:                 [-s server
-addr] [-cf config-file] [-lf lease-file]
Apr 18 06:53:11 h2502988.stratoserver.net ifup[3551]:                 [-pf pid-f
ile] [--no-pid] [-e VAR=val]
Apr 18 06:53:11 h2502988.stratoserver.net ifup[3551]:                 [-sf scrip
t-file] [interface]
Apr 18 06:53:11 h2502988.stratoserver.net ifup[3551]: Failed to bring up eth0.
Apr 18 06:53:11 h2502988.stratoserver.net systemd[1]: networking.service: Main p
rocess exited, code=exited, status=1/FAILURE
Apr 18 06:53:11 h2502988.stratoserver.net systemd[1]: Failed to start Raise netw
ork interfaces.
Apr 18 06:53:11 h2502988.stratoserver.net systemd[1]: networking.service: Unit e
ntered failed state.
Apr 18 06:53:11 h2502988.stratoserver.net systemd[1]: networking.service: Failed
 with result 'exit-code'.

我的 /etc/network/interfaces 如下所示:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

我应该从哪里开始调试?

感谢您的提示!问候,K

# sudo 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  
Internet Systems Consortium DHCP Client 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Usage: dhclient <snip>
Failed to bring up eth0.

答案1

我刚刚遇到了这种情况。原因是软件包依赖关系不一致,导致我从 trusty 升级到 xenial 时出现问题,因此某些软件包版本不一致。就我而言,不一致是由 squid3 和 ca-certificates-java 引起的。

我通过运行 恢复了网络连接dhclient eth0。通过删除有问题的软件包并运行 解决了软件包不一致问题后apt-get install -f,我运行apt-get dist-upgradeapt-get install ubuntu-standard。这完全解决了我的问题。

让我怀疑不一致的原因是/sbin/ifup二进制文件包含过时的dhclient命令行和不再支持的-I选项。这一定是软件包版本不一致。

答案2

我假设您刚刚安装/升级到较新的操作系统,例如 Ubuntu 16.04,并且由于脱离了传统的界面命名方案(例如eth0eth1),系统无法启动您的界面。

尝试编辑您的/etc/network/interfaces以使用ens32ens192代替eth0类似

# The loopback network interface
auto lo
iface lo inet loopback

# The Ethernet interface
auto ens192
iface ens192 inet dhcp

这应该可以让你重启网络接口。希望对你有帮助。有关预测网络接口更改的详细信息

https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

答案3

不确定这是否仍然有用:dhclient 似乎不再具有“-I”或“-df”选项,根据手册页是否进行 DDNS:

-I 使用来自 RFC 4701 和 4702 的标准 DDNS 方案。

一旦我从命令行删除该选项,dhclient 就能够启动 eth0。

[编辑]:现在如果我能找到“-I”选项在哪里......

答案4

尝试这个:-

sudo ifdown --exclude=lo -a && sudo ifup --exclude=lo -a

因此替换networking restartifdown... && ifup....

顺便说一句:ifconfig也已经被弃用很长时间了 -ip从包中使用iproute2

你也可以尝试

ifconfig eth0 down && ifconfig eth0 up

(或者不管你的网络接口叫什么)来重新启动网络。

相关内容