Debian – Reverse DNS lookups slowing down network operations on LAN

debiandnslinuxnetworking

Environment

My LAN setup is quite basic:

  • A router connected to the ISP's modem and the internet
  • My development pc directly connected to the router

The router provides DHCP but does not run its own DNS server. In fact, there is no DNS server hosted anywhere on my LAN (typical home network setup). The router is configured to send the ISP's DNS servers as part of the DHCP lease information.

I set up a VirtualBox machine on my development PC and installed Debian Squeeze (6.0.4) on it. The VirtualBox network mode is Bridged Adapter to simulate a standalone server on my LAN. Being a VirtualBox server instead of a physical server is not really important, but I mention it for completeness.

The Problem

Every time a network operation executes a DNS reverse lookup of a LAN ip prior to executing, the server has long delays. Some examples of slow network operations:

  • SSH connection to the server from my dev PC
  • Connection to admin port of Glassfish server
  • netstat -l (netstat -nl is very fast)
  • Starting MTA: exim4 on boot takes a long time to complete

Some of these have workarounds like adding my dev pc's Ip to /etc/hosts or adding a command-specific option to avoid doing DNS reverse lookups. Obviously, using /etc/hosts only goes so far because it is at odds with DHCP.

However, I can't help but think that I'm missing something. Do I really need to setup a DNS server somewhere on my LAN? That seems like a huge and useless effort for my needs and I can't believe there isn't another option in a DHCP environment like mine.

I searched the net a lot for this and maybe I don't have the right search terms, but I can't find the solution…

update 1 following BillThor's answer

Using host (dig gives the same results):

# ip of stackoverflow.com
$ time host -v 64.34.119.12
Trying "12.119.34.64.in-addr.arpa"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15537
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;12.119.34.64.in-addr.arpa.     IN      PTR

;; ANSWER SECTION:
12.119.34.64.in-addr.arpa. 143  IN      PTR     stackoverflow.com.

Received 74 bytes from 192.168.1.1#53 in 15 ms

real    0m0.020s
user    0m0.008s
sys     0m0.000s

# ip of dev pc
$ time host -v 192.168.1.50
Trying "50.1.168.192.in-addr.arpa"
;; connection timed out; no servers could be reached

real    0m10.004s
user    0m0.004s
sys     0m0.000s

My /etc/resolv.conf (was automatically created during installation)

nameserver 192.168.1.1

Both host and dig return very fast for a public ip but take 10s to timeout for a LAN ip. I guess 10s is my current timeout value.

update 2

With dev-pc in /etc/hosts file:

$ time getent hosts 192.168.1.50
192.168.1.50    dev-pc

real    0m0.001s
user    0m0.000s
sys     0m0.000s

Without dev-pc in /etc/hosts file:

$ time getent hosts 192.168.1.50

real    0m10.012s
user    0m0.004s
sys     0m0.000s

It looks more and more like I'll have to find piecewise program options or parameters for each one trying to do reverse DNS lookups! None of the machines (virtual or not) can act as a DNS server on my LAN since they are not always up. Unfortunately, the router's firmware doesn't include a DNS server.

Best Answer

Is 192.168.1.1 your router's IP address?

nameserver 192.168.1.1 suggests your router is advertising itself as a DNS server, rather than "sending the ISP's DNS servers".

What brand and model of router do you have? Does the web interface show log messages?

I'm wondering if your router is forwarding the request to your ISP's nameservers, but your ISP's nameservers are dropping the request, because they don't want you to know what their machine with IP 192.168.1.50 is called.

Suggestions:

  • Double check your router's settings. It should answer requests for your own private network. Maybe you can add a static host entry in your router's web interface?
  • Try installing Avahi on all the systems on your network.
  • Tell your router to use Google Public DNS (8.8.8.8 and 8.8.4.4) or OpenDNS
Related Question