Saturday, July 11, 2009

MAXNS

We recently had a requirement to have about 8 entries in /etc/resolv.conf. This was because the machine was to be used in various networks where the NS entry will be different. However, the default value of MAXNS in resolv.h is only 3 (There might be distros that might have set this to another value. But most of them have it at 3). That means, if I add a 4th or 5th name server to /etc/resolv.conf, all of them (starting from 4th entry) will get ignored.

What is the workaround? There are two ways to solve this. The first solution is to change MAXNS to some other value in resolv.h and recompile the stuff. Now, what is this 'stuff'? This stuff is glibc. Replacing glibc on a working machine can be disastrous. Hence I decided to recompile glibc on a new machine. Again, what if the machine did not accept a newly compiled glibc? I might not lose any data, but the effort spent will be wasted. Hence, I decided to make an lfs.

I downloaded an lfs live CD from here . Its been ages since I had done it last. This time, however, I decided to use jhalfs. LFS live CD has a user with the same name and the tool is present there. The glibc source tar ball was replaced by a modified one where the MAXNS was set to 8. It took one whole night. But it worked. I was able to set 8 entries in resolv.conf and they were all used.

What is the second solution? It is much simpler. Just install your own DNS server software and configure it in proxy mode. I did not try this. But, I am almost sure that it should work. Alas, its just a small piece of software. You can change it in anyway to accept any number of i/p and if you want you can write one overnight. We are evaluating both the solutions. They both have some common issues.

1. Resolution will take a long time if the address need to be retrieved from name server at the bottom of the list
2. If any one of the top servers decides to respond for the query with an address not found, then even if we have a correct answer from the bottom server, we will not get it.

However, the second solution has some workarounds for these two issues. The above two problems can be solved with the help of domain specific forwarders (named supports this AFAIK).

No comments: