You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 20.04/22.04通过Netplan设置网卡promisc模式并重启生效的方法

在Ubuntu 20.04/22.04中设置网卡混杂模式并保持重启生效

在Ubuntu 20.04和22.04系统里,Netplan没有提供直接配置网卡混杂模式的参数,尝试过多种非服务/调度器的方案后,均无法实现重启后自动保留混杂模式的效果,最终验证仅能通过创建systemd服务来完成需求。

配置步骤

  1. 创建systemd服务配置文件
    创建/etc/systemd/system/nic-promisc.service文件,写入以下内容:
[Unit]
Description=Set promiscuous mode on network interface
After=network.target

[Service]
ExecStart=/sbin/ip link set dev eth0 promisc on

[Install]
WantedBy=default.target

注意:将eth0替换为你实际需要设置的网卡名称。

  1. 启用并启动服务
    执行以下命令让配置生效并设置开机自启:
sudo systemctl daemon-reload
sudo systemctl enable --now nic-promisc.service
  1. 验证配置
    执行命令查看网卡状态,确认混杂模式已启用:
ip link show eth0

如果输出中包含PROMISC字样,说明配置成功。

内容的提问来源于stack exchange,提问作者Kevin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 10:10:03