如何获取 netplan match 的驱动程序 udev 属性?

如何获取 netplan match 的驱动程序 udev 属性?

我想match在我的 netplan 配置中使用,但如果我将 vlan 连接到接口,我就不能再仅通过该接口的 mac 地址进行匹配。请参阅netplan – 仅匹配物理 ifs

match提出的解决方案是driver以及macaddress

来自netplan 文档

match (mapping)
This selects a subset of available physical devices by various hardware
properties. The following configuration will then apply to all matching
devices, as soon as they appear. All specified properties must match.

name (scalar)
...
macaddress (scalar)
...
driver (scalar or sequence of scalars) – sequence since 0.104
Kernel driver name, corresponding to the DRIVER udev property.
A sequence of globs is supported, any of which must match.
Matching on driver is only supported with networkd.

所以我需要知道 DRIVER udev 属性。但我在哪里可以找到它?

我发现udev_device_get_driver但我从未使用过这样的 C 头文件,而且我不确定我会给它什么输入(struct udev_device *udev_device

答案1

查看你的接口并在 netplan 中ip a找到你想要的接口。match

该接口的名称应为$NAME

udevadm info -a /sys/class/net/$NAME

其输出内容应该为:

looking at device /devices/.../foo/net/$NAME

其已DRIVER定义为空字符串。

进而looking at parent device /devices/.../foo

已经DRIVER定义。这是您可以在 netplan 配置中参考的内容。

相关内容