NetworkManager 如何决定默认配置文件?

NetworkManager 如何决定默认配置文件?
rg "Wired connection 1" /var/log/messages

1932:May  5 13:47:58 localhost NetworkManager[540]: <info>  [1714884478.7331] settings: (enp0s3): created default wired connection 'Wired connection 1'
1949:May  5 13:47:59 localhost NetworkManager[540]: <info>  [1714884479.0191] policy: auto-activating connection 'Wired connection 1' (2d5f9259-0521-3381-8da8-2ee6c0c27f47)
1951:May  5 13:47:59 localhost NetworkManager[540]: <info>  [1714884479.0248] device (enp0s3): Activation: starting connection 'Wired connection 1' (2d5f9259-0521-3381-8da8-2ee6c0c27f47)
1965:May  5 13:47:59 localhost NetworkManager[540]: <info>  [1714884479.7903] policy: set 'Wired connection 1' (enp0s3) as default for IPv4 routing and DNS

我找不到任何提及“有线连接 1”的配置文件。以下内容没有任何结果。

find /etc/NetworkManager/ -name "*.nmconnection" -exec grep -l "Wired connection 1" {} \;

即使我在整个根文件系统中搜索连接 ID,也找不到任何东西:

rg -l "2d5f9259-0521-3381-8da8-2ee6c0c27f47" /
/var/lib/NetworkManager/timestamps
/var/log/messages

NetworkManager 如何知道 enp0s3 接口上启用了 DHCP?它是否保存在某个密钥路径为“/org/freedesktop/NetworkManager/ActiveConnection/4”的秘密文件中?

nmcli dev show

GENERAL.DEVICE:                         enp0s3
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         08:00:27:D2:61:6D
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     Wired connection 1
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/4
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         192.168.0.121/24
IP4.GATEWAY:                            192.168.0.1
IP4.ROUTE[1]:                           dst = 192.168.0.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[2]:                           dst = 0.0.0.0/0, nh = 192.168.0.1, mt = 100
IP4.DNS[1]:                             192.168.0.1

GENERAL.DEVICE:                         lo
GENERAL.TYPE:                           loopback
GENERAL.HWADDR:                         00:00:00:00:00:00
GENERAL.MTU:                            65536
GENERAL.STATE:                          100 (connected (externally))
GENERAL.CONNECTION:                     lo
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/1
IP4.ADDRESS[1]:                         127.0.0.1/8
IP4.GATEWAY:                            --

答案1

NetworkManager 如何决定默认配置文件?

如果不存在,它会自动创建一个配置文件,并选择 DHCP 作为方法。请参阅no-auto-defaultNetworkManager.conf(5) 手册页中的描述。配置文件将保留在内存中,直到被修改,此时它将被写入磁盘。

NetworkManager 如何知道 enp0s3 接口上启用了 DHCP?

事实并非如此。假设DHCP 已启用,这是默认选择。

它是否保存在关键路径为“/org/freedesktop/NetworkManager/ActiveConnection/4”的某个秘密文件中?

没有配置文件的有线连接应该自动获取 DHCP 配置文件的假设被嵌入在 /usr/bin/NetworkManager 二进制文件中,作为编译代码的一部分。

相关内容