方法一: 在安装系统的时候配置: 修改内核选项:net.ifnames=0 biosdevname=0
方法二: 1.重命名网卡名称为ifcfg-eth0
- [root@k8s-1 ~]# cd /etc/sysconfig/network-scripts/
- [root@k8s-1 ~]# ls
- [root@k8s-1 ~]# mv ifcfg-ens33 ifcfg-eth0
2.编辑网卡信息
- [root@k8s-1 ~]# vi ifcfg-eth0
- [root@k8s-1 ~]#
# 将name修改为eth0
- TYPE="Ethernet"
- BOOTPROTO=static
- 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="b7e7563a-8883-459d-b77d-d99447a4109d"
- DEVICE="ens33"
- ONBOOT="yes"
- DNS1=222.222.222.222
- IPADDR=10.128.25.211
- PREFIX=24
- GATEWAY=10.128.25.1
- IPV6_PEERDNS=yes
- IPV6_PEERROUTES=yes
3.修改grub 将第5行修改为: GRUB_CMDLINE_LINUX="crashkernel=auto rhgb net.ifnames=0 biosdevname=0 quiet",如下:
[root@k8s-1 sysconfig]# pwd /etc/sysconfig [root@k8s-1 sysconfig]# cat 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 net.ifnames=0 biosdevname=0 quiet" GRUB_DISABLE_RECOVERY="true" [root@k8s-1 sysconfig]#
然后生成启动菜单:
- [root@k8s-1 sysconfig]# grub2-mkconfig -o /boot/grub2/grub.cfg
- [root@localhost sysconfig]# grub2-mkconfig -o /boot/grub2/grub.cfg
- Generating grub configuration file ...
- Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64
- Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img
- Found linux image: /boot/vmlinuz-0-rescue-df27ba1c4ecf4835b8dc3f809e32ef43
- Found initrd image: /boot/initramfs-0-rescue-df27ba1c4ecf4835b8dc3f809e32ef43.img
- done
- [root@k8s-1 sysconfig]#
4.重启系统并验证 用reboot或者init 6重启系统,然后输入下面命令验证。
- [root@k8s-1 ~]# ifconfig eth0
- eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
- inet 10.128.25.211 netmask 255.255.255.0 broadcast 10.128.25.255
- inet6 fe80::bd5e:6db1:1157:7fc8 prefixlen 64 scopeid 0x20<link>
- ether 00:0c:29:ce:97:9b txqueuelen 1000 (Ethernet)
- RX packets 140 bytes 13491 (13.1 KiB)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 98 bytes 14716 (14.3 KiB)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- [root@k8s-1 ~]#