Question
How can I view my site without pointing DNS?
There are three methods to access your domain before pointing DNS, each with their own caveats.
- Hosts file
- cURL
- mod_userdir
Answer
Hosts File Modification
As long as your domain isn't pointing to an IPv6 address, such as with CloudFlare, it is relatively easy to see how your site is going to look once it's pointed.
First, you can confirm that there
To accomplish this, modify your local computer's hosts file.
How to Modify Your Hosts File | cPanel Docs
You'll need to add a line for the domain you're trying to visit, as well as any subdomains or add-on domains you're trying to test:
1.2.3.4 domain.tld www.domain.tld subdomain.domain.tld add-on-domain.tld
Save this file, then attempt to load the site in your web browser.
cURL
You might also consider reviewing the curl method if you just need to test some simple things on your website:
How to use curl to diagnose site issues on an IP that does not match the current A record
mod_userdir
We have a whole separate guide for using mod_userdir, as it has its own requirements and caveats and may require server configuration to enable:
How to use mod_userdir to access sites via IP address and username
Resources
If there is more than one IP address bound to the server, then which one I need to include in the host file?
You need to point the domain to the IP address for the account. The correct IP might not necessarily be the main IP address of the server. On a cPanel server, you can find out which IP address a domain uses by running the following command:
egrep -i "^domain.tld" /etc/userdatadomains | awk -F "==" '{ print $6 }' | awk -F ":" '{ print $1 }'
Alternatively, open the file /etc/userdatadomains with a text editor such as "less" and find the domain's line. The IP returned from that command is the IP address that Apache uses for the domain. Take note of that IP for the next command.
Next, check if your system is behind a NAT:
grep 'IP' /var/cpanel/cpnat
If you see:
cat: /usr/local/cpanel/cpnat: No such file or directory
you can use the IP address you've found to connect to the domain, otherwise, review the output for the mapped public IP, 'EXTERNAL_IP' in this example output:
example-host~# grep IP /var/cpanel/cpnat
IP EXTERNAL_IP
If you're using a NAT system, you can view the full mapping table with this command:
cat /usr/local/cpanel/cpnat
For more information: How do I know if an IP address is internal or public?