vm虛擬機找不到網卡(或者因爲遷移、修改配置導致網卡(eth0)丟失

1、以管理員身份啓動vm。

2、在虛擬機裏config -a查看網卡;通常由於修改配置導致網卡名字被修改。

    這種情況,通常網卡配置中已經沒有eth0的配置了。

    可以手動添加:

        cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).


source /etc/network/interfaces.d/*


# The loopback network interface
auto lo
iface lo inet loopback


auto eth0
iface eth0 inet dhcp 
#iface eth0 inet static
#address 192.168.0.129
#network 192.168.0.0
#netmask 255.255.255.0
#broadcast 192.168.0.255
#gateway 192.168.0.1
allow-hotplug eth0

3、如果是網卡名字被修改成了其他名字,可以通過dmesg查看是否被修改。        

dmesg | grep -i eth
[ 1.007772] e1000 0000:02:01.0 eth0: (PCI:66MHz:32-bit) 00:0c:29:07:93:6a
[ 1.007776] e1000 0000:02:01.0 eth0: Intel(R) PRO/1000 Network Connection
[ 1.008309] e1000 0000:02:01.0 ens33: renamed from eth0

     修改成eth0:        

#vim /etc/default/grub
GRUB_CMDLINE_LINUX=""
修改爲
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
# grub-mkconfig -o /boot/grub/grub.cfg
    Generating grub configuration file ...
    Found background image: /usr/share/images/desktop-base/desktop-grub.png
    Found linux image: /boot/vmlinuz-4.9.0-6-amd64
    Found initrd image: /boot/initrd.img-4.9.0-6-amd64
    done
#reboot

        重啓虛擬機。   

    #service networking restart

       重啓網絡

     #config -a

        查看網卡名字是否恢復到eth0,是否up

4、打開服務,啓動Device install service, Device setup manager,並設置爲自動啓動。

5、在網絡編輯器裏還原默認配置。重啓虛擬機即可


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