47.3. 使用 nmstatectl 永久配置网络设备,以接受所有流量
使用 nmstatectl 工具配置设备,以接受所有流量,而不考虑通过 Nmstate API 的 MAC 地址。Nmstate API 确保设置配置后结果与配置文件匹配。如果有任何失败,nmstatectl 会自动回滚更改以避免系统处于不正确的状态。
先决条件
-
nmstate软件包已安装。 -
用于配置设备的
enp1s0.yml文件可用。
步骤
编辑
enp1s0连接的现有enp1s0.yml文件,并将以下内容添加到其中:--- interfaces: - name: enp1s0 type: ethernet state: up accept -all-mac-address: true这些设置将
enp1s0设备配置为接受所有流量。应用网络设置:
# nmstatectl apply ~/enp1s0.yml
验证
验证是否启用了
802-3-ethernet.accept-all-mac-addresses模式:# nmstatectl show enp1s0 interfaces: - name: enp1s0 type: ethernet state: up accept-all-mac-addresses: true ...802-3-ethernet.accept-all-mac-addresses: true表示该模式已启用。