该方法适用于物理机上的系统,同时也适用于kvm等虚拟机上安装的系统。
需要修改的文件/lib/udev/rules.d/60-net.rules
#刚装完的系统应该只有下面一句话
ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="1", PROGRAM="/lib/udev/rename_device", RESULT=="?*", NAME="$result"
做如下修改:
ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="1", ATTR{address}=="52:54:00:31:dc:2d", NAME="extern", GOTO="net_end"
ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="1", ATTR{address}=="52:54:00:74:f4:20", NAME="internel", GOTO="net_end"
ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="1", PROGRAM="/lib/udev/rename_device", RESULT=="?*", NAME="$result"
LABEL="net_end"
重启。
这样就将mac地址为52:54:00:31:dc:2d的网卡重命名为extern,将mac地址为52:54:00:74:f4:20的网卡重命名为internel