28

Let's say I have a website example.com which I bought via a common domain registry nomcheap.com.

I want all traffic to a specific subdomain app.example.com to go to name server ns1.appserver.com so I can serve a specific user app.

I also want all other traffic (www.example.com, hello.example.com, *.example.com, etc.) to go to a different name server from a different provider ns1.squaresites.com so I can serve a general website (think something like a commerce Wordpress site).

None of the name servers are provided by the original domain registry nomcheap.com.

Is this possible? If so, any suggestions on how?

openwonk
  • 14,023
  • 7
  • 43
  • 39

2 Answers2

38

To point a subdomain to a name servers you need to create an NS record for the subdomain:

app.example.com NS ns1.appserver.com

This will make all queries go to ns1.appserver.com

*.example.com NS ns1.squaresites.com

The second record should catch all subdomains that don't have their own records (of any kind).

Lanexbg
  • 1,071
  • 1
  • 12
  • 17
  • 2
    and when there needs to have ns1,ns2 and ns3 (three nameservers) what to do? DNS ZONE EDITOR has only 1 field when adding NS/A/CNAME record – T.Todua Oct 01 '18 at 19:39
  • 3
    Can't you add three different records one at a time? – Lanexbg Oct 02 '18 at 04:47
  • 1
    To further clarify, should the name servers be ns1.d1.com, ns2.d1.com, ns1.d2.com, ns2.d2.com? Or should they be ns1, ns2, ns3, ns4? – Keegan Teetaert May 03 '19 at 14:45
  • 2
    For me (namecheap.com registrar) it only worked when I had the subdomain "app" as the value, not the full subdomain "app.example.com" – cpres Sep 25 '19 at 21:15
3

Delegating name server DNS responses can be done was the answer by @Lanexbg describes.

Realize that chaining your DNS lookups this way adds more time to DNS resolution and adds another potential point of failure in the resolution process. If the parent's name servers are down, they won't able to deliver the NS records to tell the client's resolver to continue the lookup process through a delegated name server.

Consider if using DNS "A" or "CNAME" records at the parent's DNS server would be acceptable alternative.

For more detail on how DNS resolution is delegated see this answer on serverfault.com:

Mark Stosberg
  • 12,961
  • 6
  • 44
  • 49