记录免忘
ls /etc/netplan/ 这里找个文件进行编辑,虽然网上说的是01-network-manager-all.yaml,但我用的是00-installer-config.yaml
把内容改为类似:
network:
ethernets:
enp0s3:
dhcp4: no
addresses: [192.168.0.180/24]
optional: true
gateway4: 192.168.0.1
nameservers:
addresses: [192.168.0.1,223.6.6.6]
version: 2
sudo netplan apply 生效
另外一个方法,适合于有此文件的环境
sudo nano /etc/network/interfaces
修改为类似以下
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
sudo /etc/init.d/networking restart 重启网络生效