解决 Cilium 报错 bpf_host routing failed: device not found 网卡设备缺失修复
排查 开启 Cilium eBPF Host-Routing 模式后 cilium-agent 启动失败,报错 bpf_host: cannot find native device eth0,分析 devices 参数声明与多网卡环境。
问题现象
安装 Cilium 并开启 eBPF Host-Routing 后,Agent Pod 报错自杀:
level=fatal msg="Error while initializing daemon" error="Failed to determine native devices: device eth0 not found in system"
触发根因
- 宿主机的真实物理网卡名称为 Predictable 命名规则(如
ens192、bond0或enp3s0),而非传统的eth0; - Cilium 配置文件中显式硬编码了
devices: eth0,导致内核 TC 钩子程序无法绑定目标网卡。
解决步骤
检查当前宿主机承载主默认路由的物理网卡名称
执行命令核对:
ip route show default | awk '{print $5}'
假定输出为 ens192。
更新 Helm values 或 Cilium ConfigMap 指定正确设备
在 ConfigMap cilium-config 中修正:
devices: "ens192"
# 或者指定网卡前缀自动匹配:
# devices: "en+"
或者启用全自动设备嗅探机制
设置 devices: "" 让 Cilium 自动跟随默认路由出口设备。
验证确认
重启 cilium-agent Pod:
kubectl rollout restart ds/cilium -n kube-system
eBPF 程序成功附加至 ens192 的 ingress/egress clsact 钩子,网络直通性能就绪。


