Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to modify the default network card named eth0 under CentOS7

Shulou Source: shulou.com Published: 2022-05-31 11:43:31 10月02日 Update

This article introduces the relevant knowledge of "how to modify the default network card named eth0 under CentOS7". In the operation of the actual case, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The first way

This method is suitable for setting up the operating system when installing the operating system. Click tab, open the kernel boot option, and add kernel parameters: enter the net.ifnames=0 biosdevname=0 input and install the operating system normally.

The second way

Modify the device= parameter in the configuration file of the network card about eth0

[root@ansheng ~] # cd / etc/sysconfig/network-scripts/ [root@ansheng network-scripts] # vi ifcfg-eno16777728type=ethernetbootproto=dhcpdefroute=yespeerdns=yespeerroutes=yesipv4_failure_fatal=noipv6init=yesipv6_autoconf=yesipv6_defroute=yesipv6_peerdns=yesipv6_peerroutes=yesipv6_failure_fatal=noname=eno16777728uuid=8a3eade8-005c-46df-81f2-6e2598457bac#device=eno16777728device=eth0onboot=yes

Change the name of the network card configuration file to ifcfg-eth0

[root@ansheng network-scripts] # mv ifcfg-eno16777728 ifcfg-eth0

Since centos7 is booted by grub2, you also need to modify grub2, edit the / etc/default/grub configuration file, and add net.ifnames=0 biosdevname=0 after the parameter grub_cmdline_linux.

[root@ansheng network-scripts] # vi / etc/default/grubgrub_timeout=5grub_distributor= "$(sed's, release. * $, g' / etc/system-release)" grub_default=savedgrub_disable_submenu=truegrub_terminal_output= "console" grub_cmdline_linux= "rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0 biosdevname=0" grub_disable_recovery= "true"

Regenerate grub configuration and update kernel with grub2-mkconfig command

[root@ansheng network-scripts] # grub2-mkconfig-o / boot/grub2/grub.cfggenerating grub configuration file... found linux image: / boot/vmlinuz-3.10.0-327.el7.x86_64found initrd image: / boot/initramfs-3.10.0-327.el7.x86_64.imgfound linux image: / boot/vmlinuz-0-rescue-4dd6b54f74c94bff9e92c61d669fc195found initrd image: / boot/initramfs-0-rescue-4dd6b54f74c94bff9e92c61d669fc195.imgdone

Restart the system

[root@ansheng network-scripts] # reboot

Verify the Nic name after reboot:

[root@ansheng] # ifconfig eth0: flags=4163 mtu 1500 inet 192.168.56.130 netmask 255.255.255.0 broadcast 192.168.56.255 inet6 fe80::20c:29ff:fe6d:d894 prefixlen 64 scopeid 0x20 ether 00:0c:29:6d:d8:94 txqueuelen 1000 (ethernet) rx packets 27413 bytes 38532163 (36.7 mib) rx errors 0 dropped 0 overruns 0 frame 0 tx packets 7727 bytes 702194 (685.7 kib) tx errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73 mtu 65536 inet 127 .0.0.1 netmask 255.0.0.0 inet6:: 1 prefixlen 128 scopeid 0x10 loop txqueuelen 0 (local loopback) rx packets 0 bytes 0 (0.0b) rx errors 0 dropped 0 overruns 0 frame 0 tx packets 0 bytes 0 (0.0b) tx errors 0 dropped 0 overruns 0 carrier 0 collisions 0 "how to modify the default network card named eth0" under CentOS7. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Network card configuration parameter file method system operating system content kernel name more knowledge practicality achievement next command dilemma reality situation article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Information macOS vpn MariaDB