• Centos7.2 修改网卡名称


    查看ip

    [root@localhost network-scripts]# ip addr
    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: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 00:0c:29:a7:a0:8c brd ff:ff:ff:ff:ff:ff
        inet 192.168.1.105/24 brd 192.168.1.255 scope global dynamic eno16777736
           valid_lft 4214sec preferred_lft 4214sec
        inet 192.168.1.122/24 brd 192.168.1.255 scope global secondary eno16777736
           valid_lft forever preferred_lft forever
        inet6 fe80::ac30:2bcb:e910:3ae/64 scope link 
           valid_lft forever preferred_lft forever
    3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
        link/ether 52:54:00:74:cb:1a 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
    4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
        link/ether 52:54:00:74:cb:1a brd ff:ff:ff:ff:ff:ff
    [root@localhost network-scripts]# 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: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 00:0c:29:a7:a0:8c brd ff:ff:ff:ff:ff:ff
        inet 192.168.1.105/24 brd 192.168.1.255 scope global dynamic eno16777736
           valid_lft 4157sec preferred_lft 4157sec
        inet 192.168.1.122/24 brd 192.168.1.255 scope global secondary eno16777736
           valid_lft forever preferred_lft forever
        inet6 fe80::ac30:2bcb:e910:3ae/64 scope link 
           valid_lft forever preferred_lft forever
    3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
        link/ether 52:54:00:74:cb:1a 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
    4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
        link/ether 52:54:00:74:cb:1a brd ff:ff:ff:ff:ff:ff

    可以发现网卡名称eno16777736,现在想要修改名称

    /etc/sysconfig/network-scripts/ifcfg-eno16777736 

    打开文件,修改内部的DECIVE为eth0,保存退出

    重命名,将文件ifcfg-eno16777736文件名修改为eth0

    cd /etc/sysconfig/network-scripts/
    mv ifcfg-eno16777736 ifcfg-eth0

    禁用该可预测命名规则。对于这一点,你可以在启动时传递“net.ifnames=0 biosdevname=0 ”的内核参数。这是通过编辑/etc/default/grub并加入“net.ifnames=0 biosdevname=0 ”到GRUBCMDLINELINUX变量来实现的。

    gedit  /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 rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
    GRUB_DISABLE_RECOVERY="true"

    修改后:

    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 rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0 biosdevname=0"
    GRUB_DISABLE_RECOVERY="true"

    构建新的img文件

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

    重新启动服务器

    [root@localhost ~]# reboot

    重新查看ip地址:

    不要打我,我这边报Mac地址冲突,但是网上很多人这么操作是成功的,后面再尝试!

    http://www.jb51.net/article/120340.htm

    http://www.linuxidc.com/Linux/2017-03/141384.htm

  • 相关阅读:
    8.电影推荐
    一.Memcached企业服务
    7.学完linux系统运维到底可以做什么?
    svn+jenkins自动部署
    关于gitlab+jenkins自动部署代码的实现
    Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre
    php实现雪花算法(ID递增)
    php使用rdkafka进行消费
    Burp破解安装(1.7和2.0)
    在已有lnmp环境的基础上安装PHP7
  • 原文地址:https://www.cnblogs.com/hongdada/p/7967708.html
Copyright © 2020-2023  润新知