ubuntu 18.04 配置静态ip参考:

sudo vim /etc/netplan/01-netcfg.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: no
      addresses: [10.1.100.18/24]
      gateway4: 10.1.100.1
      nameservers:
              addresses: [223.5.5.5]

ubuntu 20.04 配置静态ip参考:

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

network:
  ethernets:
    ens18:
      addresses:
      - 192.168.1.227/24
      gateway4: 192.168.1.1
      nameservers:
        addresses:
        - 8.8.8.8
        - 223.5.5.5
        search: []
  version: 2

ubuntu 22.04 配置静态ip参考(注意 routes及via 的位置):

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

network:
  ethernets:
    ens18:
      addresses:
      - 192.168.1.228/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses:
        - 8.8.8.8
        - 223.5.5.5
  version: 2
  • 启用网卡

    sudo netplan apply

Copyright © https://yan-jian.com 2023 all right reserved更新时间: 2023-12-13 16:45:59

results matching ""

    No results matching ""