实验环境:CentOS6.8。

[root@localhost6 ~]#ip a #查看网卡信息;现准备修改eth1的网卡名
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:d7:91:33 brd ff:ff:ff:ff:ff:ff
    inet 172.16.252.242/16 brd 172.16.255.255 scope global eth0
    inet6 fe80::20c:29ff:fed7:9133/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:d7:91:3d brd ff:ff:ff:ff:ff:ff
    inet 172.16.252.199/16 brd 172.16.255.255 scope global eth1
    inet6 fe80::20c:29ff:fed7:913d/64 scope link 
       valid_lft forever preferred_lft forever

实验步骤:

  1、修改网卡名的配置文件;

  2、卸载网卡驱动;

  3、装载网卡驱动。

  1. #1、修改网卡名的配置文件
    #修改网卡名的配置文件,在/etc/udev/rules.d/70-persistent-net.rules
    [root@localhost6 ~]#cd /etc/udev/
    [root@localhost6 udev]#ls
    makedev.d rules.d udev.conf
    [root@localhost6 udev]#cd rules.d/
    [root@localhost6 rules.d]#ls
    60-fprint-autosuspend.rules  60-raw.rules             90-alsa.rules   99-fuse.rules
    60-openct.rules              70-persistent-cd.rules   90-hal.rules
    60-pcmcia.rules              70-persistent-net.rules  98-kexec.rules
    [root@localhost6 rules.d]#vi 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:0x100f (e1000)    ##e1000驱动程序名
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:d7:91:33", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
    
    # PCI device 0x8086:0x100f (e1000)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:d7:91:3d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
    ~                           ##将NAME="eth1"修改成ethxin
    ~ ~ ~ "70-persistent-net.rules" 11L, 585C 


    [root@localhost6 rules.d]#lsmod | grep -i 'e1000'  #查看驱动程序模块
    e1000 134863 0

    #2、卸载网卡驱动
    [root@localhost6 rules.d]#modprobe -r e1000  #卸载网卡驱动
    [root@localhost6 rules.d]#lsmod | grep -i 'e1000'  #查看驱动程序模块,没有数据显示
    #3、装载网卡驱动
    [root@localhost6 ~]#modprobe e1000  #装载网卡
    [root@localhost6 ~]#ip a

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
    valid_lft forever preferred_lft forever
    4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:d7:91:33 brd ff:ff:ff:ff:ff:ff
    inet 172.16.252.242/16 brd 172.16.255.255 scope global eth0
    inet6 fe80::20c:29ff:fed7:9133/64 scope link
    valid_lft forever preferred_lft forever
    5: ethxin: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:0c:29:d7:91:3d brd ff:ff:ff:ff:ff:ff
    inet6 fe80::20c:29ff:fed7:913d/64 scope link
    valid_lft forever preferred_lft forever