Linux Commands

Google DNS Tutorial

On 3 December 2009, Google announced its free alternative Domain Name System (DNS) service, Google Public DNS, which can be used by anyone as an alternative to other DNS providers. In this article, we explain why you should care about which DNS service you use, and we provide detailed instructions that explain how you can switch from your current DNS service to Google Public DNS.

What Is Domain Name System (DNS)?

The Domain Name System is often described as the Internet’s phonebook. It is a hierarchical decentralized naming system whose primary role is to translate domain names to IP addresses. Without DNS, the only way how we could visit any website would be to enter its IP address directly into the address bar. DNS spares us this ordeal by providing a worldwide, distributed directory service, which has been a vital part of the Internet since 1985.

These days, there are many free and public DNS services that together handle hundreds of billions of requests every single day. Despite so much choice, most people are unaware which DNS service they use because virtually all modern electronic devices assign a DNS service automatically when they first connect to the Internet via DHCP (Dynamic Host Configuration Protocol), a network management protocol that dynamically assigns an IP address and other network configuration parameters to each device on a network.

Why Should I Change My DNS Settings?

But just because your computer or router has selected a DNS service for you, most likely one operated by your Internet Service Provider (ISP), doesn’t mean that you have to keep using that service indefinitely. In fact, there are several compelling reasons to change your DNS settings.

  • Speed: Third-party DNS services promise better speeds and lower latency than DNS services of most ISPs. Google Public DNS is a prime example of a fast DNS service as it is the largest public DNS service in the world, handling over 400 billion requests per day. To find out how faster Google Public DNS is compared to your current DNS service, we recommend you download and use a DNS benchmarking tool like Namebench, which makes DNS requests to multiple DNS services and compares the results.
  • Reliability: Some ISPs are notoriously horrible when it comes to keeping their DNS servers in working order even though they may otherwise offer excellent service. If that sounds like your current ISP, the good news is that you may not need to look for available alternatives just yet. There is a good chance that switching to an alternatives DNS services, such as Google Public DNS, will solve all your problems and provide the reliable service you are looking for.
  • Security: Google Public DNS and many other alternative DNS services offer enhanced protection against DNS security threats, including spoofing attacks and Denial-of-service (DoS) attacks. For example, Google Public DNS is overprovisioning machine resources to protect against direct DoS attacks, implementing basic validity-checking of response packets and of name server credibility, adding entropy to request messages, removing duplicate queries, and much more.

How to Switch to Google Public DNS?

If we’ve convinced you that it’s worth giving Google Public DNS a try, we have good news for you: switching from one DNS service to another is very easy and takes only a couple of minutes. But before you go ahead and change any settings, you should grab a piece of paper or open a notepad on your computer so you can note down your current settings for backup purposes. If anything goes wrong (don’t worry because there’s not much that can go wrong), or you decide that you like your old DNS service more, you can just retrace your steps and use the original settings.

Changing DNS Settings Using NetworkManager

NetworkManager is a daemon that sits on top of libudev and other Linux kernel interfaces and provides a high-level interface for the configuration of network interfaces in most modern Linux distributions as well as the ability to automatically connect to both wired and wireless networks.

To switch to Google Public DNS on Ubuntu using NetworkManager, go to System > Preferences > Network Connections.

  • Select the connection for which you want to configure Google Public DNS and click on the Edit button.
  • A new window will appear, and it will contain one tab for IPv4 settings and another tab for IPv6 settings.
  • Enter the following Google Public DNS IP addresses in the corresponding DNS servers field:
    • For IPv4: and/or
    • For IPv6: 2001:4860:4860::8888 and/or 2001:4860:4860::8844.
  • Click Apply to save the new settings.
  • Test your new settings by visiting any website.
    • If the website loads as it should, your configuration is correct.
    • If it doesn’t, something is wrong, and you can either find the mistake or switch back to your old configuration.

Because every Linux distribution is slightly different, we cannot provide a single set of instructions that would cover all Linux users. If you’re having trouble finding where DNS settings are configured on your distribution, use Google to look for a distribution-specific tutorial.

Changing DNS Settings by Editing the resolv.conf File

The resolv.conf file is used in various Linux distributions to configure DNS settings. This plain-text file is human-readable, and you don’t need to be afraid to edit it—just don’t forget to create a backup first so you can revert to it later if things don’t work as they should.

To switch to Google Public DNS on a Debian server using the resolv.conf file, edit /etc/resolv.conf using your favorite text editor. Simply add the following two lines for IPv4:

  • nameserver
  • nameserver

And the following two lines for IPv6:

  • nameserver 2001:4860:4860::8888
  • nameserver 2001:4860:4860::8844

Then, save the settings and restart any Internet clients you are using. You may also optionally remove any other nameserver lines in the file to ensure that you use nothing but Google Public DNS, but it’s advisable to leave at least one alternative nameserver as a backup.

About the author

David Morelo

David Morelo is a professional content writer in the technology niche, covering everything from consumer products to emerging technologies and their cross-industry application