How to set an NFS network?
Lets say that «boris» is my logon such as /home/boris
is my home folder.
1. set the «server» computer:
-
install nfs-kernel-server and nfs-common
$ sudo apt-get install nfs-kernel-server $ sudo apt-get install nfs-common
-
in
/etc/exports
, define the folder to be shared by adding this:/home/boris 192.168.1.0/24(rw,sync,all_squash,anonuid=1001,anongid=1001,subtree_check)
with:
/home/boris
is the folder to be sharedrw
for read and write access of the clientsync
??all_squash
??192.168.1.0/24
is a range of client computer IP address of your local network1001
is the user and group ID. To find it$ id boris
-
manage hosts, 1st allow nobody in
/etc/hosts.deny
addportmap:ALL nfsd:ALL mountd:ALL
Then allow your client computer in
/etc/hosts.allow
addportmap:192.168.1.0/24 lockd:192.168.1.0/24 nfsd:192.168.1.0/24 mountd:192.168.1.0/24 rquotad:192.168.1.0/24 statd:192.168.1.0/24
with
192.168.1.0/24
is a range of client computer IP address of your local network -
set the firewall UFW
$ sudo ufw enable $ sudo ufw default deny incoming $ sudo ufw default deny outgoing $ sudo ufw allow from 192.168.1.0/24 $ sudo ufw allow out from 192.168.1.0/24
with
192.168.1.0/24
is a range of client computer IP address of your local network -
start the server
$ sudo /etc/init.d/nfs-kernel-server start
or after a modification of /etc/exports
$ sudo /etc/init.d/nfs-kernel-server restart
2. set the «client» computer:
-
install nfs-common and autofs
$ sudo apt-get install nfs-common $ sudo apt-get install autofs
-
create the folder used to mount the connection with the server
$ sudo mkdir /media/shareFolder
-
set autofs to automatically mount this folder,
in/etc/auto.master
add this line:/media/shareFolder /etc/auto.nfs --ghost, --timeout=60
in
/etc/auto.nfs
add this lineboris -fstype=nfs,rw,intr,uid=1001,guid=1001 192.168.1.1:/home/boris
with:
192.168.1.1
is the address of server computer/home/boris
is the folder shared on server computer.1001
is the user and group ID. To find it$ id boris
rw
for read and write access -
set the firewall UFW
$ sudo ufw enable $ sudo ufw default deny incoming $ sudo ufw default deny outgoing $ sudo ufw allow to 192.168.1.1 $ sudo ufw allow out to 192.168.1.1
with
192.168.1.1
is the address of the server computer and reboot your client computer.