44.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
表示该模式已启用。
其他资源
-
您系统上的
nmstatectl (8)
手册页 -
/usr/share/doc/nmstate/examples/
目录