Centos7.4修改网卡为eth0

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7.4修改网卡为eth0相关的知识,希望对你有一定的参考价值。

Centos7.4系统将网卡名称修改为eth0

方法一:安装操作系统时,设置内核参数。
如下内核引导处时,选择“Install CentOS 7”,按tab键修改内核参数,加入net.ifnames=0 biosdevname=0。回车开始安装系统。
技术分享图片
设置网卡ip时已经发现网卡设备名已更改为eth0
技术分享图片
系统安装成功通过ifconfig命令查看仍然为eth0
技术分享图片
方法2: 安装完系统后进行修改。
第一步:系统安装结束后查看当前网卡名称为ens33.
[[email protected] ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.131 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::1dc3:7a21:103e:c958 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:d5:85:54 txqueuelen 1000 (Ethernet)
RX packets 117 bytes 14086 (13.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 109 bytes 15871 (15.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
第二步:编辑网卡的配置文件
将”/etc/sysconfig/network-scripts/ifcfg-ens33“的NAME与DEVICE参数项修改为eth0。将网卡配置文件ifcfg-ens33修改为ifcfg-eth0
[[email protected] ~]# cd /etc/sysconfig/network-scripts/
[root[email protected] network-scripts]# vi ifcfg-ens33
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME=" eth0"
UUID="c3136d13-6e1e-4a7b-bcfb-f8e85e0351e0"
DEVICE="eth0"
ONBOOT="yes"
[[email protected] network-scripts]#mv ifcfg-ens33 ifcfg-eth0
第三步:修改grub来禁用该命名规则
编辑grub配置文件/etc/sysconfig/grub,在GRUB_CMDLINE_LINUX变量中添加一句”net.ifnames=0 biosdevname=0“.
[[email protected] grub2]#vi /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 quiet"
GRUB_DISABLE_RECOVERY="true"
[[email protected] grub2]# 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 rhgb quiet net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true
第四步:重新生成grub配置并更新内核参数
运行命令:grub2-mkconfig -o /boot/grub2/grub.cfg
[[email protected] grub2]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-77419a0d119c43968d735f6a0b8534f4
Found initrd image: /boot/initramfs-0-rescue-77419a0d119c43968d735f6a0b8534f4.img
done
[[email protected] grub2]#
第7步:重启系统后验证
[[email protected] ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.131 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::bf21:39fc:b077:3c9b prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:d5:85:54 txqueuelen 1000 (Ethernet)
RX packets 801 bytes 84912 (82.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 520 bytes 83725 (81.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

[[email protected] ~]#

以上是关于Centos7.4修改网卡为eth0的主要内容,如果未能解决你的问题,请参考以下文章

RHEL7/centos7修改网卡名称为eth0

ubuntu 如何修改网卡名称

RHEL7/centos7修改网卡名称为eth0

CentOS 7 修改网卡名称为eth0

CentOS7修改网卡为eth0

配置虚拟机修改网卡名称eno16777736为eth0