eth0,eth0: ERROR while getting interface flags: No such device

本文解决Ubuntu系统中因网卡变化导致的网络配置问题,通过修改配置文件和重启服务实现网络正常连接。
eth0: ERROR while getting interface flags: No such device 


打开ubuntu里的网络设置
vi /etc/network/interfaces
配置如下:


综合网上的资料和自己遇到的问题整理的资料


auto eth0
iface eth0 inet dhcp
重启网络设备:


/etc/init.d/networking restart
会报下面的错误


SIOCSIFADDR: No such device
eth0: ERROR while getting interface flags: No such device
eth0: ERROR while getting interface flags: No such device
Bind socket to interface: No such device
Failed to bring up eth0.


用ifconfig -a,没发现eth0


rm /etc/udev/rules.d/70-persistent-net.rules
删除网络配置缓存文件,重启机器就可以了。
注意:此方法经验证重启network服务不行。如果不想重启机器可以使用重命名ifcfg-eth0文件的方法。




这是因为(Ubuntu)系统有了新网卡(eth4),而保存网卡mac地址和设备名的配置文件在/etc/udev/rules.d/70-persistent-net.rules,网卡的网络配置保存在 /etc/network/interfaces,该配置文件中保存的是eth0的配置信息。在移动/删除rules文件后,重启Ubuntu系统,会自动重新创建新的rules文件,将新网卡辨认为eth0,可用新配置的eth0的网络配置信息。
 
        # sudo mv /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules_bak


       或者:


        #sudo rm /etc/udev/rules.d/70-persistent-net.rules


        再重新启动(Ubuntu)系统,在命令端输入:ping www.baidu.com,可得到预期的结果。



将网卡名eno16777736改为eth0
使用命令 #ifconfig
发现网卡名称是eno16777736,而没有eth0,这是新的网络文件命名方法,我想把他改回原先的eth0。
方法:
vim /etc/sysconfig/grub
在GRUB_CMDLINE_LINUX 的双引号里面的最后
添加“net.ifnames=0 biosdevname=0”内容,如下图所示: 
#grub2-mkconfig -o /boot/grub2/grub.cfg
还有: vi /etc/network/interface添加:
auto eth0
iface eth0 inet dhcp
重启ubuntu



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值