• 如何在RHEL7或CentOS 7系统下修改网卡名称(亲测有效~!)


    亲测有效的更改RHEL7或CentOS 7的网卡名称的方法,

    按照以下4步来操作就可以实现!

    Step 1 :网卡配置文件名称重命名为eth0
    [root@localhost ~]# ifconfig
    ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet 192.168.74.74 netmask 255.255.255.0 broadcast 192.168.74.255
    inet6 fe80::5c:8c49:19b3:669 prefixlen 64 scopeid 0x20<link>
    ether 00:0c:29:54:c2:7a txqueuelen 1000 (Ethernet)
    RX packets 112 bytes 11132 (10.8 KiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 112 bytes 13927 (13.6 KiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
    inet 127.0.0.1 netmask 255.0.0.0
    inet6 ::1 prefixlen 128 scopeid 0x10<host>
    loop txqueuelen 1000 (Local Loopback)
    RX packets 48 bytes 4080 (3.9 KiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 48 bytes 4080 (3.9 KiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    #注意:00:0c:29:54:c2:7a为需要修改的网卡MAC地址

    cd /etc/sysconfig/network-scripts/

    ls
    ifcfg-ens33 ifdown-ipv6 ifdown-TeamPort ifup-ippp ifup-routes network-functions
    ifcfg-lo ifdown-isdn ifdown-tunnel ifup-ipv6 ifup-sit network-functions-ipv6
    ifdown ifdown-post ifup ifup-isdn ifup-Team
    ifdown-bnep ifdown-ppp ifup-aliases ifup-plip ifup-TeamPort
    ifdown-eth ifdown-routes ifup-bnep ifup-plusb ifup-tunnel
    ifdown-ib ifdown-sit ifup-eth ifup-post ifup-wireless
    ifdown-ippp ifdown-Team ifup-ib ifup-ppp init.ipv6-global
    #ifcfg-ens33 是目前需要更改名称的网卡  

    mv ifcfg-ens33 ifcfg-eth0

    vim ifcfg-eth0
    TYPE=Ethernet
    PROXY_METHOD=none
    BROWSER_ONLY=no
    BOOTPROTO=none
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    IPV6_ADDR_GEN_MODE=stable-privacy
    NAME=eth0
    UUID=febc83ef-0890-4b03-b859-9045c4158d13
    DEVICE=eth0
    ONBOOT=yes
    IPADDR=192.168.74.74
    PREFIX=24
    DNS1=223.5.5.5
    IPV6_PRIVACY=no

    GATEWAY=192.168.74.2

    :wq!
    #主要修改NAME=eth0 DEVICE=eth0

    Step 2 :禁用网卡命名规则
    [root@localhost network-scripts]# cd /etc/default/

    [root@localhost default]# ls
    grub nss useradd

    [root@localhost default]# vim grub
    GRUB_TIMEOUT=5
    GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
    GRUB_DEFAULT=saved
    GRUB_DISABLE_SUBMENU=true
    GRUB_TERMINAL_OUTPUT="console"
    GRUB_CMDLINE_LINUX="rhgb quiet net.ifnames=0 biosdevname=0"
    GRUB_DISABLE_RECOVERY="true"

    :wq!
    #在GRUB_CMDLINE_LINUX="rhgb quiet" 中增加“ net.ifnames=0 biosdevname=0” 表示禁用此功能

    Step 3 :添加udev网卡规则
    [root@localhost default]# cd /etc/udev/rules.d/

    [root@localhost rules.d]# ls
    70-persistent-ipoib.rules

    [root@localhost rules.d]# vim 70-persistent-ipoib.rules

    # This is a sample udev rules file that demonstrates how to get udev to
    # set the name of IPoIB interfaces to whatever you wish. There is a
    # 16 character limit on network device names.
    #
    # Important items to note: ATTR{type}=="32" is IPoIB interfaces, and the
    # ATTR{address} match must start with ?* and only reference the last 8
    # bytes of the address or else the address might not match the variable QPN
    # portion.
    #
    # Modern udev is case sensitive and all addresses need to be in lower case.
    #
    # ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="32", ATTR{address}=="?*00:02:c9:03:00:31:78:f2", NAME="mlx4_ib3"
    #
    SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="00:0c:29:54:c2:7a",
    ATTR{type}=="1" ,KERNEL=="eth*",NAME="eth0"

    :wq!
    # 增加内容SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="需要修改名称的网卡MAC地址",ATTR{type}=="1" ,KERNEL=="eth*",NAME="eth0"

    [root@localhost rules.d]# grub2-mkconfig -o /boot/grub2/grub.cfg
    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-3.10.0-1127.8.2.el7.x86_64
    Found initrd image: /boot/initramfs-3.10.0-1127.8.2.el7.x86_64.img
    Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
    Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
    Found linux image: /boot/vmlinuz-0-rescue-fcfe639a5bd94a0ba3369ead5d2ee97b
    Found initrd image: /boot/initramfs-0-rescue-fcfe639a5bd94a0ba3369ead5d2ee97b.img
    done
    # 加载更新grub配置参数


    Step 4 :重启Linux系统后验证网卡名称是否更改成功
    [root@localhost rules.d]# ifconfig
    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet 192.168.74.74 netmask 255.255.255.0 broadcast 192.168.74.255
    inet6 fe80::5c:8c49:19b3:669 prefixlen 64 scopeid 0x20<link>
    ether 00:0c:29:54:c2:7a txqueuelen 1000 (Ethernet)
    RX packets 865 bytes 70839 (69.1 KiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 590 bytes 74932 (73.1 KiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
    inet 127.0.0.1 netmask 255.0.0.0
    inet6 ::1 prefixlen 128 scopeid 0x10<host>
    loop txqueuelen 1000 (Local Loopback)
    RX packets 48 bytes 4080 (3.9 KiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 48 bytes 4080 (3.9 KiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    #修改成功!

  • 相关阅读:
    数据库三大范式另一角度的理解
    Log4j和Slf4j的联系和区别
    cglib和Jdk的对比
    Git- 忽略文件 ignore 无效
    GIT报错:git did not exit cleanly (exit code 1)
    Nginx和Zuul配合使用后,Cookie写入问题
    RabbitMQ报错:undefined: There is no template at js/tmpl/login.ejs
    Feign报错:The bean 'xxxxx.FeignClientSpecification' could not be registered.
    ES报错:NoNodeAvailableException[None of the configured nodes are available
    SpringBoot报错:
  • 原文地址:https://www.cnblogs.com/liuxc83/p/12991402.html
Copyright © 2020-2023  润新知