Change the name of the virtual machine network card to eth0

The default network card name is eno16777736

1. Modify the configuration file ifcfg-eno16777736

[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# vim ifcfg-eno16777736

Change NAME and DEVICE to eth0

copy code
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE = yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE = yes
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=0fea6de7-54d9-4a8d-bddc-3061678e8a0e
DEVICE=eth0
ONBOOT=yes
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
copy code

rename the file 

mv ifcfg-eno16777736 ifcfg-eth0

If you don't start dhcp, you can set static ip configuration

copy code
TYPE=Ethernet  
DEVICE=eth0
ONBOOT=yes #Whether it is automatically loaded when the system starts
BOOTPROTO=static #Enable address protocol --static: static protocol --bootp protocol --dhcp protocol
IPADDR=192.168.81.128
NETMASK=255.255.255.0
GATEWAY=192.168.81.2
DNS1=192.168.81.2
HWADDR=00:0C:29:13:5D:74
BROADCAST=192.168.81.255
copy code

2. Disable the predictable naming rule

Add net.ifnames=0 biosdevname=0 to the GRUB_CMDLINE_LINUX variable in the grup file

copy code
[root@localhost network-scripts]# vim /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 net.ifnames=0 biosdevname=0 rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
copy code

Run the command to regenerate the GRUB configuration and update the kernel parameters

copy code
[root@localhost network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-692c580a413f41d8b51ddc4724500560
Found initrd image: /boot/initramfs-0-rescue-692c580a413f41d8b51ddc4724500560.img
done
copy code

3. Restart the system 

[root@localhost network-scripts]# reboot now

View network card information

copy code
[root@localhost network-scripts]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.81.128  netmask 255.255.255.0  broadcast 192.168.81.255
        inet6 fe80::20c:29ff:fe5b:1a46  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:5b:1a:46  txqueuelen 1000  (Ethernet)
        RX packets 474  bytes 41909 (40.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 266  bytes 45987 (44.9 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 0  (Local Loopback)
        RX packets 6  bytes 564 (564.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6  bytes 564 (564.0 B)
        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 00:00:00:00:00:00  txqueuelen 0  (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


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325348084&siteId=291194637