debian无法手动重启网卡的解决方法

系统为debian9.9,Linux debian 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u2 (2019-05-13) x86_64 GNU/Linux

最近在使用过程中,发现无法通过命令手动重启网卡,在网络上搜索了很多帖子,都没有解决问题。只能慢慢排查。

首先修改配置文件以后,手动重启网卡,提示如下:

root@debian:~# service networking restart
Job for networking.service failed because the control process exited with error code.
See "systemctl status networking.service" and "journalctl -xe" for details.

根据提示,输入systemctl status networking.service继续排查问题,

root@debian:~# systemctl status networking.service
● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2019-06-13 15:27:41 CST; 2min 22s ago
     Docs: man:interfaces(5)
  Process: 765 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
  Process: 760 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --r
 Main PID: 765 (code=exited, status=1/FAILURE)

Jun 13 15:27:41 debian ifup[765]: than a configuration issue please read the section on submittin
Jun 13 15:27:41 debian ifup[765]: bugs on either our web page at www.isc.org or in the README fil
Jun 13 15:27:41 debian ifup[765]: before submitting a bug.  These pages explain the proper
Jun 13 15:27:41 debian ifup[765]: process and the information we find helpful for debugging..
Jun 13 15:27:41 debian ifup[765]: exiting.
Jun 13 15:27:41 debian ifup[765]: ifup: failed to bring up eth0
Jun 13 15:27:41 debian systemd[1]: networking.service: Main process exited, code=exited, status=1
Jun 13 15:27:41 debian systemd[1]: Failed to start Raise network interfaces.
Jun 13 15:27:41 debian systemd[1]: networking.service: Unit entered failed state.
Jun 13 15:27:41 debian systemd[1]: networking.service: Failed with result 'exit-code'.
lines 1-18/18 (END)

问题出现在这里:

Jun 13 15:27:41 debian ifup[765]: ifup: failed to bring up eth0

通过ifconfig命令,发现机器不存在这个网卡,于是又返回配置文件处寻找线索。注意下图红色箭头处的代码,表示立即执行interfaces.d目录下的所有配置文件。
debian无法手动重启网卡的解决方法_第1张图片
打开interfaces.d目录,只有一个setup文件,打开文件可以看到报错的eth0网卡配置,这就是无法重启网卡的问题所在,两个办法解决,1.注释掉这个不存在的网卡,2.将这个网卡名改成本地网卡名字。
debian无法手动重启网卡的解决方法_第2张图片
成功重启网卡。如下:

root@debian:/etc/network/interfaces.d# service networking restart
root@debian:/etc/network/interfaces.d# 

你可能感兴趣的:(linux)