FastNetMon

Thursday 20 January 2011

Как закрыть NFS сервер фаерволлом?

Нужно статически забить порты всех саб-сервисов NFS.

Открываем:
vi /etc/default/nfs-common

Правим:
STATDOPTS="--port 32765 --outgoing-port 32766"

Открываем:
vi /etc/default/nfs-kernel-server

Правим:
RPCMOUNTDOPTS="-p 32767"

Открываем:
vi /etc/modprobe.d/options.local

Правим:
options lockd nlm_udpport=32768 nlm_tcpport=32768

После этого в фаерволле нужно открыть порты:
iptables -A INPUT -p tcp -m tcp --dport 111 -m state --state NEW -j ACCEPT
iptables -A INPUT -p udp --dport 111 -j ACCEPT
# nfs server
iptables -A INPUT -p tcp -m tcp --dport 2049 -m state --state NEW -j ACCEPT
iptables -A INPUT -p udp --dport 2049 -j ACCEPT

# other nfs stuff
iptables -A INPUT -p tcp -m tcp --dport 32765 -m state --state NEW -j ACCEPT
iptables -A INPUT -p udp --dport 32765 -j ACCEPT

iptables -A INPUT -p tcp -m tcp --dport 32767 -m state --state NEW -j ACCEPT
iptables -A INPUT -p udp --dport 32767 -j ACCEPT

iptables -A INPUT -p tcp -m tcp --dport 32768 -m state --state NEW -j ACCEPT
iptables -A INPUT -p udp --dport 32768 -j ACCEPT

После этого нужно ребутнуть машину:
shutdown -r now

Первоисточник:

Путем небольших умственных усилий и проб вопрос решен, может кому и пригодится:

1. В /etc/default/nfs-common ставим
Код
STATDOPTS="--port 32765 --outgoing-port 32766"
2. Создаем файл в /etc/modprobe.d с именем options.local и вписываем строчку:
Код
options lockd nlm_udpport=32768 nlm_tcpport=32768
3. Если это надо замутить на NFS-сервере,то еще дополнительно в
/etc/default/nfs-kernel-server
Код
RPCMOUNTDOPTS="-p 32767"
перезапускаем nfs и в rpcinfo -p , видим, что все порты служб NFS сели
на указанные места и стали статическими. Теперь можно и iptables
применить....

Источник: http://unixforum.org/index.php?showtopic=74354 и http://prefetch.net/blog/index.php/2010/11/02/firewalling-a-linux-nfs-server-with-iptables/

No comments :

Post a Comment

Note: only a member of this blog may post a comment.