设置静态IP
修改网络配置文件
sudo vi /etc/netplan/50-cloud-init.yaml
设置IP地址为 192.168.1.126, 子网掩码24位即255.255.255.0, 网关为192.168.1.1, DNS1: 233.5.5.5, DNS2: 8.8.8.8
network: {config: disabled}network:ethernets:eth0:dhcp4: noaddresses: [192.168.1.126/24]optional: truegateway4: 192.168.1.1nameservers:addresses: [114.114.114.114,8.8.8.8]version: 2
运行命令应用新配置,立即生效
sudo netplan apply