menu Chancel's blog
rss_feed
Chancel's blog
有善始者实繁,能克终者盖寡。

debian12启用netplan来管理网络

作者:Chancel Yang, 创建:2024-05-24, 字数:1174, 已阅:609, 最后更新:2024-05-24

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

首先安装 netplan

Bash
sudo apt-get update
sudo apt-get install netplan.io

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

Bash
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

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

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

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

然后启用 netplan 来管理

Bash
sudo netplan apply

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


[[replyMessage== null?"发表评论":"发表评论 @ " + replyMessage.m_author]]

account_circle
email
web_asset
textsms

评论列表([[messageResponse.total]])

还没有可以显示的留言...
gravatar
[[messageItem.m_author]] [[messageItem.m_author]]
[[messageItem.create_time]]
[[getEnviron(messageItem.m_environ)]]
[[subMessage.m_author]] [[subMessage.m_author]] @ [[subMessage.parent_message.m_author]] [[subMessage.parent_message.m_author]]
[[subMessage.create_time]]
[[getEnviron(messageItem.m_environ)]]