linux - How to mount nfs share using autofs
2014-04
I shared /data
directory using nfs
This is the content of /etc/exports
/data *(rw,sync)
I started these two services
service rpcbind restart service nfs restart
This is my firewall configuration
*filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 20049 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 2020 -j ACCEPT -A INPUT -m state --state NEW -m udp -p udp --dport 32769 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 32803 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 662 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 875 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 892 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
In client side I can access the data and I can mount also
[root@client ~]# showmount -e server Export list for server: /data *
[root@client ~]# mount -t nfs server:/data /mnt/
If I try to mount using autofs it's not working, in /var/log/messages it's showing this
client automount[29971]: lookup_read_master: lookup(nisplus): couldn't locate nis+ table auto.master
This is my /etc/auto.misc
configuration
public -ro,nfs,intr 192.168.122.123:/data
If I stop iptables in server side , then autofs will work.
To allow autofs which firewall port should I open ?
On my system (Debian) it's ports 111 (rpc) and 2049 (nfs), both UDP and TCP
Also, let me give you a hint. When you have this kind of doubts, you may check on which ports different applications are listening by issuing the follwoing commands:
sudo ss -lntp
sudo ss -lnup
The flags work like this:
-l list listening sockets
-n do not resolve service names
-t list TCP sockets
-u list UDP sockets
-p show the process using the socket
I use CentOS 5.5 with Xen.
I created RedHat 5.3 DomU and exported some directories through nfs.
In clien side (Dom0) I configured autofs for automatically mounting server's directories.
Server side (DomU):
/ets/exports:
/etc *.rodnower.org(rw,sync,no_root_squash)
/var *.rodnower.org(rw,sync,no_root_squash)
/administration *.rodnower.org(rw,sync,no_root_squash)
/etc/sysconfig/nfs:
RQUOTAD_PORT=4002
LOCKD_TCPPORT=4003
LOCKD_UDPPORT=4004
MOUNTD_PORT=4005
STATD_PORT=4006
STATD_OUTGOING_PORT=4007
Client side (Dom0):
/etc/auto.master:
/misc /etc/auto.misc
/- /etc/auto.systems
/net -hosts
+auto.master
/etc/autosystems:
/mnt/dns/administration -rw,hard,intr nameserver.rodnower.org:/administration
/mnt/dns/etc -rw,hard,intr nameserver.rodnower.org:/etc
/mnt/dns/var -rw,hard,intr nameserver.rodnower.org:/var
Now, every time I lost connectivity (block all ports with iptables for example) with server, every action in /mnt/dns/* (like ls) will hang the shell.
I tried various combination of soft, hard and intr parameters, but this not change nothing, more of this, even if I mistake in name of parameter (write int instead of intr) there is no any error in any place...
Any one knows what I need to do?
Thank you for ahead.