14

I am compiling my own 3.14 kernel. I fear I may have left out some important networking feature to get DNS working.

I can't resolve domain names. I can ping my DNS server. I can resolve using that DNS on other machines so I know it's not the server.

~ # cat /etc/resolv.conf
nameserver 192.168.13.5

~ # nslookup google.com
Server:    192.168.13.5
Address 1: 192.168.13.5

nslookup: can't resolve 'google.com'

~ # ping -c 1 google.com
ping: bad address 'google.com'

~ # ping -c 1 192.168.13.5 
PING 192.168.13.5 (192.168.13.5): 56 data bytes
64 bytes from 192.168.13.5: seq=0 ttl=128 time=0.382 ms

--- 192.168.13.5 ping ststistics ---
1 packets transmitted, 1 packets recieved, 0% packet loss
reound-trip min/avg/max = 0.382/0.382/0.382 ms

Any ideas what I left out? here is my config: http://pastebin.com/vt4vGTgJ

EDIT:

If it's not the kernel, what could I be missing? I am using busybox, statically linked. there are no shared libraries in this system.

  • Do you have any firewall configured? If so, do you block port 53 UDP/TCP? – Jenny D Apr 11 '14 at 14:03
  • No firewall, no block on port 53. I can access the DNS from another machine on the same subnet. – AllenKll Apr 11 '14 at 14:04
  • As far as i iknow you can't just disable DNS functionality by .config-options from your kernel. – Bonsi Scott Apr 11 '14 at 14:07
  • 1
    Are you sure that your DNS server @ 192.168.13.5 is allowing recursive queries? For example, if you dig @192.168.13.5 www.google.com do you get any additional info? Can you perform recursive queries against your DNS server 192.168.13.5 from other machines? – Chipster Apr 11 '14 at 14:54
  • 1
    your kernel seems to be Ok, but your DNS resolving does not work. Did you obtain the nameserver IP from DHCP? is route set? try a different nameserver i.e. nameserver 8.8.8.8. – user55518 Apr 11 '14 at 15:12
5

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.

  • Did you actually compile busybox against uClibc to verify this answer, or did it just seem the most plausible one? – Tim Jun 26 '18 at 7:48
  • I did not test this. The precomoiled version worked for my issues. – AllenKll Jun 27 '18 at 13:58
2

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
0

I'm not sure if this is the same problem I had or not, but I recently upgraded and old internal DNS server system from OpenBSD 3.8 to 5.6, and I lost the ability to resolve hosts with ping, but the host command was working. Turned out I had to add 127.0.0.1/8 to the match-clients directive in named in addition to the 192.168.0.0/16 which I already had there, and then it started to work properly after restarting named.

0

I had the same problem. I've used buildroot to build the filesystem, to compile the kernel and to add extra packages with busybox.

I was only able to ping an ip address. With url the ping command returned: bad address error. Then I changed the resolv.conf file.

sudo vim /etc/resolv.conf

nameserver gateway_ip_address
nameserver 8.8.8.8
nameserver 8.8.4.4

And everything worked fine.

  • 1
    That does not seem to solve the problem for me. As OP mentioned, it seems to be down to libnss not working when statically linked. Compiling busybox with uclibc (and udhcpc) seems to solve the issue for me. – Attila O. Jan 13 '15 at 10:19
0

I resolved the same symptoms by editing: /etc/nsswitch.conf and adding DNS to the following line:

hosts:      files dns
-1

sudo vim /etc/resolv.conf to edit resolv.conf, make sure nameserver addresses (as well as the keyword 'nameserver') are separated by a single space, not a comma, like below:

nameserver 8.8.8.8 8.8.4.4

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.