NFS Server on Debian 6.0 squeeze

apt-get install nfs-common portmap nfs-kernel-server

vi /etc/exports:

/home 192.168.0.0/24(rw,sync,no_root_squash,no_subtree_check)

# *note /home ⇒ shared directory
#10.0.0.0/24 ⇒ range of networks NFS permits accesses
#rw ⇒ possible to read and write
#sync ⇒ synchronize
#no_root_squash ⇒ enable root privilege
#no_subtree_check ⇒ disable subtree check

IPTABLES:
-A INPUT -s 192.168.0.0/24 -d 192.168.0.1 -m state –state NEW -p udp –dport 111 -j ACCEPT
-A INPUT -s 192.168.0.0/24 -d 192.168.0.1 -m state –state NEW -p tcp –dport 111 -j ACCEPT
-A INPUT -s 192.168.0.0/24 -d 192.168.0.1 -m state –state NEW -p udp –dport 2049 -j ACCEPT
-A INPUT -s 192.168.0.0/24 -d 192.168.0.1 -m state –state NEW -p tcp –dport 2049 -j ACCEPT
-A INPUT -s 192.168.0.0/24 -d 192.168.0.1 -m state –state NEW -p udp –dport 32764:32769 -j ACCEPT
-A INPUT -s 192.168.0.0/24 -d 192.168.0.1 -m state –state NEW -p tcp –dport 32764:32769 -j ACCEPT

Дополнительная секурность
/etc/hosts.deny:
lockd:ALL
mountd:ALL
rquotad:ALL
statd:ALL

/etc/hosts.allow:
lockd: 192.168.0.1 , 192.168.0.2
rquotad: 192.168.0.1 , 192.168.0.2
mountd: 192.168.0.1 , 192.168.0.2
statd: 192.168.0.1 , 192.168.0.2

/etc/init.d/portmap start
/etc/init.d/nfs-kernel-server start
/etc/init.d/nfs-common start

Запускаем, проверяем (showmount -e 192.168.0.1). Да, не работает. А не работает, т.к. порты открываются старшие и хаотично. Смотрим что открыто rpcinfo -p. Нужно теперь все это хозяйство привести к виду –dport 32764:32769.
Открываем Debian SecuringNFS WIKI:

# /etc/default/nfs-common
STATDOPTS=”–port 32765 –outgoing-port 32766″

# /etc/default/nfs-kernel-server
RPCMOUNTDOPTS=”-p 32767″

# /etc/default/quota
RPCRQUOTADOPTS=”-p 32769″

# /etc/modprobe.d/local.conf
options lockd nlm_udpport=32768 nlm_tcpport=32768
options nfs callback_tcpport=32764

Все опять перегружаем. Для успокоения души смотрим, что порты открылись именно те, которые мы прописали в iptables’ах (rpcinfo -p).

Ссылки:
wikipedia.org (NFS)
http://wiki.debian.org/SecuringNFS
http://www.tldp.org/HOWTO/NFS-HOWTO/
http://www.tldp.org/HOWTO/NFS-HOWTO/security.html
http://www.tldp.org/HOWTO/NFS-HOWTO/server.html
http://24may.kharkov.ua/page65.html
http://www.crazysquirrel.com/computing/debian/servers/nfs.jspx
http://mohado.narod.ru/ru/nfs.html

Leave a comment

You must be logged in to post a comment.