Using NFS #
The Network File System, NFS, is used to share a filesystem over the network.
This section will go through the steps for a simple NFS setup. The example details a server on a LAN, with clients accessing NFS on the LAN. It does not cover securing NFS. We presume you have already set up packet filtering or other firewalling protection to prevent outside access.
Setting Up an NFS Server #
First, enable the portmap(8), mountd(8) and nfsd(8) services on the server:
# rcctl enable portmap mountd nfsd
Then configure the list of filesystems that will be made available. In this example, we have a server with IP address 10.0.0.1. This server will be serving NFS only to clients within its own subnet. This is configured in the following exports(5) file:
$ cat /etc/exports /docs -alldirs -ro -network=10.0.0 -mask=255.255.255.0
The local filesystem /docs will be made available via NFS. The -alldirs option specifies that clients will be able to mount at any point under /docs as well as /docs itself. The -ro option specifies that clients will only be granted read-only access. The last two arguments specify that only clients within the 10.0.0.0 network using a netmask of 255.255.255.0 will be authorized to mount this filesystem.
Now you can start the server services.
# rcctl start portmap mountd nfsd
If you make changes to /etc/exports while NFS is already running, you need to make mountd aware of this:
# rcctl reload mountd