I have a statically linked busybox and want to be able to write busybox telnet foo. How do I specify the address of "foo"?

Do I really need /etc/nsswitch.conf and the corresponding dynamic libraries, or does busybox contain some own simple mechanism to consult /etc/hosts?

  • 1
    As Rui writes, this depends on the libc. What libc was this busybox compiled against? And with what configuration was busybox compiled? Also, how are you getting DNS? For example *wrt systems typically run dnsmasq and have a static host list that dnsmasq reads and serves via DNS. – Gilles Apr 25 '16 at 22:10

Looking into my openWRT, I do not have any libnss* libraries installed. It seems that only libuClibc is used for that. libc.so.0 is a symlink to it.

root@RuiWifi:/lib# grep -ri hosts *

uClibc is an implementation of the standard C library that is much smaller than glibc, which makes it useful for embedded systems.

If you are trying to put together a minimal environment, I would advise you to compile busybox against UClibc instead of glibc, and snooping around openWRT to see how they managed to put together such a distribution with such a small footprint.

Compiling BusyBox with uClibc

  • In your case busybox seems to be dynamically linked. If I understand correctly uClibc looks directly at /etc/hosts, but my busybox seems not to care about the content of that file. – michas Apr 25 '16 at 7:48
  • I assumed initially you were into one of the ...wrt systems, and then it just clicked me you only mentioned a compiled busybox, hence my last paragraph and edit. – Rui F Ribeiro Apr 25 '16 at 7:49

See dnsd which can be built into Busybox:

root@alpine-linux [~]# ls -l $(which dnsd)
lrwxrwxrwx    1 root  root  12 Mar 17 23:12 /usr/sbin/dnsd -> /bin/busybox

configuring dnsd

I was also able configure unbound to provide name resolution for .local domains in Alpine Linux (which also uses Busybox).

See local-data in the unbound.conf man page. By default it is commented out of the config file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.