Little Girl's Mostly Linux Blog

NFSUseCase


NFS Use Case

This page was last updated on December 28, 2011.

Introduction

  • This document is a use case example with three computers.
  • The steps in this use case coincide with the steps in my fully commented NFS guide.
  • The example is of a family with three computers.
  • Sally has a computer.
  • Dave has a computer.
  • The two children share a computer.
  • All three computers are in different rooms in the same house.
  • The computers are connected by ethernet and are behind a hardware router.
  • Each computer has a static LAN IP.
  • The computers will use NFS to share certain directories with each other.

Meet the family:

Sally Dave The children

Creating the shares

Step 01 – The family writes down its computer information:

SALLY’S COMPUTER INFORMATION
192.168.1.100 Sally’s LAN IP address.
/home/sally/photos Sally wants to share this folder with Dave.
/home/sally/stories Sally wants to share this folder with the children.
/home/sally/daveshare Sally wants to click this folder to visit Dave’s computer.
/home/sally/childrenshare Sally wants to click this folder to visit the children’s computer.


DAVE’S COMPUTER INFORMATION
192.168.1.200 Dave’s LAN IP address.
/home/dave/work Dave wants to share this folder with Sally.
/home/dave/games Dave wants to share this folder with the children.
/home/dave/sallyshare Dave wants to click this folder to visit Sally’s computer.
/home/dave/childrenshare Dave wants to click this folder to visit the children’s computer.


THE CHILDREN’S COMPUTER INFORMATION
192.168.1.123 The children’s LAN IP address.
/home/children/homework The children want to share this folder with Sally.
/home/children/homework The children want to share this folder with Dave.
/home/children/momshare The children want to click this folder to visit Sally’s computer.
/home/children/dadshare The children want to click this folder to visit Dave’s computer.

Step 02 – The family creates mount points:

SALLY creates a mount point she can use to visit Dave’s computer:

mkdir /home/sally/daveshare

SALLY creates a mount point she can use to visit the children’s computer:

mkdir /home/sally/childrenshare



DAVE creates a mount point he can use to visit Sally’s computer:

mkdir /home/dave/sallyshare

DAVE creates a mount point he can use to visit the children’s computer:

mkdir /home/dave/childrenshare



THE CHILDREN create a mount point they can use to visit Sally’s computer:

mkdir /home/children/momshare

THE CHILDREN create a mount point they can use to visit Dave’s computer:

mkdir /home/children/dadshare


Step 03 – The family installs some software:

SALLY installs some packages:

sudo apt-get install nfs-kernel-server nfs-common portmap



DAVE installs some packages:

sudo apt-get install nfs-kernel-server nfs-common portmap



THE CHILDREN install some packages:

sudo apt-get install nfs-kernel-server nfs-common portmap


Step 04 – The family reconfigures the portmap:

SALLY reconfigures the portmap, saying NO when it asks if she’d like Portmap to bind to Loopback Interface:

sudo dpkg-reconfigure portmap



DAVE reconfigures the portmap, saying NO when it asks if he’d like Portmap to bind to Loopback Interface:

sudo dpkg-reconfigure portmap



THE CHILDREN reconfigure the portmap, saying NO when it asks if they’d like Portmap to bind to Loopback Interface:

sudo dpkg-reconfigure portmap


Step 05 – The family creates the hosts.deny file:




SALLY creates the hosts.deny file:

sudo touch /etc/hosts.deny

DAVE creates the hosts.deny file:

sudo touch /etc/hosts.deny

THE CHILDREN create the hosts.deny file:

sudo touch /etc/hosts.deny

Step 06 – The family creates the hosts.allow file:




SALLY creates the hosts.allow file:

sudo touch /etc/hosts.allow

DAVE creates the hosts.allow file:

sudo touch /etc/hosts.allow

THE CHILDREN create the hosts.allow file:

sudo touch /etc/hosts.allow

Step 07 – The family edits the hosts.deny file:

SALLY edits the hosts.deny file:

