Don't understand german? Read or subscribe to my english-only feed.

Simple DNS in chroots

Update: Ulrich ‘mru’ Dangel suggested pdnsd as nice alternative to dnsmasq and Cyril ‘KiBi’ Brulebois pointed out, that it’s not necessary to invoke dnsmasq after fresh installation as it’s running by default then – I adjusted the text accordingly, thanks for the pointers!

If /etc/resolv.conf doesn’t provide any nameserver entries glibc[1] will automatically initialize the nameserver to the loopback address. This is nice for dealing with chroots without having to manually edit resolv.conf to get working DNS.

Just install a basic DNS forwarder like dnsmasq (‘apt-get install dnsmasq’) or if it’s already on your box just start it (‘/etc/init.d/dnsmasq start’). That’s it. Now when chrooting into a system without an existing resolv.conf configuration it will give you a working DNS setup without any further work.

PS: Grml ships dnsmasq by default and ‘/etc/init.d/dnsmasq start’ or ‘Start dnsmasq’ will work out-of-the box. In Ubuntu the dnsmasq package is available only through the universe repository – but the dnsmasq-base package (providing e.g. the init script) is shipped by default, so replace the ‘/etc/init.d/dnsmasq’ command with a simple ‘dnsmasq’ there.

[1] At least the [e]glibc versions provided on Debian and Ubuntu are known to provide this glibc extension. Other libc implementations like dietlibc and uclibc don’t seem to provide it, so don’t strictly rely on this feature but use it as the icing on the cake.

Comments are closed.