The DNS (Domain Name System) is the internet’s phone book, as we all know. However, did you realize that your computer’s hosts file can also be utilized as a domain name directory? This post will explain what the hosts file is and how to update it to simulate a DNS change in Windows 10, Linux, and Mac.
In a nutshell, a hosts file is a local file that contains domain names and the IP addresses that correspond to them. It’s included in all major operating systems and serves as a map for identifying and locating IP network hosts.
Your computer will check the host’s file every time you visit a website to see which IP address it connects to. If the information is missing, your internet service provider will hunt up the resources needed to load the site in the DNS.
When you’ve recently purchased a domain, you can take advantage of the circumstances described above. Alternatively, if you’re moving your website to a new hosting provider and need your domain to point to the new server. It usually takes 24 to 48 hours for your domain to start working, and you won’t be able to view your site during that period.
You can access your website by modifying the hosts file and adding a custom IP address that links to your domain. This is useful if you want to modify your site after migrating and see how it’ll look on the new server.
The hosts file is formatted in plain text. As a result, you can change it using any text editor, such as Notepad.
Keep in mind, however, that the modifications will only affect the system where the hosts file is located.
You’ll need an IP address for your domain before we start:
Let’s go over to the hosts file and make some changes. For Windows 10, there are two options: manually or via the Hosts File Editor tool. In general, the instructions below can be used with any version of Windows.
Using the Hosts File Editor is a more convenient approach to edit the hosts file in Windows 10.
On Linux, you can complete the job with your favorite text editor. In this case, we’ll utilize Gedit in Ubuntu. By using Ctrl+Alt+T, you can access the Terminal.
sudo gedit /etc/hosts
Follow these instructions to modify the hosts file if you’re running macOS from Leopard (10.6) to the most recent version:
The Nano editor will be used. Insert the following command to run it as an administrator:
sudo nano /private/etc/hosts