ubuntu20.04设置静态IP
需要新建或修改现有配置文件:
sudo vim /etc/netplan/01-network-manager-all.yaml
获取本机IP地址和网卡名称:
ip addr #或者ifconfig (后者需要安装net-tools)
内容如下:
#Let NetworkManager manage all devices on this system network:
version: 2
renderer: NetworkManager
ethernets:
eno1: #配置的网卡名称
addresses: [192.168.36.19/24] #设置本机IP及掩码
gateway4: 192.168.36.254 #前三段需要跟IP一致,最后一段随意
nameservers: addresses: [61.134.1.4,159.226.8.7,218.30.19.40] #设置DNS