ubuntu22.04 静态IP设置

1设置IP

sudo vi /etc/netplan/01-network-manager-all.yaml

network:
  ethernets:
    ibs2:
      dhcp4: no
      dhcp6: no
      addresses:
         - 192.168.25.103/24
      routes:
          - to: default
            via: 192.168.25.1
      nameservers:
          addresses:
                - 255.255.255.0
                - 8.8.8.8
    ens4f0:
      dhcp4: no
      dhcp6: no
      addresses:
         - 192.168.1.154/24
      routes:
          - to: default
            via: 192.168.1.1
      nameservers:
          addresses:
                - 255.255.255.0
                - 8.8.8.8
    ens4f1:
      dhcp4: no
      dhcp6: no
      addresses:
         - 192.168.11.154/24
      routes:
          - to: default
            via: 192.168.11.1
      nameservers:
          addresses:
                - 255.255.255.0
                - 8.8.8.8
    ens4f2:
      dhcp4: no
      dhcp6: no
      addresses:
         - 192.168.12.154/24
      routes:
          - to: default
            via: 192.168.12.1
      nameservers:
          addresses:
                - 255.255.255.0
                - 8.8.8.8
    ens4f3:
      dhcp4: no
      dhcp6: no
      addresses:
         - 192.168.25.71/24
      optional: true
      gateway4: 192.168.25.254
      routes:
          - to: default
            via: 192.168.25.254
      nameservers:
          addresses:
                - 192.168.2.9
                - 192.168.2.8

  version: 2
  renderer: networkd

2应用

sudo netplan apply

你可能感兴趣的:(c++,linux)