修改配置文件

nano /etc/netplan/00-installer-config.yaml

源文件内容

# This is the network config written by 'subiquity'
network:
  ethernets:
    ens18:
      dhcp4: true
  version: 2

修改后内容

# This is the network config written by 'subiquity'
network:
  ethernets:
    ens18:
      dhcp4: false
      addresses: [192.168.31.7/24] #设置IP
      gateway4: 192.168.31.10  #设置网关
      nameservers:
        addresses: [192.168.31.10] #设置DNS
  version: 2

新配置生效

sudo netplan apply