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

3

8

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?

Crashland answered 13/8, 2018 at 23:59 Comment(1)
You can't create a CNAME for the root domain, it has to be for a subdomain. So you can just create a live CNAME record for some subdomain, check if everything is okay and then change the hostname to the www subdomain (if it also needs to point to somecnameaddress.com. As for the root domain, probably it will be best to create a web redirection/forwarding from mydomain.com to www.mydomain.com, after you make the CNAME for www.mydomain.com and it propagates.Stoddard
S
-20

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.

Sentimentality answered 14/8, 2018 at 11:58 Comment(1)
A CNAME record maps aliases one domain name to another domain name. A hosts file maps a domain name to an IP address. This answer does not answer the specific question and is wrong.Alsacelorraine
P
8

/etc/host cannot point cname

i use dns server (open source)

Technitium https://technitium.com/dns/ u create zone and point to cname

Perineum answered 16/2, 2021 at 18:55 Comment(0)
P
0

If you are testing APIs etc the Telerik Fiddler application has a HOSTS function which accommodates local CNAME changes as well as A records to override the windows hosts file.

Override Windows HOSTS file

Phrensy answered 13/9, 2021 at 12:40 Comment(0)
S
-20

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.

Sentimentality answered 14/8, 2018 at 11:58 Comment(1)
A CNAME record maps aliases one domain name to another domain name. A hosts file maps a domain name to an IP address. This answer does not answer the specific question and is wrong.Alsacelorraine

© 2022 - 2024 — McMap. All rights reserved.