kdesudo kate /etc/hosts.deny

SALLY adds this line to the bottom of the file:

ALL: ALL



DAVE edits the hosts.deny file:

kdesudo kate /etc/hosts.deny

DAVE adds this line to the bottom of the file:

ALL: ALL



THE CHILDREN edit the hosts.deny file:

kdesudo kate /etc/hosts.deny

THE CHILDREN add this line to the bottom of the file:

ALL: ALL


Step 08 – The family edits the hosts.allow file:

SALLY edits the hosts.allow file:

kdesudo kate /etc/hosts.allow

SALLY adds these lines to the bottom of the file, making separate entries for all of the NFS software, with Dave’s IP and the children’s IP in each entry:

portmap: 192.168.1.200 192.168.1.123
lockd: 192.168.1.200 192.168.1.123
rquotad: 192.168.1.200 192.168.1.123
mountd: 192.168.1.200 192.168.1.123
statd: 192.168.1.200 192.168.1.123
nfsd: 192.168.1.200 192.168.1.123



DAVE edits the hosts.allow file:

kdesudo kate /etc/hosts.allow

DAVE adds these lines to the bottom of the file, making separate entries for all of the NFS software, with Sally’s IP and the children’s IP in each entry:

portmap: 192.168.1.100 192.168.1.123
lockd: 192.168.1.100 192.168.1.123
rquotad: 192.168.1.100 192.168.1.123
mountd: 192.168.1.100 192.168.1.123
statd: 192.168.1.100 192.168.1.123
nfsd: 192.168.1.100 192.168.1.123



THE CHILDREN edit the hosts.allow file:

kdesudo kate /etc/hosts.allow

THE CHILDREN add these lines to the bottom of the file, making separate entries for all of the NFS software, with Sally’s IP and Dave’s IP in each entry:

portmap: 192.168.1.100 192.168.1.200
lockd: 192.168.1.100 192.168.1.200
rquotad: 192.168.1.100 192.168.1.200
mountd: 192.168.1.100 192.168.1.200
statd: 192.168.1.100 192.168.1.200
nfsd: 192.168.1.100 192.168.1.200


Step 09 – The family edits the exports file:

SALLY edits the exports file:

kdesudo kate /etc/exports

SALLY adds this line to the bottom of the file to share photos with Dave:

/home/sally/photos 192.168.1.200(rw,sync,no_subtree_check)

SALLY adds this line to the bottom of the file to share stories with the children:

/home/sally/stories 192.168.1.123(rw,sync,no_subtree_check)



DAVE edits the exports file:

kdesudo kate /etc/exports

DAVE adds this line to the bottom of the file to share work with Sally:

/home/dave/work 192.168.1.100(rw,sync,no_subtree_check)

DAVE adds this line to the bottom of the file to share games with the children:

/home/dave/games 192.168.1.123(rw,sync,no_subtree_check)



THE CHILDREN edit the exports file:

kdesudo kate /etc/exports

THE CHILDREN add this line to the bottom of the file to share homework with Sally and Dave:

/home/children/homework 192.168.1.100(rw,sync,no_subtree_check) 192.168.1.200(rw,sync,no_subtree_check)


Step 10 – The family edits the fstab file:

SALLY edits the fstab file:

kdesudo kate /etc/fstab

SALLY adds this line to the bottom of the file so she can visit Dave’s share:

192.168.1.200:/home/dave/work /home/sally/daveshare nfs rw,hard,intr,noexec 0 0

SALLY adds this line to the bottom of the file so she can visit the children’s share:

192.168.1.123:/home/children/homework /home/sally/childrenshare nfs rw,hard,intr,noexec 0 0



DAVE edits the fstab file:

kdesudo kate /etc/fstab

DAVE adds this line to the bottom of the file so he can visit Sally’s share:

192.168.1.100:/home/sally/photos /home/dave/sallyshare nfs rw,hard,intr,noexec 0 0

DAVE adds this line to the bottom of the file so he can visit the children’s share:

