How to test CNAME on local machine, without having a DNS server

You cannot test a CNAME URL on your local machine without having a DNS server installed. To be able to test that like IP addresses on “hosts” file, you need to get its current assigned IP address by just pinging it.

1. Ping and get the IP

ping cname.domain.comCode language: Bash (bash)

You’ll see the IP address there.

2. Then you can add it to the “/etc/hosts” file on your computer.

xxx.xxx.xx.x   www.testdomain.comCode language: Nginx (nginx)

This is useful for testing load balancers or any other services which provide CNAME to point.


Posted

in

, ,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.