Skip to content

Ubuntu Tips ​

Ubuntu 20.04 Tips

Setting Up NFS ​

@ref: https://askubuntu.com/questions/103910/nfs-is-blocked-by-ufw-even-though-ports-are-opened

Open /etc/default/nfs-kernel-server file and change to RPCMOUNTDOPTS="-p 13025"

# Number of servers to start up
RPCNFSDCOUNT=8

# Runtime priority of server (see nice(1))
RPCNFSDPRIORITY=0

# Options for rpc.mountd.
# If you have a port-based firewall, you might want to set up
# a fixed port here using the --port option. For more information,
# see rpc.mountd(8) or http://wiki.debian.org/SecuringNFS
# To disable NFSv4 on the server, specify '--no-nfs-version 4' here
#RPCMOUNTDOPTS="--manage-gids"
RPCMOUNTDOPTS="-p 13025"

# Do you want to start the svcgssd daemon? It is only required for Kerberos
# exports. Valid alternatives are "yes" and "no"; the default is "no".
NEED_SVCGSSD=""

Add firewall rules

ufw allow from 192.168.1.0/24 to any port 111
ufw allow from 192.168.1.0/24 to any port 2049
ufw allow from 192.168.1.0/24 to any port 13025

Restart

systemctl restart nfs-kernel-server

Export a share Open /etc/exports and edit.

# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#

/mnt/downloads 220.128.228.237(insecure,rw,sync,no_subtree_check) 123.195.32.71(insecure,rw,sync,no_subtree_check)
/srv 220.128.228.237(insecure,rw,sync,no_subtree_check) 123.195.32.71(insecure,rw,sync,no_subtree_check)

Make sure to add insecure, otherwise mount will fail and say access denied

Besure to restart service after adding

systemctl restart nfs-kernel-server

Mount on Client ​

mount -t nfs -o nfsvers=4 server663.seedhost.eu:/mnt/downloads nfs-test

Debug ​

showmount -e <IP>