Imbrium Logo

How to get the resolver to work in uClibc


Thank you very much to the responses in the uclibc mailing list, Erik Andersen and David McCullough for helping me getting this to work.

I have a ramfs that dowloaded from Flash and is then mounted on /etc/config after boot time. How this is done is explained here. Basically, after config is mounted, my dir looks like this:

uwe@sirius:/home/uclinux/uClinux-dist/romfs/etc > l
total 52
drwxr-xr-x    3 uwe      uwe          4096 Oct  2 11:42 ./
drwxr-xr-x   11 uwe      uwe          4096 Oct  2 01:37 ../
drwxr-xr-x    2 uwe      uwe          4096 Oct  2 11:42 config/
lrwxrwxrwx    1 uwe      uwe            16 Oct  2 11:42 host.conf -> config/host.conf
lrwxrwxrwx    1 uwe      uwe            15 Oct  2 11:42 hostname -> config/hostname
lrwxrwxrwx    1 uwe      uwe            12 Oct  2 11:42 hosts -> config/hosts
-rw-r--r--    1 uwe      uwe            44 Oct  2 01:37 inetd.conf
-rw-r--r--    1 uwe      uwe           128 Oct  2 01:37 inittab
-rw-r--r--    1 uwe      uwe           156 Oct  2 01:37 motd
lrwxrwxrwx    1 uwe      uwe            20 Oct  2 11:42 nsswitch.conf -> config/nsswitch.conf
-rw-r--r--    1 uwe      uwe            21 Oct  2 01:37 passwd
-rw-r--r--    1 uwe      uwe          2874 Oct  2 01:37 ramfs.img
-rw-r--r--    1 uwe      uwe           932 Oct  2 01:37 rc
lrwxrwxrwx    1 uwe      uwe            18 Oct  2 11:42 resolv.conf -> config/resolv.conf
-rw-r--r--    1 uwe      uwe          8205 Oct  2 01:37 services
-rw-r--r--    1 uwe      uwe            63 Oct  2 01:37 version
uwe@sirius:/home/uclinux/uClinux-dist/romfs/etc > 

If you do make clean in the top-level dir, you will lose these settings.. also, if you update the uClinux-dist and so on. So I wrote a quick script that will put these links into romfs, like this:

#!/bin/sh
# makelinks.sh
SOURCE=/home/uclinux/uClinux-dist/romfs/etc
TARGET=config

cd $SOURCE
if [ ! -d "${TARGET}" ]
then
        mkdir "${TARGET}"
fi

for i in hostname hosts host.conf resolv.conf nsswitch.conf
do
        if [ -L "${i}" ]
        then
                rm ${i}
        fi
                ln -s $TARGET/${i} ${i}
done

Now here are the contents of my files that are mentioned above:

# /etc/config/hosts
# 
127.0.0.1	localhost
192.168.25.1	ucdimm

# /etc/config/host.conf
order hosts,bind
multi on

# /etc/hostname
ucdimm.qulch.de

# /etc/config/nsswitch.conf
passwd:	files
group:	files
hosts:	files dns
networks:	files dns
services:	files
protocols:	files
netmasks:	files

# /etc/config/resolv.conf
search qulch.de.
nameserver 192.168.25.1

In order for the resolver to work, you will need a route to your default gateway, this is done in /etc/rc.