DNS problems with Windows, Dnsmasq, IPv6 and CNAME

I’ve been trying to set up a git repository on a server in my home.  I wasn’t sure exactly which computer I should set it up on, and I want to be able to move it to another computer later without breaking the connections to it.  I thought maybe I could do this by setting up some magic in my network’s DNS server, giving the same computer two names in DNS: both its own name, and also the name “git”.  Then I could change the name “git” to point to another computer later, if I wanted to.  But things didn’t work out very well at first.

My router is running DD-WRT, which uses Dnsmasq to provide the DHCP and DNS functions.  I learned about DNS’s “CNAME” records, which allow you to create “canonical” names that point to other “real” names.  It seemed perfect.

I figured out how to configure Dnsmasq to do that.  Other pages talk about how to do this too, so I won’t go into the details here.  But It didn’t work for me.  When I tried “ping git” on my PC, it couldn’t resolve the name.

Actually, after a great deal of debugging, I discovered that it did actually work on other computers in my house.  All of them, in fact.  Just not the one in my home office.  It happens to be a Windows XP box, but then so were some of the other ones I tried it on.

This led me to suspect something weird about the DNS name resolution going on with that particular computer.  I tried using “nslookup git” on the same PC, and it found it.  But “ping git” still could not.  Weird.  Apparently “nslookup” does not use the same DNS resolver as the Windows system itself, which kind of limits its usefulness for debugging issues with the resolver.  But this, apparently, is a common problem with many causes, possibly involving NetBIOS, and LMHOSTS files, and a bunch of other stuff.  Nothing I found really addressed my problem, though.

Eventually, I installed Wireshark, so I could see exactly what was going to and from the DNS server.  This finally clued me in.  When I executed the “ping git” command, the request that Windows sent to my DNS server was asking for an IPv6 address record (type “AAAA”), rather than the IPv4 record (type “A”) that you might expect (since I don’t use IPv6).  And DNSmasq gave a “not found” response.  When I observed the name resolution done by “nslookup”, it requested an IPv4 “A” record, and got a proper response (which included both the “git” CNAME record, and the A record for the actual server that it pointed to.)

It was at this point that I recalled that this particular PC was the only WIndows XP box in the house that had IPv6 installed.  I don’t know why it was installed, or when, but there it was.  I wasn’t using IPv6, and I even disabled the IPv6 interface in the LAN connection properties, but it still seems to affect how Windows XP handles DNS resolution.  But somehow it still worked for other names in my DNS, though, that weren’t using a CNAME record.  Perhaps there’s some bug in how Dnsmasq handles CNAME records when an IPv6 AAAA record is requested.

Anyway, in the end the solution was to uninstall the IPv6 support, using the command “netsh int ipv6 uninstall”.  After that, “ping git” started working properly, returning the IP address of the computer that my CNAME record currently has “git” mapped to.

 

0 Responses to “DNS problems with Windows, Dnsmasq, IPv6 and CNAME”


  • No Comments

Leave a Reply

Categories

Archives