Question about nslookup

Denys Vlasenko vda.linux at googlemail.com
Fri Mar 19 14:31:22 UTC 2010


On Fri, Mar 19, 2010 at 2:40 PM, Didier Kryn <kryn at in2p3.fr> wrote:
>   I am working in the field of Particle Physics and setting up the init
> sequence of a group of diskless single board computers (Emerson Network
> Power MVME3100). I have made an initramfs with a statically linked busybox
> and a collection of scripts.
>
>   I want to automate the init process so that it can run in various places
> where both the host and the NFS server can take various addresses. For the
> address of the NFS server, I just put a list in a file in the initramfs. For
> the host address I perform a DHCP request and it works well.
>
>   There is another thing I would like to do: get the hostname from the
> network.

More natural method would be to get hostname via DHCP.
Try to configure your DHCP server to provide hostnames too
in its responses.

Another method is to agree on some fixed formula how to assign
hostnames depending on the IP.

Final method is to not bother knowing your own hostname.
It is not really needed unless you are a server.
(And if you are, you don't use DHCP dynamic IP).
I usually set it to "localhost". Technically it's true,
even if I boot with no network at all:
my address is 127.0.0.1, it maps to "localhost",
so obviously I am "localhost".  :D

> Once udhcpc has configured eth0, I know the IP address. Then I
> issue an nslookup with this address and I expect to find the hostname in the
> response. But it does not work and I have to look into my own hand-written
> /etc/hosts to get it. The final OS is Debian Lenny.
>
>   I recently compiled busybox-1.15.2 to give a try the nslookup applet in
> the running Debian environment. There it works. But not in a chroot
> containing the same files as my initramfs.
>
>   Here is the response in the Debian system:
> kryn at apcdc4:~$ /busybox-1.15.2/bin/busybox nslookup apcdc4
> Server:    134.158.184.54
> Address 1: 134.158.184.54 apcdns01.in2p3.fr
>
> Name:      apcdc4
> Address 1: 134.158.186.184 apcdc4.in2p3.fr
> kryn at apcdc4:
>
>   And in my chroot /busybox-1.15.2:
> # nslookup apcdc4
> Server:    134.158.184.54
> Address 1: 134.158.184.54
>
> nslookup: can't resolve 'apcdc4'
>
>  I have copied the following files in the /etc of the chroot: host
> host.conf   nsswitch.conf   services
>
>  The executable is exactly the same in both cases and it is statically
> linked. There must be some file missing but which one?

It is likely /etc/resolv.conf

strace your nslookup run to find it out for sure.
-- 
vda


More information about the busybox mailing list