Debian 12 默认使用的是 ifupdown 来管理网络连接, netplan 是Ubuntu用于管理网络的工具,相较于 ifupdown 会更为直观一些

首先安装 netplan

sudo apt-get update
sudo apt-get install netplan.io openvswitch-switch

查看一下当前的网络配置,我的配置如下

chancel@j3455 /etc/network$ cat interfaces                                                                                                                      
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug enp1s0
iface enp1s0 inet dhcp
iface enp1s0 inet6 auto

根据上面的网络情况,编辑:/etc/netplan/01-netcfg.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0:
      dhcp4: yes
      dhcp6: yes

修改文件权限,并允许 netplan 的组件服务 systemd-networkdopenvswitch-switch 启动

sudo chmod 600 /etc/netplan/01-netcfg.yaml
sudo systemctl enable --now systemd-networkd
sudo systemctl enable --now openvswitch-switch

然后启用 netplan 来管理

sudo netplan apply

请注意,这将停用你的 /etc/network/interfaces 文件