virutalbox 中 centos 或 ubuntu 找不到网卡的解决办法

来源:互联网 发布:政委 知乎 编辑:程序博客网 时间:2024/05/13 06:08

如果你把虚拟机文件从别的地方copy过来,很可能会找不到网卡。

原因是网卡的mac 地址发生了变化。

 

1、查看virtualbox分配的网卡mac

 

 

 

 

 

 

如上图红线的位置。

 

2、如何察看本机的网卡信息 ?

 

vim /etc/udev/rules.d/70-persistent-net.rules

 

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:08:53:80",ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

 

其中 ATTR{address}=="08:00:27:08:53:80",  就是自己机器上配置的网卡信息,可能会有多个网卡。

 

这个时候,我们可以调整  NAME 后的网卡的名字,比如更改成 eth1

把virtualbox分配的地址按照格式写好。

然后保存推出。

 

3、找出网卡IP配置。

 

vim /etc/sysconfig/network-scripts/ifcfg-eth0

 

DEVICE="eth0"
HWADDR="08:00:27:08:53:80"
NM_CONTROLLED="yes"
ONBOOT="yes"
BOOTPROTO=dhcp

 

把 HWADDR 更改为刚才那个mac地址。

 

4、重启网卡

 

service network restart

 

这个时候,我们会发现网卡找到了,并且按照你的方式分配了IP。

0 0
原创粉丝点击