Reverse DNS lookups slowing down network operations on LAN

Failing DNS lookups should fail fast. However, I generally run dnsmasq which will read the hosts file and serve those entries for forward and reverse lookups. It also acts as a DNS caching server to reduce load on your upstream DNS servers.

You may want to use the host or dig command to see which lookups are slow. If you are redirected to a DNS server which isn't running DNS will take quite a while to fail. You can tune the timeouts and retries in /etc/resolv.conf to speed up the failures.

EDIT: To test the resolver response try using time getent hosts 192.168.1.50. This should return lookups from your /etc/hosts file as well as DNS. The host and dig commands only check DNS. If this returns but takes a few seconds, you may want to change the order of the hosts entry in /etc/nsswitch.conf move files to the front of the list.

Setting up dnsmasq and using it as your primary DNS nameserver in /etc/resolve.conf should resolve the issue if you have any programs which rely only on DNS for name lookups. Exim should use the resolver for is base lookups. You will need a /etc/hosts file, unless you can disable the DHCP server on your router, you can use dnsmasq for DHCP. dnsmasq will automatically register names if they are provided in DHCP requests it handles.

EDIT2: If none of your computers are always up, you may want to look at installing samba and using wins in your nsswitch configuration. It should be fast, so it may work if you put it ahead of dns in the hosts entry.

You could also look at installing the avahi utilities which will enable automatic discovery on link-local networks. I have it working on the IPv6 side, but it is not publishing IPv4 addresses. The default domain for hosts is '.local'. This may not be suitable in your case, but can be overridden. It also seems slower doing lookups than wins so putting mdns ahead of dns in the nsswitch configuration may not be suitable.


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

If you don't want to go through the exercise of setting up a local DNS (and potentially DHCP) server for your home network, you could tell the services where possible to not perform reverse DNS lookups.

For example, to disable reverse dns lookup for SSHD, add the following to the sshd_config file (or similar depending on distro):

UseDNS no

You could remove this line from the Exim configuration, though I'm not clear if this will have impact on the startup speed, it will prevent reverse dns lookup on connecting clients:

host_lookup = *

It looks like you can export this environment variable for the user that starts the Glassfish process:

export AS_NO_REVERSE_DNS=true