How to change the IP to which the domain points locally (configure hosts file)

How to change the IP to which the domain points locally (configure hosts file)

In certain situations we want to view the content of a hosting different from the one the domain points to. For example, when performing a migration from another provider to cdmon while the domain is still pointing to them, but we want to check whether the content on the cdmon server has been completed correctly.

IMPORTANT: We would like to point out that this change only affects your device. In other words, people who access the domain will still access the public IP of the domain; this change only applies to the device where it is made. This allows you to see how the hosting responds for a domain different from the one it publicly points to.

To modify the IP that the domain points to only on our device, we must configure the hosts file on our computer.

The process is slightly different depending on the operating system we use. In Windows it differs from Mac and Linux:

How to configure the hosts file in Windows

We must go to the hard drive where our Windows system is installed. Once there, the hosts file is located in Windows/System32/drivers/etc
 

Next, we will edit the hosts file. To do this, double-click on the hosts file and it will ask which program we want to use to edit it. We will select Notepad to make the changes:


This file requires administrator permissions to run, so if we are not using the administrator user we must run the file as administrator by right-clicking:



Once inside the file, we must enter the domain name we want to modify and the hosting IP it should point to. Example:



As indicated, we must enter the hosting IP we want to visualize and the domain that should point to that IP.
 
The hosting IP of cdmon can be obtained from the server information in our control panel.
 
Finally, when accessing the domain (in the example domain.com) it will respond using the assigned IP.
 
IMPORTANT: If we want to revert the changes, we only need to access the hosts file in the same way and delete the lines we added.
 
How to configure the hosts file in Mac and Linux
 
The process on these operating systems is much simpler, since we can do it quickly from the terminal.
 
To do this, we must open the terminal/console from our applications:


Next, we must run sudo nano /etc/hosts and it will ask for our user password, which we must enter:


We will now be inside the hosts file, so we must enter the domain name and the hosting IP as shown in the following image:


The hosting IP of cdmon can be obtained from the server information in our control panel.
 
IMPORTANT: If we want to revert the changes, we only need to access the hosts file in the same way and delete the lines we added.
 

For more information, you can   contact us .
    • Related Articles

    • Information and uses of the .htaccess file

      1.- What is a .htaccess? The .htaccess (hypertext access) file is the default name for Apache’s directory-level configuration file. It is used to customize the configuration of directives and parameters defined in the main hosting configuration file. ...
    • How to modify hosting file permissions

      From the cdmon Control Panel, in the hosting management, you can modify the permissions of your website's files and directories. To change permissions, in the 'Security' section click on the option File and folder permissions In this section you can ...
    • How to change the domain of accommodation

      To modify the domain name associated with the hosting, you must access the hosting management section. You can access it from the "Basic service list". Once you have accessed the hosting management section, you can modify the domain associated with ...
    • How to configure cdmon services with external DNS

      There may be several reasons why you have decided to manage your own DNS records: a preference for a specific provider, the need to keep domain management centralized, or simply a strategic choice for your setup. In this guide, we will show you the ...
    • How to change file and directories from webFTP and from Filezilla

      When we create a new file or make changes to the hosting, it is possible that the permissions of these files are not correct and therefore we cannot perform the necessary actions. Below we will explain how to change file and directory permissions ...