1. 程式人生 > >Centos7.4修改網卡為eth0

Centos7.4修改網卡為eth0

toc 命名規則 fff ram centos 7 frame bootp ras cal

Centos7.4系統將網卡名稱修改為eth0

方法一:安裝操作系統時,設置內核參數。
如下內核引導處時,選擇“Install CentOS 7”,按tab鍵修改內核參數,加入net.ifnames=0 biosdevname=0。回車開始安裝系統。
技術分享圖片
設置網卡ip時已經發現網卡設備名已更改為eth0
技術分享圖片
系統安裝成功通過ifconfig命令查看仍然為eth0
技術分享圖片
方法2: 安裝完系統後進行修改。
第一步:系統安裝結束後查看當前網卡名稱為ens33.
[root@jason2 ~]# 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
[root@jason2 ~]# cd /etc/sysconfig/network-scripts/
[root@jason2 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"
[root@jason2 network-scripts]#mv ifcfg-ens33 ifcfg-eth0
第三步:修改grub來禁用該命名規則
編輯grub配置文件/etc/sysconfig/grub,在GRUB_CMDLINE_LINUX變量中添加一句”net.ifnames=0 biosdevname=0“.
[root@jason2 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"
[root@jason2 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
[root@jason2 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
[root@jason2 grub2]#
第7步:重啟系統後驗證
[root@jason2 ~]# 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

[root@jason2 ~]#

Centos7.4修改網卡為eth0