mount.nfs: Failed to resolve server
Solution 1:
I have yet to figure out what the real problem is but the solution is to remove rotate
option from /etc/resolv.conf
and put a dot after nfs-server-host-name
in /etc/fstab
to prevent domain search (which occurred even when there was no search
option in /etc/resolv.conf
), i.e.:
nfs-server-host-name.:/nfs/export/...
^
^---up here
It may have something to do with kernel build option CONFIG_NFS_USE_LEGACY_DNS, which is set to yes on my kernel.
The behaviour of nfs-client (and nfs-client only) was that it only queried the second nameserver in /etc/resolv.conf
no matter how many there were as long as the rotate
option was present. It did, however, work when there was no second nameserver at all. Beats me...
Solution 2:
The showmount
command has an RPC call which uses gethostbyname_r
to attempt to get information for a hostname. It does not do much to interpret errors returned by it. Could you run a test to see what the error actually is? This code is modified from the actual glibc clnt_gen.c
code seen here
Example C source:
#include <netdb.h>
#include <alloca.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
int main(int argc, char **argv)
{
struct hostent hostbuf, *h;
size_t hstbuflen;
char *hsttmpbuf;
char *hostname;
int herr;
if (argc != 2)
{
exit(-1);
}
hostname = argv[1];
hstbuflen = 1024;
hsttmpbuf = alloca(hstbuflen);
while (gethostbyname_r (hostname, &hostbuf, hsttmpbuf, hstbuflen, &h, &herr) != 0 || h == NULL)
{
if (herr != NETDB_INTERNAL || errno != ERANGE)
{
printf("gethostbyname_r error: %s\n", hstrerror(herr));
exit(0);
}
else
{
hstbuflen *= 2;
hsttmpbuf = alloca (hstbuflen);
}
}
}
Save this as ghbntest.c
and compile with the command gcc -o ghbntest ghbntest.c
. Run using ./ghbntest nfs-server-host-name
. Output example:
$ ./ghbntest 12345.example.com
gethostbyname_r error: Unknown host