重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4209|回复: 0
打印 上一主题 下一主题

更换rhel7.0里面的网卡设备名字为7.0以前的名字

[复制链接]
跳转到指定楼层
楼主
发表于 2015-6-10 16:44:24 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

更换rhel7.0里面的网卡设备名字为7.0以前的名字

在rhel7.0里面,网卡的设备名字,被自动基于固件,拓扑结构和位置信息来确定。现在,即使添加或移除网络设备,接口名称仍然保持固定,而无需重新枚举,和坏掉的硬件可以无缝替换
但是这样一来,虽然有好处,但也影响了不少用户的操作,因为新的命名方案接口名称比传统的eth0相比有点难以阅读。出于习惯等一些原因,你想修改网卡名称,下面为大家介绍如何在

RHEL7命名网络接口。

1.系统安装完毕,可能你的网卡命名是这样的
  [root@rac2 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    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:af:1b:87 brd ff:ff:ff:ff:ff:ff
    inet 192.168.133.121/24 brd 192.168.133.255 scope global eno16777736
    inet6 fe80::20c:29ff:feaf:1b87/64 scope link
       valid_lft forever preferred_lft forever
3: eno33554992: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:af:1b:91 brd ff:ff:ff:ff:ff:ff
4: eno50332224
: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:af:1b:9b brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.121/24 brd 192.168.0.255 scope global eno50332224
    inet6 fe80::20c:29ff:feaf:1b9b/64 scope link
       valid_lft forever preferred_lft forever

2.想变成以前版本的eth0,eth1...,这种样子的,我们只需要按一下方法做:
   2.1 修改 /etc/default/grub 文件,在 GRUBCMDLINELINUX变量后面增加上 “net.ifnames=0 biosdevname=0 ”内核参数
      /etc/default/grub 修改前内容:
      [root@rac2 ~]# vi /etc/default/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  vconsole.font=latarcyrheb-sun16 rd.lvm.lv=ol/swap rd.lvm.lv=ol/root vconsole.keymap=us rhgb quiet"
      GRUB_DISABLE_RECOVERY="true"

      修改后内容:

      [root@rac2 ~]# more /etc/default/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  vconsole.font=latarcyrheb-sun16 rd.lvm.lv=ol/swap rd.lvm.lv=ol/root vconsole.keymap=us net.ifnames=0 biosdevname=0 rhgb

quiet"
      GRUB_DISABLE_RECOVERY="true"

   2.2 更新内核参数
      运行命令grub2-mkconfig -o /boot/grub2/grub.cfg 来重新生成GRUB配置并更新内核参数。

      [root@rac2 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
      Generating grub configuration file ...
      Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
      Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
      Found linux image: /boot/vmlinuz-3.8.13-35.3.1.el7uek.x86_64
      Found initrd image: /boot/initramfs-3.8.13-35.3.1.el7uek.x86_64.img
      Warning: Please don't use old title `Oracle Linux Server, with Unbreakable Enterprise Kernel 3.8.13-35.3.1.el7uek.x86_64' for GRUB_DEFAULT, use `Advanced options 

     for Oracle Linux Server>Oracle Linux Server, with Unbreakable Enterprise Kernel 3.8.13-35.3.1.el7uek.x86_64' (for versions before 2.00) or `gnulinux-advanced-     

58943444-cead-4d08-8820-f56eb92b5715>gnulinux-3.8.13-35.3.1.el7uek.x86_64-advanced-58943444-cead-4d08-8820-f56eb92b5715' (for 2.00 or later)
      Found linux image: /boot/vmlinuz-0-rescue-d61db428063441ca8f24dd7b0303f820
      Found initrd image: /boot/initramfs-0-rescue-d61db428063441ca8f24dd7b0303f820.img
      done
      [root@rac2 ~]# 
3.重启操作系统
      [root@rac2 ~]# reboot

4.确认网卡名字
  [root@rac2 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    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:af:1b:87 brd ff:ff:ff:ff:ff:ff
    inet 192.168.133.121/24 brd 192.168.133.255 scope global eth0
    inet 169.254.52.232/16 brd 169.254.255.255 scope global eth0:1
    inet6 fe80::20c:29ff:feaf:1b87/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:af:1b:91 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:af:1b:9b brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.121/24 brd 192.168.0.255 scope global eth2
    inet 192.168.0.123/24 brd 192.168.0.255 scope global secondary eth2:1
    inet6 fe80::20c:29ff:feaf:1b9b/64 scope link
       valid_lft forever preferred_lft forever

  我们看到,网卡设备名字已经修改。
 

[此贴子已经被作者于2015-06-10 16:50:47编辑过]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-11-28 19:17 , Processed in 0.112682 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表