1.编辑 /etc/netplan/50-cloud-init.yaml 文件(注意:该文件是 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:
ens33:
dhcp4: no
dhcp6: no
addresses: [192.168.101.55/24]
gateway4: 192.168.101.1
nameservers:
addresses: [114.114.114.114]
version: 2
2.执行命令生效
netplan apply