Busybox ping IP works, but hostname nslookup fails with "bad address"

The problem is with busybox. I switched to a precompiled version and did not have issues. I need to look into compilation options with it. Thanks for your help.

https://gist.github.com/vsergeev/2391575:

There are known issues with DNS functionality in statically-linked glibc programs (like busybox in this case), because libnss must be dynamically loaded. Building a uClibc toolchain and linking busybox against that would resolve this.


I ran into the same issue and it turns out that busybox is picky about the format for resolv.conf. There must be exactly one blank between the nameserver tag and the address for nslookup to work. In addition /etc/nsswitch.conf has to include dns for host.

[ busybox master (git hash 349d72c19) sysroot-glibc-linaro-2.25-2018.05-arm-linux-gnueabihf ]

root@4000000a:~# cat /etc/nsswitch.conf 
passwd:    files compat
shadow:    files compat
hosts:    files dns compat 

Yes the question is old, but the current busybox still behaves this way.

[ I used xxd below to show the number of blanks in resolv.conf ]

This fails:

root@4000000a:~# xxd /etc/resolv.conf
00000000: 6e61 6d65 7365 7276 6572 2020 382e 382e  nameserver  8.8.
00000010: 382e 380a                                8.8.
root@4000000a:~# nslookup  www.cnn.com 
nslookup: bad address ' 8.8.8.8'

and this works:

root@4000000a:~# xxd /etc/resolv.conf
00000000: 6e61 6d65 7365 7276 6572 2038 2e38 2e38  nameserver 8.8.8
00000010: 2e38 0a                                  .8.
root@4000000a:~# nslookup  www.cnn.com                
Server:     8.8.8.8
Address:    8.8.8.8:53

Non-authoritative answer:
www.cnn.com canonical name = turner-tls.map.fastly.net
Name:   turner-tls.map.fastly.net
Address: 151.101.1.67
Name:   turner-tls.map.fastly.net
Address: 151.101.65.67
Name:   turner-tls.map.fastly.net
Address: 151.101.129.67
Name:   turner-tls.map.fastly.net
Address: 151.101.193.67

Non-authoritative answer:
www.cnn.com canonical name = turner-tls.map.fastly.net
Name:   turner-tls.map.fastly.net
Address: 2a04:4e42::323
Name:   turner-tls.map.fastly.net
Address: 2a04:4e42:200::323
Name:   turner-tls.map.fastly.net
Address: 2a04:4e42:400::323
Name:   turner-tls.map.fastly.net
Address: 2a04:4e42:600::323