0

Suppose I acquired both a.example and b.example two domains. The goal is when I config somepage.a.example to point at an IP address, somepage.b.example can also resolve to this address. That means any lookup to *.b.example will be the same to *.a.example

As I consider, maybe some DNS provider offers something like automatic DNS mirror? or is there a way to use *.a.example for *.b.example DNS resolve?

3 Answers 3

1

You can use the slightly uncommon RFC 6672 DNAME DNS record which provides redirection for a subtree of the domain name tree in the DNS. That is, all names that end with a particular suffix are redirected to another part of the DNS.

A DNS record:

example.com. IN DNAME example.net. 

will redirect:

a.example.com.   -->   a.example.net.
b.example.com.   -->   b.example.net. 
c.d.example.com. -->   c.d.example.net.
etc. 

You will only need to manually maintain every record for example.com. that exists at the same level as the DNAME record:

example.com.  IN  SOA   ns1.example.com. username.example.com. ( 
                               20140218131405 ; Serial number YYYYMMDDHHMMSS
                                        28800 ; Refresh     8 hours
                                         7200 ; Retry       2 hours
                                       604800 ; Expire      7 days
                                        86400 ; Minimum TTL 1 day )
example.com.  IN  NS    ns1.example.net.      ; ns1.example.net is a primary nameserver
example.com.  IN  NS    ns2.example.net.      ; ns2.example.net is also a nameserver
example.com.  IN  MX    10 mail.example.net.  ; mail.example.net is the mailserver
example.com.  IN  MX    20 mail2.example.net. ; the secondary mailserver
example.com.  IN  A     192.0.2.1             ; IPv4 address for the bare domain
example.com.  IN  AAAA  2001:db8:10::1        ; IPv6 address for the bare domain
example.com.  IN  DNAME example.net.          ; every record <something>.example.com will 
                                               ; get mapped to  <the same something>.example.net.

Please note that the RFC lists some issues, which may of import to you too.
Also, I'm not sure if you can have exceptions in the example.com zone file for records which should not get mapped to the corresponding example.net record, i.e. if the presence of a record such as old-www.example.com. IN A 192.0.2.2 will continue to work and will be preferred to the DNAME mapping of old-www.example.com. --> old-www.example.net.

3
  • Amazing!!! This is the exact what I need, unfortunately the DNS provider I'm using now (CloudFlare and DNSPod) don't support DNAME entry currently.
    – BH4EHN
    Feb 12, 2019 at 9:34
  • "f you can have exceptions in the example.com zone file for records which should not get mapped to the corresponding example.net record" I do not think you can based on section 2.4 of the RFC: "Resource records MUST NOT exist at any subdomain of the owner of a DNAME RR. [..] A server MAY refuse to load a zone that has data at a subdomain of a domain name owning a DNAME RR. If the server does load the zone, those names below the DNAME RR will be occluded as described in RFC 2136 [RFC2136], Section 7.18." Feb 13, 2019 at 17:00
  • @YankeeYu It is very probable/possible that you will not find anyone providing it and you will be able to use it only if your maintain your nameservers yourself. Why? Because people discovered many problems with it, like HBruijn said, and in fact it resolves a technical problem that does not map exactly to what people wanted (as there is often misconceptions about the DNS). AFAIR the .CAT TLD heavily used them... before stopping altogether. See datatracker.ietf.org/meeting/97/materials/… for example. Feb 13, 2019 at 17:03
0

I don't think a DNS mirror service exists because it has a limited use case however, with amazon route 53, you can write a powershell script to create domain records for all your zones. Check out this script which will create a cname for all your hosted zones. You could use this as a template where it inputs one A records and then creates that record for both domains.

0
0

There's no reason why two different domain names can't point to the same IP address.

Conceptually, just configure the dns server for b.example to have all the same data as the server for a.example. If it was a small domain and you were manually updating dns data files, it would be simple to add the same records to two different files.

Whether it can be done automatically depends on the details - are the same dns servers being used for both domains? who's running the servers? Assuming it's the same provider, it could be very easy to do, but only if the provider supports it.

3
  • thanks for answer, but manually config is laborious and easy to goes wrong, so I'm looking for a better way.
    – BH4EHN
    Feb 12, 2019 at 8:38
  • "manually config is laborious and easy to goes wrong" kind of true but if the two zones are strictly the same you need only one zonefile and just instruct your nameserver to configure 2 zones with the exact same zonefile. Some DNS providers offer a way to separately define zone content, and association between a given zone and some content, in which case you can achieve the same result. Feb 13, 2019 at 15:19
  • This problem ends up with I wrote a script that sync with dns provider of a.example and b.example. I Manually execute this script after every time I modify either of these two.
    – BH4EHN
    Feb 14, 2019 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.