Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different name servers for different subdomains

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?

like image 876
openwonk Avatar asked Dec 14 '17 07:12

openwonk


People also ask

Can I use different nameservers for different subdomains?

DNS Made Easy lets you assign different nameservers to any of your subdomains. This means you will be using two providers at the same time: one at the root level and one at the subdomain level.

Can I have 2 different nameservers?

At a minimum, you'll need two DNS servers for each Internet domain you have. You can have more than two for a domain but usually three is tops unless you have multiple server farms where you would want to distribute the DNS lookup load. It's a good idea to have at least one of your DNS servers at a separate location.

Can a subdomain have a different DNS?

Yes, without a problem, this is one of the basic functions of DNS. On the DNS server for example.com, you define the IP for dev.example.com, and that the NS for dev.example.com is dev.example.com, and on dev.example.com you define all the sub-names of dev.example.com.

Can a domain have different name servers?

You sure can. For example, where I work, we have 4 name servers, 2 hosted with one DNS host, one hosted by us, and the other one hosted by a second external DNS host.


2 Answers

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).

like image 166
Lanexbg Avatar answered Sep 19 '22 16:09

Lanexbg


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:

  • How exactly should I set up DNS to delegate authority for subdomains?
like image 37
Mark Stosberg Avatar answered Sep 21 '22 16:09

Mark Stosberg