192.168.1.123:/home/children/homework /home/dave/childrenshare nfs rw,hard,intr,noexec 0 0



THE CHILDREN edit the fstab file:

kdesudo kate /etc/fstab

THE CHILDREN add this line to the bottom of the file so they can visit Sally’s share:

192.168.1.100:/home/sally/stories /home/children/momshare nfs rw,hard,intr,noexec 0 0

THE CHILDREN add this line to the bottom of the file so they can visit Dave’s share:

192.168.1.200:/home/dave/games /home/children/dadshare nfs rw,hard,intr,noexec 0 0


Step 11 – The family edits the nfs-common file:

Step 12 – The family exports the shares:

SALLY exports her shares:

sudo exportfs -ar



DAVE exports his shares:

sudo exportfs -ar



THE CHILDREN export their shares:

sudo exportfs -ar


Step 13 – The family restarts the portmap:

SALLY restarts the portmap:

sudo service portmap restart



DAVE restarts the portmap:

sudo service portmap restart



THE CHILDREN restart the portmap:

sudo service portmap restart


Step 14 – The family restarts nfs-common:

SALLY restarts nfs-common:

sudo service idmapd restart



DAVE restarts nfs-common:

sudo service idmapd restart



THE CHILDREN restart nfs-common:

sudo service idmapd restart


Step 15 – The family restarts nfs-kernel-server:

SALLY restarts nfs-kernel-server:

sudo /etc/init.d/nfs-kernel-server restart



DAVE restarts nfs-kernel-server:

sudo /etc/init.d/nfs-kernel-server restart



THE CHILDREN restart nfs-kernel-server:

sudo /etc/init.d/nfs-kernel-server restart


Working with the shares

The family connects to the shares automatically:

SALLY reboots her computer.

If Dave’s computer is already booted, Sally will automatically be connected to Dave’s share.

If the children’s computer is already booted, Sally will automatically be connected to the children’s share.


DAVE reboots his computer.

If Sally’s computer is already booted, Dave will automatically be connected to Sally’s share.

If the children’s computer is already booted, Dave will automatically be connected to the children’s share.


THE CHILDREN reboot their computer.

If Sally’s computer is already booted, the children will automatically be connected to Sally’s share.

If Dave’s computer is already booted, the children will automatically be connected to Dave’s share.

The family connects to the shares manually:

SALLY manually connects to Dave’s share:

sudo mount /home/sally/daveshare

SALLY manually connects to the children’s share:

sudo mount /home/sally/childrenshare



DAVE manually connects to Sally’s share:

sudo mount /home/dave/sallyshare

DAVE manually connects to the children’s share:

sudo mount /home/dave/childrenshare



THE CHILDREN manually connect to Sally’s share:

sudo mount /home/children/momshare

THE CHILDREN manually connect to Dave’s share:

sudo mount /home/children/dadshare


The family uses the shares:

SALLY visits Dave’s share by opening her /home/sally/daveshare folder.

SALLY shares photos with Dave by putting them in her /home/sally/photos folder.

SALLY visits the children’s share by opening her /home/sally/childrenshare folder.

SALLY shares stories with the children by putting them in her /home/sally/stories folder.


DAVE visits Sally’s share by opening his /home/dave/sallyshare folder.

DAVE shares his work with Sally by putting them in his /home/dave/work folder.

DAVE visits the children’s share by opening his /home/dave/childrenshare folder.

DAVE shares games with the children by putting them in his /home/dave/games folder.


THE CHILDREN visit Sally’s share by opening their /home/children/momshare folder.

THE CHILDREN share their homework with Sally by putting it in their /home/children/homework folder.

THE CHILDREN visit Dave’s share by opening their /home/children/dadshare folder.

THE CHILDREN share their homework with Dave by putting it in their /home/children/homework folder.

The family disconnects from the shares:

SALLY stops visiting Dave’s share by disconnecting from it:

sudo umount /home/sally/daveshare

SALLY stops visiting the children’s share by disconnecting from it:

