LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-18-2020, 07:15 AM   #1
supermario18b
LQ Newbie
 
Registered: Sep 2018
Posts: 18

Rep: Reputation: Disabled
NFSv4 - restrict access to exports by IP


Hi everyone,

since NFSv4 needs a root share folder, I set /media/nfs_root accessible from everyone and two child folders accessible from specific IPs.
Here is my /etc/exports file:

Code:
/media/nfs_root			*(fsid=0,sync,no_subtree_check) 
/media/nfs_root/nfs_child10	192.168.1.10(rw,sync,no_subtree_check)
/media/nfs_root/nfs_child20	192.168.1.20(rw,sync,no_subtree_check)
The unexpected result (for me) is that everyone can mount the root and the child directories.
I'd like that the machine with IP 192.168.1.10 can only access the nfs_child10 folder and the machine with IP 192.168.1.20 can only access the nfs_child20 folder.

How do I have to modify the configuration file to achieve that?


Thanks in advance,

supermario18b

Last edited by supermario18b; 09-18-2020 at 07:18 AM.
 
Old 09-18-2020, 07:32 PM   #2
dc.901
Senior Member
 
Registered: Aug 2018
Location: Atlanta, GA - USA
Distribution: CentOS/RHEL, openSuSE/SLES, Ubuntu
Posts: 1,005

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Working on RHEL7 and CentOS7, I do not see need for "nfs_root" like you have. Or maybe I am misunderstanding what you are trying to say.

Now, do the child directories nfs_child10/20 need to be under the nfs_root?
If not, what if you do something like this instead:

Code:
/media/nfs_root			*(fsid=0,sync,no_subtree_check) 
/media/nfs_child10	192.168.1.10(rw,sync,no_subtree_check)
/media/nfs_child20	192.168.1.20(rw,sync,no_subtree_check)
Then, perhaps make a symbolic links to nfs_child10/20 under nfs_root?
 
Old 09-19-2020, 02:11 AM   #3
supermario18b
LQ Newbie
 
Registered: Sep 2018
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by dc.901 View Post
Working on RHEL7 and CentOS7, I do not see need for "nfs_root" like you have
I followed the instructions on wiki.archlinux.org/NFS

By the way I tried like you said. It works without "nfs_root" and the fsid=0 option.
Here is the working configuration:

Code:
/media/nfs_child10		192.168.1.10(rw,sync,no_subtree_check)
/media/nfs_child20		192.168.1.20(rw,sync,no_subtree_check)
Thanks dc.901. I mark the thread as solved


Edit: Now as expected the ip 10 can only access the directory /media/nfs_child10 and the ip 20 can only access the directory /media/nfs_child20

Last edited by supermario18b; 09-19-2020 at 03:25 AM.
 
Old 09-19-2020, 02:53 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by supermario18b View Post
I followed the instructions on wiki.archlinux.org/NFS
I followed the same instructions, but I do not have a '*' in the first line - it lists the same IPs as for the subfolders:
Code:
/srv/nfs       n.n.n.0/24(rw,async,fsid=root,crossmnt,subtree_check)
/srv/nfs/html n.n.n.0/24(rw,async,no_subtree_check)
/srv/nfs/mus n.n.n.0/24(rw,async,no_subtree_check)
I forgot the logic of it all, but it works.
 
Old 09-19-2020, 03:18 AM   #5
supermario18b
LQ Newbie
 
Registered: Sep 2018
Posts: 18

Original Poster
Rep: Reputation: Disabled
What ondoho posted works but it's about to limit the access of the two folders by IP. In the example would be:

Code:
/srv/nfs       n.n.n.0/24(rw,async,fsid=root,crossmnt,subtree_check)
/srv/nfs/html n.n.n.10/32(rw,async,no_subtree_check)
/srv/nfs/mus n.n.n.20/32(rw,async,no_subtree_check)
According this configuration I expected that the ip 10 can only access the "html" directory and that the ip 20 can only access the mus directory.
The problem is both can access "html" and "mus". Probably because the nfs-root directory "nfs" allows the whole network.

Last edited by supermario18b; 09-19-2020 at 03:22 AM.
 
Old 09-19-2020, 03:47 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Sorry, I should've understood that.
I wonder if you can simply comment out / remove the first line?
 
Old 09-19-2020, 04:23 AM   #7
supermario18b
LQ Newbie
 
Registered: Sep 2018
Posts: 18

Original Poster
Rep: Reputation: Disabled
Nothing to be sorry about
Without the first line it works. It's the solution posted above (without the "nfs-root").
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Cannot mount nfsv4 exports xq10907 CentOS 10 09-01-2017 12:11 AM
NFSv4 and Kerberos - "access denied by server" gatsby Linux - Server 2 11-13-2012 12:22 AM
Does NFSv4 serve only files which are at least readable? (was: NFSv4 and SUID mount) Reuti Linux - Server 1 08-05-2011 04:13 PM
[SOLVED] NFS exports do not show up in /proc/fs/nfs/exports Gerard_2009 Linux - Server 2 09-07-2010 03:06 PM
LXer: NFSv4 Delivers Seamless Network Access LXer Syndicated Linux News 0 09-14-2006 11:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration