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

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



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章