1.在/etc/default/grub中,GRUB_CMDLINE_LINUX里添加参数net.ifnames=0 biosdevname=0,如下图所示:
然后再行执行update-grub命令,
update-grub
2.然后修改/etc/udev/rules.d/70-persistent-net.rules这个文件
vim /etc/udev/rules.d/70-persistent-net.rules
把下面这段代码加进去
# PCI device 0x14e4:0x1692 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="bc:30:5b:b1:cd:be", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
关键字解释:
ATTR{address}==“bc:30:5b:9c:ae:79” ##物理网卡MAC地址
KERNEL 原网卡名
NAME 现网卡名
3.最后修改/etc/netplan/50-cloud-init.yaml这个文件就行了
修改成下面的格式(格式一定要对齐)
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
ens32:
addresses: [192.168.1.47/24]
gateway4: 192.168.1.1
nameservers:
addresses: [114.114.114.114]
version: 2