sudo umount /home/sally/childrenshare



DAVE stops visiting Sally’s share by disconnecting from it:

sudo umount /home/dave/sallyshare

DAVE stops visiting the children’s share by disconnecting from it:

sudo umount /home/dave/childrenshare



THE CHILDREN stop visiting Sally’s share by disconnecting from it:

sudo umount /home/children/momshare

THE CHILDREN stop visiting Dave’s share by disconnecting from it:

sudo umount /home/children/dadshare


Examples

These examples show only the relevant information that pertains to NFS. Some files on your computer (like the /etc/fstab file, for instance) may contain more than what is shown here.

/etc/network/interfaces

SALLY’S /etc/network/interfaces file:

auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0

auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1


DAVE’S /etc/network/interfaces file:

auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0

auto eth0
iface eth0 inet static
address 192.168.1.200
netmask 255.255.255.0
gateway 192.168.1.1

THE CHILDREN’S /etc/network/interfaces file:

auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0

auto eth0
iface eth0 inet static
address 192.168.1.123
netmask 255.255.255.0
gateway 192.168.1.1

/etc/default/portmap

SALLY’S /etc/default/portmap file:

# Portmap configuration file
#
# Note: if you manually edit this configuration file,
# portmap configuration scripts will avoid modifying it
# (for example, by running 'dpkg-reconfigure portmap').

# If you want portmap to listen only to the loopback
# interface, uncomment the following line (it will be
# uncommented automatically if you configure this
# through debconf).
#OPTIONS="-i 127.0.0.1"


DAVE’S /etc/default/portmap file:

# Portmap configuration file
#
# Note: if you manually edit this configuration file,
# portmap configuration scripts will avoid modifying it
# (for example, by running 'dpkg-reconfigure portmap').

# If you want portmap to listen only to the loopback
# interface, uncomment the following line (it will be
# uncommented automatically if you configure this
# through debconf).
#OPTIONS="-i 127.0.0.1"

THE CHILDREN’S /etc/default/portmap file:

# Portmap configuration file
#
# Note: if you manually edit this configuration file,
# portmap configuration scripts will avoid modifying it
# (for example, by running 'dpkg-reconfigure portmap').

# If you want portmap to listen only to the loopback
# interface, uncomment the following line (it will be
# uncommented automatically if you configure this
# through debconf).
#OPTIONS="-i 127.0.0.1"

/etc/hosts.deny

SALLY’S /etc/hosts.deny file:

ALL: ALL:\


DAVE’S /etc/hosts.deny file:

ALL: ALL:\

THE CHILDREN’S /etc/hosts.deny file:

ALL: ALL:\

/etc/hosts.allow

SALLY’S /etc/hosts.allow file:

portmap: 192.168.1.200 192.168.1.123
lockd: 192.168.1.200 192.168.1.123
rquotad: 192.168.1.200 192.168.1.123
mountd: 192.168.1.200 192.168.1.123
statd: 192.168.1.200 192.168.1.123
nfsd: 192.168.1.200 192.168.1.123


DAVE’S /etc/hosts.allow file:

portmap: 192.168.1.100 192.168.1.123
lockd: 192.168.1.100 192.168.1.123
rquotad: 192.168.1.100 192.168.1.123
mountd: 192.168.1.100 192.168.1.123
statd: 192.168.1.100 192.168.1.123
nfsd: 192.168.1.100 192.168.1.123

THE CHILDREN’S /etc/hosts.allow file:

portmap: 192.168.1.100 192.168.1.200
lockd: 192.168.1.100 192.168.1.200
rquotad: 192.168.1.100 192.168.1.200
mountd: 192.168.1.100 192.168.1.200
statd: 192.168.1.100 192.168.1.200
nfsd: 192.168.1.100 192.168.1.200

/etc/exports

SALLY’S /etc/exports file:

/home/sally/photos 192.168.1.200(rw,sync,no_subtree_check)
/home/sally/stories 192.168.1.123(rw,sync,no_subtree_check)


