2.12. 按接口名称,使用单个连接配置文件配置多个以太网接口
NetworkManager 支持将通配符用于连接配置文件中的接口名称。这可让您为多个以太网接口创建一个配置文件,这在带有动态 IP 地址分配的以太网网络间漫长时很有用。
先决条件
- 服务器配置中存在多个物理或虚拟以太网设备。
- 网络中有 DHCP 服务器。
- 主机上不存在连接配置文件。
流程
添加可应用于以
enp开头的所有接口名称的连接配置文件:nmcli connection add con-name "Wired connection 1" connection.multi-connect multiple match.interface-name enp type ethernet*
# nmcli connection add con-name "Wired connection 1" connection.multi-connect multiple match.interface-name enp type ethernet*Copy to Clipboard Copied! Toggle word wrap Toggle overflow
验证
显示单个连接配置文件的所有设置:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 3表示接口在特定的时间可以被多次激活。连接配置文件使用与match.interface-name参数中的模式匹配的所有设备,因此连接配置文件具有相同的通用唯一识别符(UUID)。显示连接的状态:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow