When you open your web browser and type in hub.tutsplus.com to find something interesting to learn, your computer is able to find a server with the IP address 22.214.171.124. Among other technologies, a protocol called DNS helps your computer find that server. In this tutorial, I’ll show you what DNS is and some tips you can use to be safer on the web.
DNS: A Definition and Example
DNS stands for Domain Name System and is a protocol, or language, that computers use when talking to each other. Every device on the public Internet has an IP address; DNS is like a phonebook that associates a domain name, hub.tutsplus.com for instance, with the server’s IP address, 126.96.36.199. Here’s a basic scenario of how it works:
- Connect to a wireless network; the router tells your computer what DNS server to use, usually the router itself.
- Type hub.tutsplus.com into the web browser; the computer asks the router for the IP address for hub.tutsplus.com so it can connect to the server.
- The router asks a DNS server for the IP address. If other devices have previously requested the Tuts+ Hub, the router may have the result cached already and may skip this step.
- The router receives a reply from a public DNS server and sends that on to your computer; among other details, it includes an IP address such as 188.8.131.52.
- The computer initiates a connection to that IP address and continues with loading the page. If the page needs resources from another domain, as many do, the computer will go through the whole process again for each domain or subdomain.
Frankly, it’s amazing that this whole process, called resolution, takes less than a second. In fact, DNS requests can take as little as 40 milliseconds!
Public DNS Servers
Your home router is likely set by default to use your ISP’s DNS servers, which may or may not be very reliable. There are a number of third-party DNS servers available as well. Personally, I prefer OpenDNS (184.108.40.206 and 220.127.116.11) and Google Public DNS (18.104.22.168 and 22.214.171.124).
Every major DNS service has at least primary and secondary servers to ensure that requests will always be answered. When changing DNS server settings, you’ll want to make sure that you specify at least two servers, although you can include more if you want.
When to Change DNS Servers
If you are using your ISP’s default DNS servers, you may get better speed and more reliable service by changing to a different DNS service. You can measure DNS resolution time by using the
dig command in Terminal and looking for the Query time. To test your default DNS server, open Terminal and type
dig hub.tutsplus.com and press Return. In this case, I’m using my home router as the DNS server and it took 179 milliseconds.
To test a different DNS server for name resolution, type
dig @126.96.36.199 hub.tutsplus.com and press Return, putting the DNS server’s IP address—in this example, one of OpenDNS’ servers—after the @ symbol. This query and response was much faster: 43 milliseconds.
Changing your DNS servers has the potential to speed up your internet browsing experience, particularly if you surf or visit a large number of sites. In the above example, OpenDNS was faster than the default DNS server by 136ms.
Many sites include images or other resources from a number of domains and subdomains. If you add up the name resolution speed difference for every domain you visit or use, you can see how changing your DNS can speed up your internet browsing experience, shaving seconds off of a page load time.
Where to Change DNS Server Settings
If you have decided to change your DNS settings, you have a couple of options. One is to make the change on your router; this may give you the best results since every device using that router will get the benefit of the change. You could also make the change on your Mac; that may save just a little extra time since your Mac will ask the DNS servers directly rather than asking the router which then asks the DNS servers. However, you may experience unexpected issues if you set the servers on your Mac, especially if you use it at work. See Reasons Not to Change DNS Servers below for more details.
How to Change the DNS Servers on a Mac
Open System Preferences and click on the Network icon. Unlock the pane if necessary by clicking on the lock icon and entering your password. Click on the Advanced button, then on the DNS tab. Click the + button and add at least two DNS servers, then press OK and Apply.
If you use WiFi, ethernet, and other types of connections, you’ll want to follow the same steps for each interface.
How to Change the DNS Servers on Your Router
If you have an Apple Airport or Time Capsule router, open Airport Utility in your Applications/Utilities folder, click on the device’s icon, click on the Internet tab, and enter the new DNS servers in the appropriate boxes.
If you don’t have an Apple router, log in to the router’s administration panel and look for DNS. Add the addresses and apply the changes.
Advanced Benefits of Changing DNS Servers
Depending on the DNS service you choose to use, there may be some additional benefits. For example, OpenDNS offers OpenDNS Family Shield, a service which automatically blocks adult content.
They also offer OpenDNS Home, allowing you to select from 56 categories to block on your home network. Other advanced benefits might include blocking known phishing or malware domains and detecting typo-squatting, for instance, by blocking twlttr.com or simply redirecting it to twitter.com.
Reasons Not to Change DNS Servers
If you try to use a DNS service hosted in another country, you may actually slow down your browsing experience because it will take longer to resolve domain names. Make sure you choose one with servers close to you; most major DNS services have servers spread across the world and use anycast routing so you always reach the closest one.
If you use your computer in a corporate environment, changing DNS servers may cause some unexpected issues. For instance, my workplace has a server named master; if I change the DNS servers on my computer, it won’t know where to find master, unless I manually edit the /etc/hosts file.
In this tutorial, I’ve taught you what DNS is and what it does, how to change the settings, and some advanced benefits you can use. Will you be changing your DNS settings to take advantage of these benefits?
Subscribe below and we’ll send you a weekly email summary of all new Computer Skills tutorials. Never miss out on learning about the next big thing.Update me weekly
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!Translate this post