dnscname

How to setup/mock CNAME record locally for a dev environment


I need to setup a CNAME record locally. The use case is that I have a domain which is being hit in production and I want to change the production DNS settings but I want to verify my setup works by testing the setting locally before I change it in production.

Currently my domain is setup like this: A mydomain.com some.ip.addre.ss

I want to change it to CNAME mydomain.com somecnameaddress.com

I am able to test A record changes by modifying my hosts file but I cannot do this to test CNAME records. How would I go about doing this?


Solution

  • For IP address mapping - You can do this by adding a entry in your local /etc/hosts file instead of updating the CNAME. Just add Your live domain and IP address of you test environment, it should work.

    For CNAME mapping - You need to use a dns server opensource or hosted is your choice.