Cablemas DNS

So it seems cablemas decided to block DNS requests (port 53) going out of their network. I’m not sure if they’re doing this at the network level — which would be extremely stupid on their part — or by reconfiguring their modem. Either way this means:

  • Cannot use OpenDNS or Google Public DNS for domain resolution.
  • I’m forced to use Cablemas DNS servers. They are very, very slow. Most lookups are above 20s, with 30s-40s latency being common.

Since DNS queries take long to resolve, internet connectivity is slow as hell. Enter DNS caching (DNS proxy).

Most DNS servers can do caching on the side (BIND, djbdns, dnsmasq) without too much additional work. The problem is most of the time the cache disappears when the computer is rebooted. If your system is a server, you’re fine. But what if you’re on a laptop or a desktop? It’s no good having a cache if you have to rebuild it every day.

There isalso the fact the electric system in Mexico isn’t the best, so often computers go down hard when the electricity fails. UPS units are expensive to put them on a single desktop computer.

So that’s when I discovered pdnsd. It’s a light DNS proxy that can act as a caching system, working on localhost to speed up queries.

Being on Debian Sid, all I had to do to install it was

# aptitude install pdnsd

When asked which mode to use, I chose ‘manual’. When it was done I added my ISP’s DNS servers like so to /etc/pdnsd.conf

server {
        label=cablemas;
        ip=200.95.144.3;
        ip=10.147.0.43;
        ip=10.147.0.15;
        timeout=30;
        uptest=ping;
        ping_timeout= 300;
}

You’re free to use other DNS resolvers like OpenDNS or Google Public DNS obviously. The caching will work regardless of what upstream server does the actual resolving.

Then set it up so it runs on boot by editing /etc/default/pdnsd

This sets up the daemon to work; you still have to set up your network interfaces to make use of the cache. In my own case my system is getting an IP address from the cablemodem itself dynamically, so I had to edit /etc/dhcp3/dhclient.conf and enable the prepend domain-name-servers directive:

prepend domain-name-servers 127.0.0.1

If you’re setting manually via /etc/network/interfaces, you’ll have to manually edit /etc/resolv.conf so your local DNS is queried first.

Once everything is done, bring down the interface (eth0 in my case):

# ifdown eth0

Then bring it back up:

# ifup eth0

I’m pretty sure it’d be same for wlan interfaces. This should be more useful on laptops or systems that connect to networks of unknown quality.

This all goes to show Cablemas is one of the worst ISPs around and you should avoid it like the plague.

Sources: