码迷,mamicode.com
首页 > 其他好文 > 详细

Centos7.2 修改网卡名称

时间:2017-12-03 23:59:31      阅读:462      评论:0      收藏:0      [点我收藏+]

标签:规则   改名   release   car   改网卡名   ras   centos7   crash   forever   

查看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

Centos7.2 修改网卡名称

标签:规则   改名   release   car   改网卡名   ras   centos7   crash   forever   

原文地址:http://www.cnblogs.com/hongdada/p/7967708.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!