【基础设置】修改网卡设备名称

vm使用克隆出来的虚拟机,网卡名称变成eth1,要把这个eth1改为eth0,参照以下步骤:nginx

  1. 查看eth1对应的mac地址
    ide

    ifconfigip

    如:eth1:00:0C:29:74:F2:99ci

  2. 修改/etc/sysconfig/network-scripts/ifcfg-eth0的mac地址为eth1的mac地址generator

    因为vm克隆过来,network-scripts目录下没有eth1的文件,目录下有一个ifcfg-eth0,修改以下:虚拟机

hwaddr由原来的mac改为eth1的mac,保存。it

DEVICE=eth0class

HWADDR=00:0C:29:74:F2:99file

ONBOOT=yesnetwork

IPADDR=192.168.198.10

BOOTPROTO=none

NETMASK=255.255.255.0

TYPE=Ethernet

GATEWAY=192.198.198.2

    

3. 修改/etc/udev/rules.d/70-persistent-net.rules文件


attr{address} 与 name两个字段


[root@nginx rules.d]# cat 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 0x1022:0x2000 (pcnet32)

# SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:55:61:94", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"


# PCI device 0x1022:0x2000 (pcnet32)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:74:f2:99", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

[root@nginx rules.d]# 


4. 重启系统