加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

网络 – Linux命名空间:网络命名空间是否可以存在而不与进程相

发布时间:2020-12-16 03:32:40 所属栏目:安全 来源:网络整理
导读:ip netns创建对/ var / run / ns中的(命名)网络命名空间的引用,可以轻松跟踪它.同样,也可以通过/ proc / [pid] / ns / net来确定.然而,一些自定义程序可能创建一个网络ns,并将相应的inode保存在其他非常规位置.这可能使得难以确定是否存在可以列出的净值. 其

ip netns创建对/ var / run / ns中的(命名)网络命名空间的引用,可以轻松跟踪它.同样,也可以通过/ proc / [pid] / ns / net来确定.然而,一些自定义程序可能创建一个网络ns,并将相应的inode保存在其他非常规位置.这可能使得难以确定是否存在可以列出的净值.

其次,取消共享< cmd>当进程退出时,会损坏网络,这很好.但是,ip netns exec< netns> < CMD>即使在命令/进程退出后也会保持ns.所以我相信,任何自定义程序都可以这样做.

因此,问题是:自定义程序是否可能创建一个未命名的网络ns,并且与任何进程保持不相关?

此外,鉴于我们不知道inode的路径,是否可以从用户空间中列出这样的(隐藏)网络ns? (内核当然有一个net ns的链表)一个代码段将是有帮助的.

最佳答案

Is it possible that a custom program creates an unnamed net ns,and it is left unassociated with any process?

是的,这是可能的.根据Linux命名空间手册页(http://man7.org/linux/man-pages/man7/namespaces.7.html):

Each process has a /proc/[pid]/ns/ subdirectory containing one entry
for each namespace that supports being manipulated by setns(2):

Bind mounting (see mount(2)) one of the files in this directory to
somewhere else in the filesystem keeps the corresponding namespace of
the process specified by pid alive even if all processes currently in
the namespace terminate.

关于另一个问题:

is it possible to list out such (hidden) net ns from user-space,given that we do not know the paths to the inodes?

如果您从第一个问题考虑上述引用,通过检查绑定路径,您应该可以找到这些隐藏的命名空间.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读