Do you want to speed up your Internet connection?
Maybe it seems like web pages are taking longer to load, or maybe you simply like the idea of a faster Internet connection (and let’s be honest, who doesn’t like the idea of a faster Internet connection?)
One of the most effective ways of cutting the time it takes your Mac to load a web page, is to change your DNS (Domain Name Service) settings.
Every website is assigned an IP (Internet Protocol) address, which is a string of numbers. The problem is that a long string of (seemingly) random numbers isn’t the easiest thing for the human brain to remember, so a DNS is the system that’s responsible for translating these numerical IP addresses into the more human-readable domain names we’re all familiar with.
Whenever you type a URL into your browser’s address bar, your Mac contacts a DNS server and gets the IP address associated with that domain name. How quickly this lookup can be completed determines how quickly (or slowly!) your web browser will load the website you’re trying to access.
While most Macs will use the DNS from your Dynamic Host Configuration Protocol (DHCP) or Wi-Fi router, you’re under no obligation to use this particular DNS, and can often improve the speed of your connection by switching to a different DNS.
In this article I’m going to show you how to use Google’s Namespace app to find the DNS server that offers the best performance for your particular Mac and your exact location, and how you can switch your Mac to these new DNS settings. Along the way I’ll also be sharing some troubleshooting tips, as well as a quick Terminal command that lets you see exactly how long your DNS lookups are taking.
Put your DNS Settings to the test
The quickest way to gauge how your current DNS settings are performing, is to test how long it takes your Mac to query a DNS server. By performing this test before and after editing your DNS settings, you can see exactly what impact your changes have made to your Internet connection.
You can run this test via your Mac’s Terminal, so launch a ‘Finder’ window and select ‘Applications > Utilities > Terminal.’
Type the following command into the Terminal window:
Then, press the ‘Enter’ key on your keyboard.
This returns a range of information, but we’re only interested in the ‘query time,’ which is how long it took the DNS server to provide an answer to your query. Make a note of this value, so you can see exactly how your query time changes after you’ve updated your DNS settings.
Find the Best DNS Server for your Mac
While many of these servers do perform better than their ISP equivalents, there’s no guarantee that they’ll result in faster Internet for you specifically, so you should always test how these public servers compare to your current DNS settings.
One of the most effective ways of testing these public servers, is to use Google’s Namebench. This free app tests your current DNS settings against all the most popular public DNS servers, including GoogleDNS and OpenDNS, as well as some smaller, lesser-known DNS servers that are available in your local area. If Namebench does identify one or more servers that are faster than your current settings, then it’ll display their full DNS addresses, ready for you to enter this information into your Mac.
To get started, download the latest version of Namebench, then install and launch it.
By default, Namebench should display your current DNS settings in its ‘Nameservers’ field. However, if this field is blank then you can always locate your current DNS address manually:
- Click the ‘Apple’ logo in your Mac’s toolbar and select ‘System preferences….’
- Click ‘Network.’
- Select the interface you’re using to connect to the Internet, such as Ethernet or Wi-Fi.
- Click the ‘Advanced…’ button.
- Select the ‘DNS’ tab.
- You’ll find the address of your current DNS server, in the ‘DNS Servers’ section – it’s the set of numbers separated by colons. Type this information into Namebench’s ‘Nameservers’ field.
By default, the Namebench app should launch with the following checkboxes selected:
- Include global DNS providers. Namebench will check your current DNS server against all the most popular DNS providers.
- Best available regional DNS services. Namebench will check for smaller, lesser-known DNS services that are available in your local area.
It’s recommended that you leave both of these checkboxes selected, unless you have a very good reason for deselecting either of them.
To start Namebench running, give the ‘Start’ button a click. Just be aware that testing multiple DNS servers can be a time-consuming process, so you may want to leave Namebench running in the background while you go do something else.
Once Namespace has completed its tests, it’ll display its report in a new tab in your default browser. This report contains lots of information, but you should pay particular attention to the three recommended DNS servers in the report’s upper-right corner: the Primary, Secondary and Tertiary server, as these are the servers that you’ll typically want to switch to. Namebench also displays the estimated performance boost that you can expect if you switch to its recommended ‘Primary server.’
For the best results, you should use Namebench’s recommended ‘Primary server’ as your main DNS server, and then optionally add the Secondary and Tertiary servers as backups, in the event that your Mac can’t connect to the Primary server.
Changing your DNS Configuration
To change your DNS settings:
- Open your Mac’s ‘System preferences…’
- Select ‘Network.’
- Select the interface you use to connect to the Internet, then click ‘Advanced.’
- Select the ‘DNS’ tab.
- Click the ‘+’ button directly beneath the ‘DNS Servers’ list.
- Enter the DNS server address, exactly as it appears in your Namebench report.
- Press the ‘Return’ key on your keyboard.
If you want to add multiple DNS addresses, then click the ‘+’ icon and add each address separately. Never try to enter more than one DNS address per line.
By default, any new DNS servers will appear below your original DNS settings. The order your DNS servers appear in this menu is crucial, as your Mac will always query the topmost DNS server first, and will only move onto subsequent servers in the list if it doesn’t receive a response. For the best results, you should place your best performing server at the top of the list.
You can rearrange the servers in your list using drag and drop, although if you want something more permanent you can always delete your original DNS settings.
To remove a DNS server from this list, select it in the left-hand menu and then click the little ‘-’ icon. Repeat for every DNS entry you want to remove.
Once you’ve finished making your changes, save them by clicking the ‘OK’ button, followed by ‘Apply.’ You can now start browsing with your new DNS settings!
If any Internet-enabled applications were open while you were editing your DNS settings, then it’s possible that you may encounter some issues with these applications. You can usually resolve these errors simply by quitting and then relaunching the misbehaving application.
If you want to check how your DNS changes have impacted your Internet connection, then open your Mac’s Terminal, re-enter the ‘dig’ command and then check how the new query time compares to the old one.
How to Change DNS from Command Line
Changing your DNS settings via the ‘System Preferences’ menu may be the most intuitive method, but if you’re comfortable with Terminal commands then you can usually update your DNS settings much more quickly, from the Terminal.
To add a new DNS server to your list, launch the Terminal and enter the following command:
networksetup -setdnsservers (Network Service) (DNS IP)
Replace ‘Network Service’ with the interface you use to connect to the Internet, and replace ‘DNS IP’ with the new DNS settings you want to use. For example, if you wanted to change your Mac’s Wi-Fi interface to use Google’s 188.8.131.52 DNS, then you’d enter the following command:
networksetup -setdnsservers Wi-Fi 184.108.40.206
You can also use this command to add multiple DNS servers at once, for example:
networksetup -setdnsservers Wi-Fi 220.127.116.11 18.104.22.168
Finally, you can check your current DNS settings from the command line:
networksetup -getdnsservers Wi-Fi
Flushing your DNS Cache
If you’ve updated your DNS settings and haven’t noticed any performance benefits, or you’re encountering longer loading times and DNS lookup errors, then it’s possible that your Mac hasn’t properly registered your new DNS settings. You can often solve this error by clearing your DNS cache, in a process known as “flushing.”
The easiest way to flush your cache is via the Terminal. The exact command will vary depending on your version of macOS, so work your way through the various possible commands until you find the one that works for your particular Mac:
sudo killall -u _mdnsresponder mDNSResponder
sudo killall -HUP mDNSResponder
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder.
Enter your admin password when prompted, and then wait a few moments for the DNS cache to be cleared.
Speed Up Your Mac in 3 Easy StepsiDoctor will improve your Mac performance and make it run almost as fast as it was when you bought it.
- Download & Install iDoctor
- Diagnose your Mac for problems
- Remove all items safely