一、
bash
ip address
sudo nano /etc/netplan/50-cloud-init.yaml
修改前:
修改后:
bash
====================================================================
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. 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:
enp0s3:
dhcp4: no
addresses: [192.168.31.142/24]
optional: true
routes:
- to: default
via: 192.168.31.1
nameservers:
addresses: [114.114.114.114,8.8.8.8]
version: 2
====================================================================
bash
sudo netplan apply #生效