我最近在一个新存储上安装了 Debian 12.7,这是一个没有桌面环境的无头服务器。
我检查了Debian 的 NetworkConfiguration 文档,看到了以下内容:
配置网络的 4 种方法
- /etc/network/interfaces处的接口配置文件(本页):用于基本或简单配置(例如工作站)
- NetworkManager:这是笔记本电脑配置的默认设置
- Systemd:Debian 参考文档 第 5 章
- Netplan:Debian 参考文档第 5 章
现在我很困惑,因为我不明白哪些部分适用于我的安装。
系统使用默认配置,因此答案可能很简单,但假设我连接到一台我不认识的机器,并且我想识别网络配置。
如何识别 Debian(或其他 Linux 发行版)系统用于配置其网络堆栈的方式?
我的尝试
/etc/network/interfaces
文件存在:
root@serveur:~# cat /etc/network/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 enp2s0
iface enp2s0 inet dhcp
# This is an autoconfigured IPv6 interface
iface enp2s0 inet6 auto
网络管理器
该服务不存在:
root@serveur:~# service network-manager status
Unit network-manager.service could not be found.
系统化
存在一个文件,但其内容被注释:
root@serveur:~# ls -lrth /etc/systemd/network/
total 0
root@serveur:~# cat /etc/systemd/networkd.conf
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
# any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the networkd.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# See networkd.conf(5) for details.
[Network]
#SpeedMeter=no
#SpeedMeterIntervalSec=10sec
#ManageForeignRoutingPolicyRules=yes
#ManageForeignRoutes=yes
#RouteTable=
[DHCPv4]
#DUIDType=vendor
#DUIDRawData=
[DHCPv6]
#DUIDType=vendor
#DUIDRawData=
网络计划
没有配置:
root@serveur:~# ls -lrth /etc/netplan/
ls: cannot access '/etc/netplan/': No such file or directory
观察结果
该系统使用/etc/network/interfaces
Systemd 来配置网络?