• centos7修改网卡名字为传统名字


    前言:在centos6及其之前的系统中,我们已经习惯了网卡为eth0,eht1这种网卡命名方式,在centos7上网卡名字为ens33,ens37,ens38等名字,很别扭,想统一下网卡的命名。

    1 修改内核配置文件

    [root@centos74 ~]$ sed -r -i.bak '/^GRUB_CMDLINE_LINUX/s@(.*)"@1 net.ifnames=0 biosdevname=0"@' /etc/default/grub               # 修改下grub的配置文件   -i.bak保留原始文件的备份为.bak文件
    [root@centos74 ~]$ cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bak                                                              # 备份配置文件
    [root@centos74 ~]$ grub2-mkconfig -o /boot/grub2/grub.cfg                                                                         # grub2-mkconfig 生成配置文件
    Generating grub configuration file ...
    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-063d6d8599b74e68adab2b5e6cc3add8
    Found initrd image: /boot/initramfs-0-rescue-063d6d8599b74e68adab2b5e6cc3add8.img
    done

    2 修改已有的网卡信息

    [root@centos74 network-scripts]$ mv ifcfg-ens33 ifcfg-eth0                                                             # 已有网卡的重命名,我这里只有ens33有配置,只做这个网卡的处理
    [root@centos74 network-scripts]$ sed -ri 's@ens33@eth0@' ifcfg-eth0                                                    # 替换ens33为eth0
    [root@centos74 network-scripts]$ cat ifcfg-eth0                                                                        # 检查下
    TYPE=Ethernet
    PROXY_METHOD=none
    BROWSER_ONLY=no
    BOOTPROTO=dhcp
    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=f20778dd-bdaa-4e5c-8e2a-8fef4ec151a0
    DEVICE=eth0
    ONBOOT=yes

    3 重启检查

    重启

    [root@centos74 ~]$ reboot                                                                                    # 重启系统

     检查下

    [root@centos74 ~]$ ip a                                                                                       # 检查
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        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:ad:b0:f2 brd ff:ff:ff:ff:ff:ff
        inet 192.168.1.105/24 brd 192.168.1.255 scope global dynamic eth0
           valid_lft 172502sec preferred_lft 172502sec
        inet6 fe80::424f:3b52:2ac8:2535/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:ad:b0:fc brd ff:ff:ff:ff:ff:ff
        inet 192.168.27.141/24 brd 192.168.27.255 scope global dynamic eth1
           valid_lft 1503sec preferred_lft 1503sec
        inet6 fe80::25f5:cc0c:6e2a:d1b2/64 scope link 
           valid_lft forever preferred_lft forever
    4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 00:0c:29:ad:b0:06 brd ff:ff:ff:ff:ff:ff
        inet 192.168.27.142/24 brd 192.168.27.255 scope global dynamic eth2
           valid_lft 1503sec preferred_lft 1503sec
        inet6 fe80::7046:9827:fa73:db4c/64 scope link 
           valid_lft forever preferred_lft forever
    5: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
        link/ether 52:54:00:3f:39:3a brd ff:ff:ff:ff:ff:ff
        inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
           valid_lft forever preferred_lft forever
    6: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
        link/ether 52:54:00:3f:39:3a brd ff:ff:ff:ff:ff:ff
    7: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN 
        link/ether 02:42:ba:6e:03:4f brd ff:ff:ff:ff:ff:ff
        inet 172.17.0.1/16 scope global docker0
           valid_lft forever preferred_lft forever
  • 相关阅读:
    JS基础(一)异常错误
    实验四 主存空间的分配和回收
    实验三、进程调度模拟程序实验
    学习进度条
    软件工程学期总结
    实验四、主存空间的分配和回收
    诚信与道德
    【操作系统】实验三、进程调度模拟程序实验
    软件工程---在此基础上,进行软件的改进
    【操作系统】实验二 作业调度模拟程序
  • 原文地址:https://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_044_rename_netcard.html
Copyright © 2020-2023  润新知