莱因电博

Li-e.cn

Li Internet Electronic Blog
@rss

Ubuntu 22.04 配置 netplan

Configuring netplan on Ubuntu 22.04

————————————————————

Ubuntu 22.04 配置 netplan

在22.04版本中,gateway4的办法已经弃用,需要换成下面这种方式:

编辑配置文件:

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

改成下面这样:

network:
  ethernets:
    eth0:
      dhcp4: yes
      dhcp6: yes
    eth1:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.100.100/24]
      optional: true
      routes:
        - to: default
          via: 192.168.100.8
      nameservers:
          addresses: [192.168.8.8,114.114.114.114]
    eth2:
      dhcp4: yes
      dhcp6: no
      addresses: [10.10.0.1/24]
      optional: true
    eth3:
      dhcp4: yes
      dhcp6: no
      addresses: [10.10.1.1/24]
      optional: true
      
  version: 2
  renderer: networkd

应用网络配置:

sudo netplan apply
(C) 2019 - 2024 Li-e.cn莱因电博(立网电子博客) | Powered by Vercel , based on Hugo with Gists theme.