大网数据广告活动
服务器运维问答

How to define a NFS root in a discrete directory tree?

· 52CE 我爱测

I would like to setup a NFS-server for multiple docker containers and I found documentation on the archlinux-wiki . I thought of this project as an useful example to get to know NFS-configuration and it's security details. I am n…

问题原文

原帖链接 · Human · CC BY-SA 4.0

I would like to setup a NFS-server for multiple docker containers and I found documentation on the archlinux-wiki. I thought of this project as an useful example to get to know NFS-configuration and it's security details.

I am not sure what the following sentence means and how to do it.

A good security practice is to define a NFS root in a discrete directory tree which will keep users limited to that mount point.

Does that just mean to create a specific directory for the shared data and not have it accross multiple users home directory?

server OS: centos7 or 8

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

I think I know what's going on here and why the Arch wiki is confusing.

Ancient versions of NFS from back in the 1990s (version 3 and previous) could simply export arbitrary directories which were located anywhere in the filesystem. This changed with NFSv4, which requires all exported directories to be subdirectories of a top-level "root" export which is defined by the system administrator and carries the export option fsid=0 to distinguish it as the root. There is no predefined root; the admin makes an explicit choice to define the root.

Thus if you define /srv/nfs as the root, all other NFSv4 exports must be subdirectories of that directory.

However, it is likely that the directory you want to export is not actually under /srv/nfs. For example you may want to export /var/lib/docker/volumes. To do this, instead of moving the files around which might break things that depend on them being in their original location, you can create a bind mount so that the files remain in their original place in the filesystem but are also visible under the bind-mounted path.

mkdir /srv/nfs/volumes
mount --bind /var/lib/docker/volumes /srv/nfs/volumes

Now the files are available in both places in the filesystem tree, and because of that, NFSv4 can export them.

The only bit I am still confused about is why the Arch wiki calls it a "good security practice" when it is just how NFSv4 works.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-06-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。