zoukankan      html  css  js  c++  java
  • centos7修改网卡名称为eth0-技术流ken

     

    前言

    在配置集群的时候,需要保持网卡名称一致,所以我们需要修改centos7中的网卡名称为eth0.

    检查网卡

    检查网卡,现在网卡名称是ens33

    [root@localhost ~]# ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
        link/ether 00:0c:29:e9:0d:a7 brd ff:ff:ff:ff:ff:ff
        inet 10.220.5.9/24 brd 10.220.5.255 scope global noprefixroute dynamic ens33
           valid_lft 518249sec preferred_lft 518249sec
        inet6 fe80::20c:29ff:fee9:da7/64 scope link noprefixroute 
           valid_lft forever preferred_lft forever

    修改网卡名称

    修改启动过程中加载的内核参数

    添加 net.ifnames=0 biosdevname=0

    [root@localhost ~]# vim /etc/sysconfig/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="crashkernel=auto rhgb net.ifnames=0 biosdevname=0 quiet"
    GRUB_DISABLE_RECOVERY="true"

    重新生成grub

    [root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg 
    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-3.10.0-862.el7.x86_64
    Found initrd image: /boot/initramfs-3.10.0-862.el7.x86_64.img
    Found linux image: /boot/vmlinuz-0-rescue-04a5422144ea49f38d885773499b59b9
    Found initrd image: /boot/initramfs-0-rescue-04a5422144ea49f38d885773499b59b9.img
    done

       

    创建网卡配置文件

    [root@localhost ~]# cd /etc/sysconfig/network-scripts/
    [root@localhost network-scripts]# mv ifcfg-ens33 ifcfg-eth0
    [root@localhost network-scripts]# vim ifcfg-eth0 
    DEVICE="eth0"
    ONBOOT=yes
    NETBOOT=yes
    BOOTPROTO=dhcp
    TYPE=Ethernet

       

    重启

    [root@localhost network-scripts]# reboot

    检查网卡名称

    检查发现网卡名称已经变成了eth0

    [root@localhost ~]# ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        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 UNKNOWN group default qlen 1000
        link/ether 00:0c:29:e9:0d:a7 brd ff:ff:ff:ff:ff:ff
        inet 10.220.5.9/24 brd 10.220.5.255 scope global noprefixroute dynamic eth0
           valid_lft 518376sec preferred_lft 518376sec
        inet6 fe80::20c:29ff:fee9:da7/64 scope link 
           valid_lft forever preferred_lft forever
  • 相关阅读:
    collection系列用法-defaultdict()
    collection系列用法-namedtuple()
    collection系列用法-deque双向队列
    Python 拷贝对象(深拷贝deepcopy与浅拷贝copy)
    python 【第四篇】:面向对象(一)
    python之lambda表达式
    python 【第三篇】:函数及参数
    LeetCode 648. Replace Words (单词替换)
    LeetCode 953. Verifying an Alien Dictionary (验证外星语词典)
    LeetCode 970. Powerful Integers (强整数)
  • 原文地址:https://www.cnblogs.com/kenken2018/p/9715690.html
Copyright © 2011-2022 走看看