问题描述

本博客的Debian10最近在做了一次软件包的更新后出现了每隔24小时断网的情况。

sudo apt update && sudo apt upgrade -y

问题分析

1、使用命令重启网卡报错,无法重启网络。

systemctl restart networking.service

错误提示:

Job for networking.service failed because the control process exited with error code.

See “systemctl status networking.service” and “journalctl -xe” for details.

347-4.png

2、查看syslog日志,分析得知应该是eth0网卡不存在导致

ifup[74186]: ifup: failed to bring up eth0
systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: networking.service: Failed with result 'exit-code'.
systemd[1]: Failed to start Raise network interfaces.
systemd[1]: Starting Raise network interfaces...
dhclient[74252]: Internet Systems Consortium DHCP Client 4.4.1
ifup[74258]: Cannot find device "eth0"
dhclient[74252]: Failed to get interface index: No such device
ifup[74252]: Failed to get interface index: No such device
dhclient[74252]: exiting.

347-1.png

解决方法

1、使用查看网络配置文件,看到这里配置了eth0网卡,又因为source原因会加载Interfaces.d文件夹下的配置文件(默认是setup)

vi /etc/network/interfaces

347-2.png

347-3.png

2、在auto eth0和iface eth0 inet dhcp前加#注释掉即可。也可以直接注释掉#source /etc/netwrok/interface.d/*

347-5.png

3、最后interfaces配置文件如下

auto lo
iface lo inet loopback

auto enp4s3
allow-hotplug enp4s3
iface enp4s3 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 223.6.6.6 8.8.8.8

至此获取动态IP时断网问题解决。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。