I'm using Cloudflare (no proxy) to manage DNS Records. I have two servers with IP:
- 128.xxx.xxx.xxx
- 174.xxx.xx.x
And these are the DNS Records that I have created:
Type | Name | Content |
---|---|---|
A | example.com |
128.xxx.xxx.xxx |
CNAME | sub1 |
example.com |
CNAME | sub2 |
example.com |
CNAME | sub3 |
example.com |
Now, I want to point the main domain (example.com) to the new IP (174.xxx.xx.x), the subdomains (sub1, sub2, sub3) keep using 128.xxx.xxx.xxx.
I could of course change the DNS records for each subdomain to type A by pointing all subdomains to IP 128.xxx.xxx.xxx like this:
Type | Name | Content |
---|---|---|
A | example.com |
174.xxx.xx.x |
A | sub1.example.com |
128.xxx.xxx.xxx |
A | sub2.example.com |
128.xxx.xxx.xxx |
A | sub3.example.com |
128.xxx.xxx.xxx |
The problem is, I have a lot of subdomains and the number is growing, I don't want to manually write the IP for the subdomains, apart from many, I'm also worried that I will switch servers with different IP addresses later.
Is there any way to solve this problem?
I really appreciate any answer, thanks in advance.
CodePudding user response:
This should be easy to solve by simply having a single 'A' record for your secondary IP address (could be sub1, or could be an unused name).
Then all your other subdomains will be CNAME records pointed at the subdomain with that A record (128.xxx.xxx.xxx
). That way when it comes time to update, you'll just update that single A record.
Example -
Type | Name | Content |
---|---|---|
A | example.com |
174.xxx.xx.x |
A | secondary.example.com |
128.xxx.xxx.xxx |
CNAME | sub1.example.com |
secondary.example.com |
CNAME | sub2.example.com |
secondary.example.com |
CNAME | sub3.example.com |
secondary.example.com |