首先要安装netplan
这步很关键 sudo apt install netplan.io (不能用sudo apt install netplan 至少我没搞明白这个怎么用)
执行 netplan generate
然后创建文件 /etc/netplan/50-init.yaml
network:
version: 2
ethernets:
eth0:
dhcp4: no
dhcp6: no
addresses: [192.168.192.101/24]
gateway4: 192.168.192.1
nameservers:
addresses: [114.114.114.114, 8.8.8.8]
然后执行netplan apply
这样就配置好了静态IP