A DNS server resolves domain names into IP addresses. So, when you request "www.google.com" for example, the DNS server finds out the address for the domain, and sends your request the right way.
You can run a DNS cache on your computer. This will speed up the process of looking up domain names when browsing. The difference is about 30-60 ms for me. Multiply that difference by the number of websites you visit a day for an approximate estimate of the speed improvement. Of course, all this would be worth it if it weren't for the fact that setting this up is way too easy.
The following instructions are for someone with a cable (broadband) internet connection, where the computer gets it's local IP address using DHCP from the router in your house/office:
The package we will be using for caching nameserver lookups is called dnsmasq. So first, install it using:
sudo apt-get install dnsmasq
(If you can't find then, then you probably haven't added the Universe repository to your list of repositories.)
No uncomment the following line (that is edit the line to NOT have a "#" in the beginning) in the file /etc/dnsmasq.conf:
Run in terminal:
sudo gedit /etc/dnsmasq.conf
Find listen-address= and change to listen-address=127.0.0.1
Now edit /etc/dhcp3/dhclient.conf and make sure the section below exactly like this, especially the line that says "prepend domain-name-servers 127.0.0.1;"
sudo gedit /etc/dhcp3/dhclient.conf
#supersede domain-name "fugue.com home.vix.com";
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;
require subnet-mask, domain-name-servers;
timeout 60;
retry 60;
reboot 10;
select-timeout 5;
initial-interval 2;
Explanation for the above change: In the normal case, when you get a new dhcp lease, the dhcp3 client (tool) on your computer gets a new lease, and updates the /etc/resolv.conf file on your computer with the right values for the DNS servers to use (usually some machine in the network of your hosting provider). Adding the "prepend" option as we did above ensures that "127.0.0.1" will appear on the top of the list of DNS servers. That magic number refers to your own computer. So in the future, whenever your computer needs to resolve a domain name, it will forward that request to dnsmasq (which is running at 127.0.0.1 - your computer). If the details for the domain name are already in you cache, well and good, dnsmasq will serve it up and make the process real fast. If it is not in the cache, then dnsmasq will look at the /etc/resolv.conf file and use the nameservers listed below the "127.0.0.1". I hope that explains things.
Now open the file in your text editor. It probably looks like:
# Generated by NetworkManager
nameserver 218.248.241.5
nameserver 8.8.8.8
The 127.0.0.1 is missing right now since you haven't renewed your lease after you edited the /etc/dhcp3/dhclient.conf file. So, let us add that in manually this one time. After you do, your /etc/resolv.conf file will look like the following:
# Generated by NetworkManager
nameserver 127.0.0.1
nameserver 218.248.241.5
nameserver 8.8.8.8
"Don't worry if the numbers are different"
Okay. We are almost done here. All we have to do now is to restart dnsmasq so that the changes we made to the configuration file take effect. You can do that using the command:
sudo /etc/init.d/dnsmasq restart
Now you are running a local DNS cache. If you want to measure your speed improvement, type the command:
dig google.com
You will see something like ";; Query time: 42 msec" there.
Now type the command again, and you should see something like ";; Query time: 0 msec"
See, the first time, since www.google.com's details were not in your cache (you are using it for the first time), the query took 42 ms. The second time, the cache speeds up the lookup. I have been using this for over a month now, and haven't had any problem.
A DNS server resolves domain names into IP addresses. So, when you request "www.google.com" for example, the DNS server finds out the address for the domain, and sends your request the right way.
You can run a DNS cache on your computer. This will speed up the process of looking up domain names when browsing. The difference is about 30-60 ms for me. Multiply that difference by the number of websites you visit a day for an approximate estimate of the speed improvement. Of course, all this would be worth it if it weren't for the fact that setting this up is way too easy.
The following instructions are for someone with a cable (broadband) internet connection, where the computer gets it's local IP address using DHCP from the router in your house/office:
The package we will be using for caching nameserver lookups is called dnsmasq. So first, install it using:
sudo apt-get install dnsmasq
(If you can't find then, then you probably haven't added the Universe repository to your list of repositories.)
Now uncomment the following line (that is edit the line to NOT have a "#" in the beginning) in the file /etc/dnsmasq.conf:
Run in terminal:
sudo gedit /etc/dnsmasq.conf
Find listen-address= and change it to listen-address=127.0.0.1
Now edit /etc/dhcp3/dhclient.conf and make sure the section below exactly like this, especially the line that says "prepend domain-name-servers 127.0.0.1;"
sudo gedit /etc/dhcp3/dhclient.conf
#supersede domain-name "fugue.com home.vix.com";
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;
require subnet-mask, domain-name-servers;
timeout 60;
retry 60;
reboot 10;
select-timeout 5;
initial-interval 2;
Explanation for the above change: In the normal case, when you get a new dhcp lease, the dhcp3 client (tool) on your computer gets a new lease, and updates the /etc/resolv.conf file on your computer with the right values for the DNS servers to use (usually some machine in the network of your hosting provider). Adding the "prepend" option as we did above ensures that "127.0.0.1" will appear on the top of the list of DNS servers. That magic number refers to your own computer. So in the future, whenever your computer needs to resolve a domain name, it will forward that request to dnsmasq (which is running at 127.0.0.1 - your computer). If the details for the domain name are already in you cache, well and good, dnsmasq will serve it up and make the process real fast. If it is not in the cache, then dnsmasq will look at the /etc/resolv.conf file and use the nameservers listed below the "127.0.0.1". I hope that explains things.
Now open the file in your text editor. It probably looks like:
# Generated by NetworkManager
nameserver 218.248.241.5
nameserver 8.8.8.8
The 127.0.0.1 is missing right now since you haven't renewed your lease after you edited the /etc/dhcp3/dhclient.conf file. So, let us add that in manually this one time. After you do, your /etc/resolv.conf file will look like the following:
# Generated by NetworkManager
nameserver 127.0.0.1
nameserver 218.248.241.5
nameserver 8.8.8.8
"Don't worry if the numbers are different"
Okay. We are almost done here. All we have to do now is to restart dnsmasq so that the changes we made to the configuration file take effect. You can do that using the command:
sudo /etc/init.d/dnsmasq restart
Now you are running a local DNS cache. If you want to measure your speed improvement, type the command:
dig google.com
You will see something like ";; Query time: 42 msec" there.
Now type the command again, and you should see something like ";; Query time: 0 msec"
See, the first time, since www.google.com's details were not in your cache (you are using it for the first time), the query took 42 ms. The second time, the cache speeds up the lookup.
I have been using this for over a year now, and haven't had any problem.
Thanks.