DAVE’S /etc/exports file:

/home/dave/work 192.168.1.100(rw,sync,no_subtree_check)
/home/dave/games 192.168.1.123(rw,sync,no_subtree_check)

THE CHILDREN’S /etc/exports file:

/home/children/homework 192.168.1.100(rw,sync,no_subtree_check) 192.168.1.200(rw,sync,no_subtree_check)

/etc/fstab

SALLY’S /etc/fstab file:

192.168.1.200:/home/dave/work /home/sally/daveshare nfs rw,hard,intr,noexec 0 0
192.168.1.123:/home/children/homework /home/sally/childrenshare nfs rw,hard,intr,noexec 0 0


DAVE’S /etc/fstab file:

192.168.1.100:/home/sally/photos /home/dave/sallyshare nfs rw,hard,intr,noexec 0 0
192.168.1.123:/home/children/homework /home/dave/childrenshare nfs rw,hard,intr,noexec 0 0

THE CHILDREN’S /etc/fstab file:

192.168.1.100:/home/sally/stories /home/children/momshare nfs rw,hard,intr,noexec 0 0
192.168.1.200:/home/dave/games /home/children/dadshare nfs rw,hard,intr,noexec 0 0

/etc/default/nfs-common

SALLY’S /etc/default/nfs-common file:

# If you do not set values for the NEED_ options, they will be attempted
# autodetected; this should be sufficient for most people. Valid alternatives
# for the NEED_ options are "yes" and "no".

# Do you want to start the statd daemon? It is not needed for NFSv4.
NEED_STATD=

# Options for rpc.statd.
#   Should rpc.statd listen on a specific port? This is especially useful
#   when you have a port-based firewall. To use a fixed port, set this
#   this variable to a statd argument like: "--port 4000 --outgoing-port 4001".
#   For more information, see rpc.statd(8) or http://wiki.debian.org/?SecuringNFS
STATDOPTS=

# Do you want to start the idmapd daemon? It is only needed for NFSv4.
NEED_IDMAPD=yes

# Do you want to start the gssd daemon? It is required for Kerberos mounts.
NEED_GSSD=no


DAVE’S /etc/default/nfs-common file:

# If you do not set values for the NEED_ options, they will be attempted
# autodetected; this should be sufficient for most people. Valid alternatives
# for the NEED_ options are "yes" and "no".

# Do you want to start the statd daemon? It is not needed for NFSv4.
NEED_STATD=

# Options for rpc.statd.
#   Should rpc.statd listen on a specific port? This is especially useful
#   when you have a port-based firewall. To use a fixed port, set this
#   this variable to a statd argument like: "--port 4000 --outgoing-port 4001".
#   For more information, see rpc.statd(8) or http://wiki.debian.org/?SecuringNFS
STATDOPTS=

# Do you want to start the idmapd daemon? It is only needed for NFSv4.
NEED_IDMAPD=yes

# Do you want to start the gssd daemon? It is required for Kerberos mounts.
NEED_GSSD=no

THE CHILDREN’S /etc/default/nfs-common file:

# If you do not set values for the NEED_ options, they will be attempted
# autodetected; this should be sufficient for most people. Valid alternatives
# for the NEED_ options are "yes" and "no".

# Do you want to start the statd daemon? It is not needed for NFSv4.
NEED_STATD=

# Options for rpc.statd.
#   Should rpc.statd listen on a specific port? This is especially useful
#   when you have a port-based firewall. To use a fixed port, set this
#   this variable to a statd argument like: "--port 4000 --outgoing-port 4001".
#   For more information, see rpc.statd(8) or http://wiki.debian.org/?SecuringNFS
STATDOPTS=

# Do you want to start the idmapd daemon? It is only needed for NFSv4.
NEED_IDMAPD=yes

# Do you want to start the gssd daemon? It is required for Kerberos mounts.
NEED_GSSD=no


Obligatory Happy Ending

And they all lived happily ever after. The end.

Back to top

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: WordPress Classic. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.