How to edit the host file on my MacOS?

Within the multiple files that we have in our MacOs we have the host. One of the most important when it comes to saving the names of the domains and the different IP addresses that we are seeing on the internet. With it, we can make the system’s DNS work better.

 

To do this, today we bring you this guide, which will help you understand a little more about this very important file. In this way,  we will be able to see our domain name , from a different web hosting. Since in this way, we can see that everything is working correctly.

The purpose of this article is to show you a series of instructions with the appropriate commands so that you can update your host files. In addition, you will find out what it is for on a Mac.

Index( )

  1. What is editing host files for?
    1. Migrating a server without changing the DNS
    2. Work on two different servers without using changes in the DNS and nameservers
  2. What steps should I follow to edit the host file from the terminal of my MacOS?

What is editing host files for?

Within the utilities that we can do to the IP Address, such as knowing the local private LAN IP address of a PC . This is one of the utilities we can do with the host file, see these IP addresses. With this, we will be able to see the DNS of said domain, and see that IP of the pages and websites in which we are browsing.

This becomes a very important file for network protocols. In this way, the nodes that activate the host name, in the network, make it work in a better way. But they will not only be available for Mac computers, these are implicit in Windows computers and Linux operating systems.

Migrating a server without changing the DNS

Migrating a server without changing the DNS is one of the strengths of host files. Since with this, we can make changes in several web hosting, but using the same DNS that we have as a domain on the computer. In this way, we will be able to see the operation of these pages, before making a DNS change.

Work on two different servers without using changes in the DNS and nameservers

Another utility that we put the host file to do, is the work of two servers without DNS change. With this option, the secondary DNS will be copying the settings of the primary. In this way, you will be able to work from the secondary one and make the changes that we want without having an effect on the first one.

But of course, if you are using Google Chrome, you must be aware of the DNS . Since clearing the DNS cache of your browser is a very important task, since it will be slowing down the operation and performance of the browser.

What steps should I follow to edit the host file from the terminal of my MacOS?

When we talk about changing or modifying the host file, on the Mac, we have the possibility to move and merge it in our favor. In a computer like these, we can access this file from different places to modify it, but we will show you how to do it from the Mac terminal.

  • To do this, you will need to launch the terminal application on the Mac.After this, you will need to run the command ‘sudo nano /etc/hosts’. In this way, the host file will be displayed.
  • To modify this, you will have to change the command line that gets your IP, for the new IP address of the hosting you want to use. Adding the command line IP www.yourdomainname.com, changing ‘yourdomainname’, with the other host’s domain.
  • At the end of all this, you will have to press the ‘Ctrl + x’ keys to close the file, and hit ‘Yes’ to save the changes.
  • Mac AppleSupport . It does not recommend clearing caches of resolver names. Rather, you will make them have a greater effect by running the ‘dscacheuti –flushcache’ command.

With all these steps, you will successfully make the change in your host file . If you want to see if these modifications have been made correctly, you just have to ping the domain and verify the change.

Therefore it is necessary to execute the command ‘ ping –c1 www.yourdomainname.com’ . In this way, the result that it will be throwing is the indicator that the access of the new IP is correct, and that the changes have been made appropriately.

by Abdullah Sam
I’m a teacher, researcher and writer. I write about study subjects to improve the learning of college and university students. I write top Quality study notes Mostly, Tech, Games, Education, And Solutions/Tips and Tricks. I am a person who helps students to acquire knowledge, competence or virtue.

Leave a Comment