Add a local DNS lookup to Hosts file

When you type a website URL into the address bar of your browser, a request is sent to a type of Internet server known as a domain name server† This server takes the URL you typed and then checks to see what specific IP addresses are listed for the actual servers hosting the content you’re looking for.

The problem with this is that if there’s something wrong with the name server, you won’t be able to access the correct site. Even worse, if the name server is hijacked, you could end up on a fake site! The good news is that you can manually specify the link between specific IP addresses and website addresses, simply by adding a local DNS lookup to your “hosts” file.

What is the Hosts file?

The hosts file is easy to understand. It’s just a plain text file. By the way, this is why you should just edit the file with something like Notepad, which won’t try to resize or add extra formatting to the file.

In the hosts file, you can add a list of IP addresses, along with the web address that the IP address should point to. You can combine each IP address and web address, even if they don’t really go together. You can point the actual IP address for Bing.com to Google.com if you wish.

Windows will always check the hosts file first before sending a request to a name server. So if an address you type into your web browser is listed in the hosts file, you will be redirected to the IP address listed in the file.

What is a local DNS lookup?

The process described in the previous section is a local DNS lookup. Your computer will look up the IP address itself from your local disk, without having to contact a remote server. It’s that simple!

Why add a local DNS lookup to the hosts file?

There are a few reasons why you might want to add a local DNS lookup to your hosts file. We already mentioned a few reasons at the beginning of the article, but people have found quite a few creative ways to use this simple feature.

A major reason to add entries to your hosts file is speed. It will always be faster to do a local search than going to a remote server. Especially if that server is unreliable. By putting your most important or frequently used sites in the hosts file, you never have to worry about your DNS service causing access problems.

You can also use the hosts file to block sites that you don’t want that computer to access. All you need to do is put an IP address in the hosts file for that site that either isn’t going anywhere or points to a benign IP address. Common redirects are 0.0.0.0 and 127.0.0.1. This is the so-called “loopback” address. View our Youtube video for more details on that.

If you have local devices such as routers, IP cameras, network attached storage, and so on, you can use your hosts file to give their IP addresses an easy-to-remember name.

Using Pre-Created Hosts Files

If adding dozens or even hundreds of sites to your hosts file sounds pretty tedious, then you’re not alone! The good news is that there are plenty of places on the web where you can find pre-made lists that you can simply copy and paste into your own hosts file.

The main problem with this is that malicious redirects can be hidden in these lists. That means you either have to manually verify each IP address or make sure you trust the source of the list.

Editing the Hosts file in Windows 10

Since the hosts file leaves some room for mischief, you can’t just open and edit it. You need administrator rights on your computer to make changes. Before making any changes to your hosts file, we strongly recommend that you copy the original content and paste it into another text file in case something goes wrong!

To change your hosts file to Windows 10Follow these steps:

  1. Open the Start menu and type “Notepad”.
  1. Once Notepad appears, right click on it and select “Run as administrator”.
  1. n Notepad, click Open and go to c:\Windows\System32\Drivers\etc\hosts and open the hosts file. Don’t forget to change the file type to “All Files”.
  1. You should see this default hosts file from Microsoft.
  1. Don’t worry about the text already in the document. You can just leave it as is and add your own entries at the bottom of the file. Any line that starts with a “#” symbol is treated as a comment and is not used for name lookups.

Adding a local search to the list is super easy. Just write down the IP address of the site, followed by a space and then the address of the website.

Don’t forget to save what you added when closing the file. That’s all you need to do! Now your computer will skip the whole DNS lookup process when accessing the sites you specified.

How to find the IP address of a website

What if you don’t know the IP address of a site you want to add to your hosts file? It’s actually quite easy to find a site’s IP address using Command Prompt in Windows 10. Here’s how:

  1. Open the Start menu and type “cmd”.
  1. Once the command prompt opens, type “tracert” followed by a space and the site you want to check. In this example, it’s ‘google.com’. Then press the Enter key on your keyboard.
  1. Here you can see the IP address of the site. You can now use this address in your hosts file.

The hosts with the most

Who would think that such a small text file, hidden deep in the Windows folder, could be so useful? Now you are a real local search guru and take control of how your computer visits websites.

Leave a Reply

Your email address will not be published.