CentOS7修改網(wǎng)卡名ensXX稱為eth0

CentOS7.4 系統(tǒng)安裝好后,默認(rèn)網(wǎng)卡名稱為為ensXX,如ens33,如果要修改為eth0開頭,需要進(jìn)行如下配置


1.查看原網(wǎng)卡名稱:

[root@centos7 network-scripts]# ifconfig

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>? mtu 1500

? ? ? ? inet 192.168.155.104? netmask 255.255.255.0? broadcast 192.168.155.255

? ? ? ? inet6 fe80::212a:c0fb:e179:7f1c? prefixlen 64? scopeid 0x20<link>

? ? ? ? ether 00:0c:29:c4:34:bd? txqueuelen 1000? (Ethernet)

? ? ? ? RX packets 1465? bytes 129004 (125.9 KiB)

? ? ? ? RX errors 0? dropped 0? overruns 0? frame 0

? ? ? ? TX packets 802? bytes 104240 (101.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 72? bytes 5720 (5.5 KiB)

? ? ? ? RX errors 0? dropped 0? overruns 0? frame 0

? ? ? ? TX packets 72? bytes 5720 (5.5 KiB)

? ? ? ? TX errors 0? dropped 0 overruns 0? carrier 0? collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>? mtu 1500

? ? ? ? inet 192.168.122.1? netmask 255.255.255.0? broadcast 192.168.122.255

? ? ? ? ether 52:54:00:1a:02:e7? txqueuelen 1000? (Ethernet)

? ? ? ? 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

[root@centos7 network-scripts]#


2.修改網(wǎng)卡信息

[root@centos7 ~]# cd /etc/sysconfig/network-scripts/
[root@centos7 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?????????????????? #name修改為eth0

UUID=048802a8-f20c-4c19-902a-e326b3a69686

#DEVICE=ens33

ONBOOT=yes


網(wǎng)卡配置文件名稱改為 ifcfg-eth0?

[root@centos7 network-scripts]# mv ifcfg-ens33 ifcfg-eth0


3.修改grub配置

因 CentOS7 采用 grub2 引導(dǎo),還需要對(duì) grub2 進(jìn)行修改,編輯 /etc/default/grub 配置文件,在 GRUB_CMDLINE_LINUX 這個(gè)參數(shù)后面加入 "net.ifnames=0?biosdevname=0"

[root@centos7 network-scripts]# 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 rd.lvm.lv=centos/root rd.lvm.lv

=centos/swap rhgb quiet net.ifnames=0 biosdevname=0"

GRUB_DISABLE_RECOVERY="true"


用 grub2-mkconfig 命令重新生成GRUB配置并更新內(nèi)核

[root@centos7 network-scripts]# 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-c15c0efab776454daa1c4da36ec768f6

Found initrd image: /boot/initramfs-0-rescue-c15c0efab776454daa1c4da36ec768f6.img

done

[root@centos7 network-scripts]#


重啟系統(tǒng)

[root@centos7 network-scripts]# reboot


4.驗(yàn)證網(wǎng)卡名

重啟之后驗(yàn)證網(wǎng)卡名稱:

[root@centos7 ~]# ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>? mtu 1500

? ? ? ? inet 192.168.155.104? netmask 255.255.255.0? broadcast 192.168.155.255

? ? ? ? inet6 fe80::8453:5a1:debb:b9d5? prefixlen 64? scopeid 0x20<link>

? ? ? ? ether 00:0c:29:c4:34:bd? txqueuelen 1000? (Ethernet)

? ? ? ? RX packets 119? bytes 12471 (12.1 KiB)

? ? ? ? RX errors 0? dropped 0? overruns 0? frame 0

? ? ? ? TX packets 142? bytes 18721 (18.2 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

[root@centos7 ~]#

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容