Ubuntu22.04网络配置,静态IP配置

Ubuntu22.04网络配置,静态IP配置

一、查看默认配置

ms@moshui:~$ cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
  ethernets:
    enp0s5:
      dhcp4: true
  version: 2
ms@moshui:~$

二、配置静态IP

# This is the network config written by 'subiquity'
network:
  ethernets:
    enp0s5:
      dhcp4: true
    enp0s6:
      dhcp4: false
      addresses:
        - 198.168.0.22/24
      optional: true
      routes:
        - to: default
          via: 198.168.0.1
      nameservers:
        addresses: [198.168.0.1,8.8.8.8]
        search:
          - localhost
          - local
  version: 2

# This is the network config written by 'subiquity'
network:
  ethernets:
    enp0s5:
      dhcp4: true
    enp0s6:
      dhcp4: false
      addresses:
        - 198.168.0.22/24
      optional: true
      routes:
        - to: default
          via: 198.168.0.1
      nameservers:
        addresses:
          - 198.168.0.1
          - 8.8.8.8
        search:
          - localhost
          - local
  version: 2

三、应用生效

sudo netplan apply

你可能感兴趣的:(Ubuntu,linux,运维,服务器)