Powered By

Powered by Blogger

Tampilkan postingan dengan label dns. Tampilkan semua postingan
Tampilkan postingan dengan label dns. Tampilkan semua postingan

Minggu, 26 September 2010

Determine The DNS Query Duration [Quick Linux Tip]

There are 2 applications you can use to see which DNS is the fastest for you (Namebench and Domain Name Speed Benchmark) but for a quick way to do this (without actually setting your computer to use new DNS), you can use the following command:

x=0; server=8.8.8.8; host="yahoo.com"; queries=128; for i in `seq $queries`; do let x+=`dig @${server} $host | grep "Query time" | cut -f 4 -d " "`; done && echo "scale=3;($x/${queries})" | bc

The command uses "dig" (which you can install in Ubuntu/Debian with: sudo apt-get install dnsutils) and you can specify the server (DNS to test), host (I've used Yahoo but you can use any other website) and number of queries (the number of requests).

In the above example, 8.8.8.8 is one of the Google DNS (the other one is 8.8.4.4). You can replace it with other DNS to test their speed (like OpenDNS: 208.67.222.222 and 208.67.220.220 or your ISP DNS and so on).

For me, Google DNS was a lot faster (13.351) then OpenDNS (49.460). But then again, Google already knows almost everything about us, so should we use its DNS services too?


Thanks to Debiania for the command!

Rabu, 09 Desember 2009

Faster Browsing In Linux With Local DNS Cache

A local DNS cache can help for faster browsing since you’re caching the DNS request instead of attempting that request multiple times. The internet speed will not get any faster, but the browsing speed will improve, because on each website there are usually quite a few DNS requests for which the local DNS cache will be used, bringing the query time to almost 0. You can find more info about DNS, on Wikipedia.

To see how fast your current domain name servers (DNS) are, open a terminal and paste this:
dig yahoo.com

(Or dig google.com or whatever domain)

You should see something like this:
; <<>> DiG 9.6.1-P1 <<>> yahoo.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42045
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;yahoo.com. IN A

;; ANSWER SECTION:
yahoo.com. 20142 IN A 69.147.114.224
yahoo.com. 20142 IN A 209.131.36.159
yahoo.com. 20142 IN A 209.191.93.53

;; Query time: 50 msec
;; SERVER: 208.67.220.220#53(208.67.220.220)
;; WHEN: Wed Dec 9 13:21:48 2009
;; MSG SIZE rcvd: 75

Notice the "Query time" in bold. It's usually somewhere near 50 msec. (it depends on your domain name servers).

Run this one more time. If the query time decreases to less than 5 msec, it means your internet service provider DNS already uses some caching method and you do not need to follow this how-to. If the response time is almost the same and you are using a cable (broadband) internet connection, you can use this guide to cache the DNS for faster internet browsing.

Firstly, I would like to thank embraceubuntu for this how-to, I've just made it more newbie-friendly. So the credits go to him.

Before we get started, please note that there is an easier method on doing this (by only installing (well, actually you need to edit /etc/bind/named.conf.options with your ISP DNS) resolvconf and bind9: sudo apt-get install resolvconf bind9) but in my tests, using resolvconf and bind9, the first DNS query time was 200-300 msec (maybe it needs some tweaking but I couldn't figure out why there is such a big query time the first time) and then since it was cached, it went to 0. But the method I am going to explain will get an initial query time equal to your default DNS (~50 msec for me, as opposed to 200-300 msec which I got by using resolvconf and bind9).

Let's get started!

Manually configuring the local DNS cache



1. Install DNSMasq:
sudo apt-get install dnsmasq


2. Configure dnsmasq.conf

Press Alt + F2 and type:

gksu gedit /etc/dnsmasq.conf


Now search for "listen-address" (it's on line 90 on my Ubuntu Karmic installation), remove the "#" character in front of "listen-address" and add "127.0.0.1" after the "=" (all without the quotes). Basically, this is how the "listen-address" line should look like after editing it:
listen-address=127.0.0.1


(Optional) You can also edit the cache size if you want. Search for this in the same file: "#cache-size=150" (it's on line 432 on my Ubuntu Karmic installation), remove the "#" character in front of the line (this uncomments it) and change "150" with the size you want for you DNS cache. This is how the line should look after editing it:
cache-size=500

Obviously, "500" can be any number you want.

Don't forget to save the changes!

3. Edit dhclient.conf

Press Alt + F2 and type:
gksu gedit /etc/dhcp3/dhclient.conf


And modify the "prepend domain-name-servers" (it's on line 20 on my computer) to look like this:
prepend domain-name-servers 127.0.0.1;



4. Edit resolv.conf

Press Alt + F2 and paste this:
gksu gedit /etc/resolv.conf


Initially, this is how the resolv.conf file looks like:
nameserver ISP_DNS1
nameserver ISP_DNS2

Where ISP_DNS1 and ISP_DNS2 are your ISP domain name servers (or 8.8.4.4, etc if you are using Google DNS and so on).

Put this as the first line in your resolv.conf file:
nameserver 127.0.0.1

Which means this is how your resolv.conf file will look like:
nameserver 127.0.0.1
nameserver ISP_DNS1
nameserver ISP_DNS2

Again, ISP_DNS1 and ISP_DNS2 are your ISP domain name servers.

As an example, this is how my resolv.conf file looks like (using local DNS cache, a Google DNS and an OpenDNS DNS):
nameserver 127.0.0.1
nameserver 8.8.4.4
nameserver 208.67.220.220


4.1 If you are using a DSL connection, you need to make sure the ppp client will not overwrite your /etc/resolv.conf file. To do this, press Alt + F2, and paste this:
gksu gedit /etc/ppp/peers/provider

Search for "usepeerdns" and replace it with "#usepeerdns" (we used "#" to comment that line so it's ignored).

5. Restart your networking and dnsmasq:

-Networking:
sudo /etc/init.d/networking restart


-DNS:
sudo /etc/init.d/dnsmasq restart

Please note that you can use this last command at any time you want to restart your DNS cache (flush DNS, clear the cache - call it whatever you want) without restarting the computer.

6. Testing

To see the peformance improvement, open a terminal and type:
dig yahoo.com

The first time, it should be the same like in the beginning of the post (~50 msec. for me). Now type it again! You should see something like this:
dig yahoo.com

; <<>> DiG 9.6.1-P2 <<>> yahoo.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57501
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;yahoo.com. IN A

;; ANSWER SECTION:
yahoo.com. 20982 IN A 209.131.36.159
yahoo.com. 20982 IN A 69.147.114.224
yahoo.com. 20982 IN A 209.191.93.53

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Dec 9 14:43:41 2009
;; MSG SIZE rcvd: 75


0 msec. query time, because the domains are now cached.


Note: Using the method above, the DNS cache will be cleared once you reboot your computer. For persistent DNS caching (on the hard disk), see this excellent how-to on Ubuntu Forums.



Message from Testking: Get the a+ certification to best support your IT career. No matter you are interested in mcitp or mcts certification, we guarantee first time success with up to date training products.

Sabtu, 05 Desember 2009

How To Find Out Which DNS Is Fastest For You [Windows, Linux, Mac OS X]

Google released it's public DNS and I saw some debates on different blog on wrather it is possible or not for the Google domain name servers to be faster than your ISP DNSs.

I know of two applications (thanks to GoogleSystem and Dsq) which you can use to see which domain name servers (DNS) are the fastest for you!



1. Domain Name Speed Benchmark


Domain Name Speed Benchmark is a free utility to determine the exact performance of local and remote DNS nameservers which works on Windows and Linux, under Wine.

Domain Name Speed Benchmark

To use it, download it, add Google DNS (8.8.8.8 and 8.8.4.4) and your ISP DNS (it already comes with OpenDNS and lots of other different domain name servers) and click on "Run Benchmark"

Download Domain Name Speed Benchmark



2. Namebench


Namebench is a project which began as a 20% project at Google and it hunts down the fastest DNS servers available for your computer to use (for free). Namebench runs a fair and thorough benchmark using your web browser history, tcpdump output, or standardized datasets in order to provide an individualized recommendation.

Namebench

Namebench is available for Windows, Linux and Mac OS X. The Windows and Mac OS X versions come with a GUI so all you have to do is download it (link at the end of the post), install it and add Google DNS (8.8.8.8 and 8.8.4.4).

To use Namebench on Linux, download the .tar.gz file, extract it, open a terminal and navigate to the folder where you have extracted namebench (example: cd /home/andrei/Desktop/namebanch) and then run the following command:
./namebench.py 8.8.8.8 8.8.4.4


This will add Google DNS to the existing domain name servers in Namebench. The output will contain many details regarding all the DNS, such as:

Fastest individual response (in milliseconds):
----------------------------------------------
Xnet RO ### 2.61497
kpnqwest RO #### 2.89702
Zapp RO #### 3.63088
Planet RO ######## 6.56700
Westel HU ############### 13.28516
EOL-2 HU ################ 14.26911
Google Public DN ################################### 31.73208
OpenDNS ##################################################### 49.07799
UltraDNS ##################################################### 49.43705
OpenDNS-2 ##################################################### 49.44301

Mean response (in milliseconds):
--------------------------------
Google Public DN ############################# 104.89
OpenDNS ############################## 106.24
Xnet RO ################################ 114.89
UltraDNS ################################## 123.26
Zapp RO ###################################### 136.91
OpenDNS-2 ####################################### 140.00
kpnqwest RO ############################################## 163.75
EOL-2 HU ################################################# 175.20
Planet RO ################################################# 176.89
Westel HU ##################################################### 192.48


And at the bottom you will find a list of suggested DNS:

Recommended configuration (fastest + nearest):
----------------------------------------------
nameserver 8.8.4.4 # Google Public DNS-2 Replica of Google Public DNS [8.8.8.8]
nameserver 193.230.161.3 # Xnet RO
nameserver 193.226.128.1 # kpnqwest RO

Which you can copy into your /etc/resolv.conf file if you want to start using these DNS right away.

For more info, consult the readme file.

Download Namebench

Kamis, 03 Desember 2009

Google Public DNS - How Google Tries To Speed Up The Internet

Google has launched Google Public DNS as an alternative domain name service for any Internet user. Designed to replace the DNS services provided by ISPs or companies, Google says that its DNS will be faster and more secure than many other DNSs, and won't filter content.

An amazing similar alternative is OpenDNS but it appears most services on the Internet disappear slowly, as Google releases it's own, much better alternative to... everything.

The goals for Google's new DNS are:

  • Speed: Resolver-side cache misses are one of the primary contributors to sluggish DNS responses. Clever caching techniques can help increase the speed of these responses. Google Public DNS implements prefetching: before the TTL on a record expires, we refresh the record continuously, asychronously and independently of user requests for a large number of popular domains. This allows Google Public DNS to serve many DNS requests in the round trip time it takes a packet to travel to our servers and back.
  • Security: DNS is vulnerable to spoofing attacks that can poison the cache of a nameserver and can route all its users to a malicious website. Until new protocols like DNSSEC get widely adopted, resolvers need to take additional measures to keep their caches secure. Google Public DNS makes it more difficult for attackers to spoof valid responses by randomizing the case of query names and including additional data in its DNS messages.
  • Validity: Google Public DNS complies with the DNS standards and gives the user the exact response his or her computer expects without performing any blocking, filtering, or redirection that may hamper a user's browsing experience.


Skeptics may say your local ISP may have faster DNS than Google, but:

"Google Public DNS is hosted in data centers worldwide, and uses anycast routing to send users to the geographically closest data center."


TechCrunch has it's own version for the reasons Google entered the DNS business:

In 2008 OpenDNS was making $20,000/day in revenue when they were resolving just 7 billion daily queries.

Here’s how money is made – when users enter a URL that can’t resolve, the service puts up its own landing page with search results and advertisements. And companies are very willing to pay for DNS services like these to stop employees from hitting malware sites (they are simply blocked), or other sites (porn, Facebook, etc.).


The new domain name servers (DNS) provided by Google are: 8.8.8.8 and 8.8.4.4. If you want to start using Google's DNS right away but don't know how to configure your computer domain name servers, see THIS page (it includes instructions for Windows, Linux and Mac OS X).

There are also a couple of screencasts you can follow for changing your DNS (Windows):



-Windows XP:



-Windows Vista / 7:



[videos via Labnol]

Additional info: The Official Google Blog and Google Code Blog.

Rabu, 09 September 2009

Quick Tip: How To Flush DNS Cache In Linux, Windows and Mac OSX

There is a simple command for every operating system for quickly cleaning the DNS cache. On Linux and Mac, the command must be typed in a terminal. In Windows, type the command in cmd.exe (Start > Run, type cmd.exe):

Linux:

Firstly, make sure you have nscd installed:
sudo apt-get install nscd
Then:
sudo /etc/init.d/nscd restart


Mac OS X:
lookupd -flushcache

Leopard and later:
dscacheutil -flushcache


Windows:
ipconfig /flushdns