ubuntu server配置静态ip

ubuntu server的ip设置真是不太适应,每次都忘记

  • ubuntu 20.04
    sudo vim /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
  ethernets:
    enp0s3:
      addresses: [192.168.1.89/24]
      optional: true
      gateway4: 192.168.1.1
      nameservers:
        addresses: [192.168.1.1]
      dhcp4: no
  version: 2
  • ubuntu 22.04
network:
  ethernets:
    eth0:
      dhcp4: false
      addresses: [192.168.1.11/24]
      optional: true
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses: [192.168.1.1]
  version: 2

最后执行
sudo netplan apply

posted on 2022-05-10 22:56  ww2000e  阅读(443)  评论(0编辑  收藏  举报