ubuntu22设置静态ip

好久不操作ubuntu,生疏了,今天需要用到ubuntu,遇到一些问题,记录下来

首先就是静态ip

cd /etc/netplan/


sudo vim /etc/netplan/00-installer-config.yaml

#修改内容如下

network:
  renderer: NetworkManager
  ethernets:
    ens33:
      addresses: [192.168.168.100/24]
      routes:
        - to: default
          via: 192.168.168.2
      nameservers:
        addresses:
          - 114.114.114.114
          - 8.8.8.8
          - 223.5.5.5
          - 223.6.6.6
  version: 2

如果没有NetworkManager,需要先安装NetworkManager

让配置生效

sudo netplan apply