Mobile app version of vmapp.org
Login or Join
Moriarity557

: How to edit /etc/hosts file on WHM/cPanel I need to add a domain/IP record to my hosts file on a CentOS box running WHM/cPanel, so that a domain which has no public DNS is routed to the

@Moriarity557

Posted in: #Cpanel #Dns #Whm

I need to add a domain/IP record to my hosts file on a CentOS box running WHM/cPanel, so that a domain which has no public DNS is routed to the correct IP address.

I've done this on my macbook but I'm unsure of the process on cPanel.

When I nano /etc/hosts I see the following:

# Automatically generated by OnApp (2.3.1)
127.0.0.1 localhost
1.2.3.4 s1.mydomain.com


So - if the contents of this file are automatically generated:


Is it safe to edit this file manually - or will cPanel wipe my changes during updates etc?
Does WHM/cPanel have an GUI for adding hosts records?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Moriarity557

2 Comments

Sorted by latest first Latest Oldest Best

 

@Radia820

It is perfectly acceptable to update /etc/hosts in cPanel/WHM.

As a rule of thumb, incase of an update which may change the file (unlikely, cPanel doesn't tend to touch it after the initial install phase) run this command to take a backup.

# cp /etc/hosts /etc/hosts.bak


This will copy your hosts file to a new file in your etc directory called hosts.bak which you can rename to hosts again at anytime incase you need to revert any changes.

At current, cPanel does not provide a GUI for updating your hosts file however, if this is a feature that you feel will benefit others, you can submit a feature request where others can vote on and discuss your request.

10% popularity Vote Up Vote Down


 

@BetL925

Yes, you can safely add entries to the hosts file. The only thing you might need to consider is that the entries may be erased if you update WHM/Cpanel.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme