首页 > 解决方案 > 在容器中,脚本需要添加一个路由,但它失败并出现错误 :ip: RTNETLINK answers: Operation not allowed

问题描述

该脚本必须在容器中添加路由,但路由添加命令失败并出现以下错误。

ip: RTNETLINK answers: Operation not permitted

上述命令以非 root 用户身份运行

bash-5.1$ /sbin/ip route add 9.0.0.0/8 via 10.196.226.1 dev eth0
ip: RTNETLINK answers: Operation not permitted
bash-5.1$ id
uid=(p2-user) 
bash-5.1$ exit
exit

当我们以 root 身份运行相同的命令时,出现错误。

/ # /sbin/ip route add 9.0.0.0/8 via 10.196.226.1 dev eth0
ip: RTNETLINK answers: File exists

标签: linuxbashnetwork-programmingcontainersnic

解决方案


推荐阅读