Every now and then, I come across a person needing help with their DNS resolution for their proxy. More often than not, they don’t know that DNS is their problem, and it shows up as general poor performance, or unable to load proxied pages.

I have since resolved this on my servers, but I thought it would be useful to share that information with you. The idea behind this post came from one (of many similar) threads on the proxy.org forum: http://proxy.org/forum/1179669925.html

I run a few proxies and I see that I have a problem with the loading time. It takes around 25seconds just to load google.

I have my apache optimized and also noticed that my other website and non-proxy surfing are fast.

But the proxy surfing is very slow. The server load is fairly low at around 0.50, so I don’t think this could be due to excessive load.

In a situation like this, you should look to your DNS resolvers first.

The key points of interest are:

  1. When site finally starts loading, it does so quickly.
  2. Your site’s homepage loads very quickly, but “in proxy” pages do not.
  3. Server is not under heavy load but goes very slow.
  4. You’ve taken other appropriate steps to optimize your server.

The trick here is to look at your /etc/resolv.conf file.

This file has a list of the DNS resolvers your server will use, in order. In the situation above, chances are your first resolver is bad, and all requests have to time out on that resolver before it tries another one. Eventually it finds a working resolver, and you’re in business, but meanwhile everything goes slowly.

Your resolv.conf file should look like this:

nameserver 127.0.0.1
nameserver 66.90.68.25
nameserver 66.90.68.26
nameserver 66.90.68.15
nameserver 66.90.68.16

If there’s other stuff in there, it may be causing you problems. If you’re getting a “parse error” in your resolv.conf when you do the nslookup, see the original thread for a way to fix that.

There is a command you can run from the linux command line to test each resolver:

nslookup www.google.com 127.0.0.1

In this case, we want to see what the dns server located at “127.0.0.1″ thinks the address for www.google.com is. Replace 127.0.0.1 for the ip address listed in your resolv.conf. Try a few different addresses to resolve. Note if you get an error message, or if it takes a while to do the resolution. If this happens, you should remove this resolver from your list.

Ideally, for maximum performance, you should run a local dns resolver on your proxy server. This will make your server immune from issues relating to poor performing upstream resolvers. In Cpanel, you’d just use the “enable nameserver” option, and then make sure the first entry in your resolv.conf file is “127.0.0.1″.