Ubuntu Server – Configure ufw to nfs in alternative port

Ubuntu uses UFW, which is extremely easy to configure, yet very potent, at least for soho needs.
So, the rpc.mountd listens on multiple ports by default thus you have to bind rpc.mountd to one port, then you can add an additional UFW rule to accept incoming connection on that particular port.

To do so, open /etc/default/nfs-kernel-server and comment out the line


RPCMOUNTDOPTS=--manage-gids

and add the following line


RPCMOUNTDOPTS="-p 13030"

13030 is just a randomly selected port, something that is available and isn’t already defined in /etc/services.

Restart NFSd with sudo /etc/init.d/nfs-server-kernel restart

Now configure the UFW to accept incoming connections on port 13030, 2049 and port 111.


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

That’s it. You should now be able to mount your exports form another machine.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*