博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
network namespace问题小结
阅读量:4055 次
发布时间:2019-05-25

本文共 1558 字,大约阅读时间需要 5 分钟。

场景描述:创建一个namespace  test,并分配一个veth 口到这个namespace里,veth的另一个口在默认namespace里,直接执行ip netns delete test

情况1:当这个ns中没有运行进程(此进程也没有使用这个ns里的veth口),删除后,ns删除,veth 两个口都会删除

情况2:当这个ns中有进程使用ns的veth口,删除后,默认ns中的veth还在,ns删除,ns里面的veth口删除(丢失了)。

 

通过man ip-netns信息可知

ip [-all] netns delete [ NAME ] - delete the name of a network namespace(s)              If NAME is present in /var/run/netns it is umounted and the mount point is removed. If this is the last user of the network namespace the network namespace will be freed and all physi‐              cal devices will be moved to the default one, otherwise the network namespace persists until it has no more users. ip netns delete may fail if the mount point is in use in another mount              namespace.              If -all option was specified then all the network namespace names will be removed.              It is possible to lose the physical device when it was moved to netns and then this netns was deleted with a running process:                 $ ip netns add net0                 $ ip link set dev eth0 netns net0                 $ ip netns exec net0 SOME_PROCESS_IN_BACKGROUND                 $ ip netns del net0              and eth0 will appear in the default netns only after SOME_PROCESS_IN_BACKGROUND will exit or will be killed. To prevent this the processes running in net0 should be killed before delet‐              ing the netns:                 $ ip netns pids net0 | xargs kill                 $ ip netns del net0

上面描述的是物理网卡的情况,意思是删除ns之前,要先杀掉运行在这个ns中的进程(这个进程可能正在使用ns的网络设备),然后删除ns,否则导致网卡丢失(物理网卡和虚拟网卡)。

转载地址:http://yfqci.baihongyu.com/

你可能感兴趣的文章
Golang struct 指针引用用法(声明入门篇)
查看>>
Linux 粘滞位 suid sgid
查看>>
C#控件集DotNetBar安装及破解
查看>>
Winform皮肤控件IrisSkin4.dll使用
查看>>
Winform多线程
查看>>
C# 托管与非托管
查看>>
Node.js中的事件驱动编程详解
查看>>
mongodb 命令
查看>>
MongoDB基本使用
查看>>
mongodb管理与安全认证
查看>>
nodejs内存控制
查看>>
nodejs Stream使用中的陷阱
查看>>
MongoDB 数据文件备份与恢复
查看>>
数据库索引介绍及使用
查看>>
MongoDB数据库插入、更新和删除操作详解
查看>>
MongoDB文档(Document)全局唯一ID的设计思路
查看>>
mongoDB简介
查看>>
Redis持久化存储(AOF与RDB两种模式)
查看>>
memcached工作原理与优化建议
查看>>
Redis与Memcached的区别
查看>>