rpc.mountd
, rpc.statd
e lockd
. Questi servizi usano in maniera predefinita una porta casuale (assegnata dal portmapper): questo rende difficoltoso filtrare il traffico indirizzato a questi servizi. Gli amministratori della Falcot Corporation hanno trovato una soluzione a questo problema, di seguito descritta.
/etc/init.d/nfs-kernel-server
e /etc/init.d/nfs-common
. Forniscono opzioni di configurazione per forzare le porte: i file importanti da modificare per utilizzare sempre queste opzioni sono /etc/default/nfs-kernel-server
e /etc/default/nfs-common
.
Esempio 11.22. Il file /etc/default/nfs-kernel-server
# 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 --port 2048" # 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= # Options for rpc.svcgssd. RPCSVCGSSDOPTS=
Esempio 11.23. Il file /etc/default/nfs-common
# 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="--port 2046 --outgoing-port 2047" # Do you want to start the idmapd daemon? It is only needed for NFSv4. NEED_IDMAPD= # Do you want to start the gssd daemon? It is required for Kerberos mounts. NEED_GSSD=
rpc.mountd
utilizzerà la porta 2048 mentre rpc.statd
si porrà in ascolto sulla porta 2046 ed utilizzerà la porta 2047 per le connessioni in uscita.
lockd
è gestito da un thread del kernel (processo leggero): questa funzionalità è compilata come modulo nei kernel Debian. Il modulo ha due opzioni che permettono di scegliere sempre la stessa porta: nlm_udpport
e nlm_tcpport
. Per far sì che queste opzioni siano usate sistematicamente dev'esserci un file /etc/modprobe.d/lockd
simile a quello che segue:
/etc/exports
, elenca le directory che vengono rese disponibili attraverso la rete (esportate). Per ogni condivisione NFS l'accesso è garantito solo alla lista di macchine fornita. Un controllo degli accessi più accurato può essere ottenuto con qualche opzione. La sintassi di questo file è piuttosto semplice:
/directory/to/share machine1(option1,option2,...) machine2(...) ...
*.falcot.com
o un intervallo di indirizzi IP come 192.168.0.0/255.255.255.0
o 192.168.0.0/24
.
ro
). L'opzione rw
permette l'accesso in lettura e scrittura. I client NFS si connettono tipicamente da una porta riservata a root (in altre parole inferiore a 1024): questa restrizione può essere sospesa con l'opzione insecure
(l'opzione secure
è implicita ma può essere resa esplicita, se necessario, per rendere le cose più chiare).
sync
): questo comportamento può essere disabilitato con l'opzione async
. La scrittura asincrona può aumentare un po' le prestazioni ma diminuisce l'affidabilità poiché c'è il rischio di perdere dati nel caso in cui il server subisca un crash tra la conferma di scrittura e la reale scrittura sul disco. Poiché il valore predefinito è cambiato recentemente (rispetto al valore storico di NFS) è raccomandato di rendere esplicita questa impostazione.
nobody
user. This behavior corresponds to the root_squash
option, and is enabled by default. The no_root_squash
option, which disables this behavior, is risky and should only be used in controlled environments. The anonuid=uid
and anongid=gid
options allow specifying another fake user to be used instead of UID/GID 65534 (which corresponds to user nobody
and group nogroup
).
/etc/fstab
e alla sintassi del comando mount
.
Esempio 11.25. Montare manualmente con il comando mount
#
mount -t nfs -o rw,nosuid arrakis.internal.falcot.com:/srv/shared /shared
Esempio 11.26. Condivisione NFS nel file /etc/fstab
arrakis.internal.falcot.com:/srv/shared /shared nfs rw,nosuid 0 0
/srv/shared/
NFS directory from the arrakis
server into the local /shared/
directory. Read-write access is requested (hence the rw
parameter). The nosuid
option is a protection measure that wipes any setuid
or setgid
bit from programs stored on the share. If the NFS share is only meant to store documents, another recommended option is noexec
, which prevents executing programs stored on the share.