Contents

CentOS 更换网卡后手动更新MAC

Contents

在VBOX里面装了一台CentOS作为还原母鸡,复制小鸡的MAC地址会改变,之前在母鸡配置好的网络就不能用了

这时需要将网卡配置文件里面的MAC地址更改为新的就可以用,其它的配置可以不用变

好久没有弄了,都快忘记了,记录一下

新网卡的MAC地址在 /etc/udev/rules.d/70-persistent-net.rules 这个文件里面的最后一段

比如说我的

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27


  
# 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:89:d4:d9", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"  
  
  
  
# PCI device 0x8086:0x100e (e1000)  
  
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:96:53:8a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

  

第一个SUBSYSTEM 就是旧网卡的MAC地址,第二个SUBSYSTEM就是新检测到的了,注释掉旧的,将新的NAME改为eth0 并将新的MAC替换掉ifcfg-eth0里面的就OK了

当然别忘记了

1
2
3
4
5
6
7


  
service network restart