Hacking Windows XP DNS cache for faster surfing
I'm pretty sure few will know what DNS is all about, so I'll keep it simple.
Let's imagine you type in www.facebook.com in the address bar in Internet Explorer or Firefox. Your computer now needs to connect to Facebook's computers (servers) to get to your account. But www.facebook.com means absolutely nothing to the computer, and says nothing about where exactly to connect to.
And so, after you press Enter, your laptop asks a giant online address book called a DNS server, which will hold information on how to connect to Facebook's servers in the form of a series of numbers.
Using those numbers, your computer now connects to Facebook's servers, and the login page is loaded.
All this occurred in milliseconds (let's say, 100ms), so you probably wouldn't notice any delay. But www.facebook.com is not the only site you visit. You probably also visit www.friendster.com or www.hotmail.com. (Let's say around 50 sites each time you go online)
So, at each session, using this system, you will spend 50x100=5,000milliseconds referring to that giant online address book. And let's say you go online once daily on weekdays and twice daily on weekends. This means a total of 9 sessions x 5,000 milliseconds= 45,000 milliseconds per week.
In a year, that would mean 52x45,000=2,430,000milliseconds.
That's about 67.5 hours of time merely spent referring to the DNS servers.
And these values are just for the average casual server. We have not even begun to consider people like me who are capable of being actively online surfing and reading more than a hundred sites a day. Obviously, we need to find a way to minimize this waste of time.
There is something in both Windows and Linux that reduces this load, called the DNS cache, that temporarily stores the DNS information. Sort of like copying down notes from the giant address book. The problem is, the default DNS cache isn't very large, and in the case of some linux distributions, it does not seem to be permanent, being erased at system shut down.
So, how do you further reduce the time spent referring to the DNS servers?
By running your own little storage of DNS addresses. Think of it like copying the addresses off the giant online address book at the first time you refer to it, so that you don't have to keep referring to it for the same address each time.
Well, in Linux, it is solved easily enough via dnsmasq.
yum install dnsmasq (for RPM based systems)
or
apt-get install dnsmasq (for Debian systems)
For Fedora, dnsmasq seemed to run fine without changing anything, but I have not got around to making the cache permanent on my Fedora 10 machine rather than frying it each time I turn off my laptop.(*edit: dnsmasq is designed to lose the cache on shutdown. For a permanent cache that survives shut down, try pdnsd. I might, someday.) The service was disabled when I checked the services though. Fixed that, and it was all good.
For Debian systems, apparently there are some changes to make before it works:
1. Uncomment the following line in /etc/dnsmasq.conf :
listen-address=127.0.0.1
2. Add this to the /etc/dhcp3/dhclient.conf file:
prepend domain-name-servers 127.0.0.1; request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, host-name, netbios-name-servers, netbios-scope;
Boom, you're done.
For the hardcore people, there's always the option of a dedicated proxy server to handle this. For the 90% of users out there, who are home users running Windows, neither is really a practical option, let alone a cost-effective one.
The solution for the regular user on Windows XP? Here:
Run regedit
Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters
Right click, and choose: Create> New DWORD (32bit) Value
Modify (or create, if absent) the following DWORD [REG_DWORD] values :
CacheHashTableBucketSize 40 CacheHashTableSize 307 MaxCacheEntryTtlLimit 432000 MaxSOACacheEntryTtlLimit 90 NegativeCacheTime 0 NetFailureCacheTime 0 NegativeSOACacheTime 0
And you're done.
ALTERNATIVE:
If you are not really into digging in the registry, try this alternative for Windows XP:
Download this file, and run it, accepting anything it orders you to do.
I have no guarantees on that though.
(*edit: the script doesn't work,sadly. Do it manually via regedit as per above. )
At the end of all this, you now have a larger DNS cache, which over time, shall hopefully save many hours.
Let's imagine you type in www.facebook.com in the address bar in Internet Explorer or Firefox. Your computer now needs to connect to Facebook's computers (servers) to get to your account. But www.facebook.com means absolutely nothing to the computer, and says nothing about where exactly to connect to.
And so, after you press Enter, your laptop asks a giant online address book called a DNS server, which will hold information on how to connect to Facebook's servers in the form of a series of numbers.
Using those numbers, your computer now connects to Facebook's servers, and the login page is loaded.
All this occurred in milliseconds (let's say, 100ms), so you probably wouldn't notice any delay. But www.facebook.com is not the only site you visit. You probably also visit www.friendster.com or www.hotmail.com. (Let's say around 50 sites each time you go online)
So, at each session, using this system, you will spend 50x100=5,000milliseconds referring to that giant online address book. And let's say you go online once daily on weekdays and twice daily on weekends. This means a total of 9 sessions x 5,000 milliseconds= 45,000 milliseconds per week.
In a year, that would mean 52x45,000=2,430,000milliseconds.
That's about 67.5 hours of time merely spent referring to the DNS servers.
And these values are just for the average casual server. We have not even begun to consider people like me who are capable of being actively online surfing and reading more than a hundred sites a day. Obviously, we need to find a way to minimize this waste of time.
There is something in both Windows and Linux that reduces this load, called the DNS cache, that temporarily stores the DNS information. Sort of like copying down notes from the giant address book. The problem is, the default DNS cache isn't very large, and in the case of some linux distributions, it does not seem to be permanent, being erased at system shut down.
So, how do you further reduce the time spent referring to the DNS servers?
By running your own little storage of DNS addresses. Think of it like copying the addresses off the giant online address book at the first time you refer to it, so that you don't have to keep referring to it for the same address each time.
Well, in Linux, it is solved easily enough via dnsmasq.
yum install dnsmasq (for RPM based systems)
or
apt-get install dnsmasq (for Debian systems)
For Fedora, dnsmasq seemed to run fine without changing anything, but I have not got around to making the cache permanent on my Fedora 10 machine rather than frying it each time I turn off my laptop.(*edit: dnsmasq is designed to lose the cache on shutdown. For a permanent cache that survives shut down, try pdnsd. I might, someday.) The service was disabled when I checked the services though. Fixed that, and it was all good.
For Debian systems, apparently there are some changes to make before it works:
1. Uncomment the following line in /etc/dnsmasq.conf :
listen-address=127.0.0.1
2. Add this to the /etc/dhcp3/dhclient.conf file:
prepend domain-name-servers 127.0.0.1; request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, host-name, netbios-name-servers, netbios-scope;
Boom, you're done.
For the hardcore people, there's always the option of a dedicated proxy server to handle this. For the 90% of users out there, who are home users running Windows, neither is really a practical option, let alone a cost-effective one.
The solution for the regular user on Windows XP? Here:
Run regedit
Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters
Right click, and choose: Create> New DWORD (32bit) Value
Modify (or create, if absent) the following DWORD [REG_DWORD] values :
CacheHashTableBucketSize 40 CacheHashTableSize 307 MaxCacheEntryTtlLimit 432000 MaxSOACacheEntryTtlLimit 90 NegativeCacheTime 0 NetFailureCacheTime 0 NegativeSOACacheTime 0
And you're done.
ALTERNATIVE:
If you are not really into digging in the registry, try this alternative for Windows XP:
Download this file, and run it, accepting anything it orders you to do.
I have no guarantees on that though.
(*edit: the script doesn't work,sadly. Do it manually via regedit as per above. )
At the end of all this, you now have a larger DNS cache, which over time, shall hopefully save many hours.
_______________________________________________





0 Comments:
Post a Comment
<< Home