• sentos7网卡改名


    一、已经装好系统CentOS7修改网卡为eth0

    1. 修改网卡配置文件
    [root@localhost ~]# mv /etc/sysconfig/network-scripts/ifcfg-ens33   /etc/sysconfig/network-scripts/ifcfg-eth0
    
    [root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0                                   
    NAME=eth0  
    
    2. GRUB添加kernel参数
    # vim /etc/sysconfig/grub
    GRUB_CMDLINE_LINUX="......      net.ifnames=0"
    
    3.重新装载配置文件
    # grub2-mkconfig -o /boot/grub2/grub.cfg
    
    4. reboot
    

    二、未装好系统CentOS7修改网卡为eth0

    也可在安装系统时添加kernel参数 net.ifnames=0

     三、修改网卡名脚本

    #!/bin/sh
    a=`ifconfig  |grep mtu |cut -f1 -d ':'`
    b=0
    
    for i in $a
    do
    if  [ $i != 'lo' ]
    then
    
    echo -e "33[40;32m ===================================start edit eth$b================================================================================33[0m"
    
    sed -i "s/^NAME.*$/NAME=eth${b}/g" /etc/sysconfig/network-scripts/ifcfg-$i
    sed -i "s/^BOOTPROTO.*$/BOOTPROTO=static/g" /etc/sysconfig/network-scripts/ifcfg-$i
    sed -i "s/^DEVICE.*$/DEVICE=eth${b}/g" /etc/sysconfig/network-scripts/ifcfg-$i
    sed -i '/PROXY_METHO|BROWSER_ONLY|DEFROUTE|IPV4_FAILURE_FATAL|IPV6*|UUID/d' /etc/sysconfig/network-scripts/ifcfg-$i
    
    mv /etc/sysconfig/network-scripts/ifcfg-$i /etc/sysconfig/network-scripts/ifcfg-eth$b
    
    ((b++))
    sleep 2
    else
    echo "skip $i"
    fi
    done
    
    sed -i 's/rhgb/net.ifnames=0 biosdevname=0 &/' /etc/default/grub
    
    grub2-mkconfig -o /boot/grub2/grub.cfg
    grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
    
    echo -e "33[40;32m ===================================edit network finish===========================================================================33[0m"
    
  • 相关阅读:
    QML使用动画连续非线性改变int的取值
    QML粒子系统
    QML获取当前时间
    QML与C++混合编程
    QMLBinding
    QML图形渲染QtGraphicalEffects
    [九度][何海涛] 数组中只出现一次的数字
    [九度][何海涛] 扑克牌顺子
    [九度][何海涛] 最大子向量和
    [九度][何海涛] Move!Move!!Move!!!
  • 原文地址:https://www.cnblogs.com/zjz20/p/11280279.html
Copyright © 2020-2023  润新知