nixos nfs: allow setting the lockd ports.

This helps in setting a fixed firewall open port for NFS lockd.

Based on:
http://rlworkman.net/howtos/NFS_Firewall_HOWTO

(cherry picked from commit b32ca0616ff70795f71995fa79ea508b82f30b3a)

Conflicts:
	nixos/modules/services/network-filesystems/nfsd.nix
This commit is contained in:
Lluís Batlle i Rossell 2014-10-15 10:56:41 +02:00
parent e9809e8f9e
commit f594033822

View File

@ -63,6 +63,12 @@ in
description = '' description = ''
Use fixed port for rpc.mountd, usefull if server is behind firewall. Use fixed port for rpc.mountd, usefull if server is behind firewall.
''; '';
lockdPort = mkOption {
default = 0;
description = ''
Fix the lockd port number. This can help setting firewall rules for NFS.
'';
}; };
}; };
@ -104,6 +110,9 @@ in
# Create a state directory required by NFSv4. # Create a state directory required by NFSv4.
mkdir -p /var/lib/nfs/v4recovery mkdir -p /var/lib/nfs/v4recovery
${pkgs.procps}/sbin/sysctl -w fs.nfs.nlm_tcpport=${builtins.toString cfg.lockdPort}
${pkgs.procps}/sbin/sysctl -w fs.nfs.nlm_udpport=${builtins.toString cfg.lockdPort}
rpc.nfsd \ rpc.nfsd \
${if cfg.hostName != null then "-H ${cfg.hostName}" else ""} \ ${if cfg.hostName != null then "-H ${cfg.hostName}" else ""} \
${builtins.toString cfg.nproc} ${builtins.toString cfg.nproc}