17

I have a domain example.com, and subdomains a.example.com and b.example.com on a production server.

I also have a development server dev.example.com, with subdomains a.dev.example.com and b.dev.example.com.

Both of these servers are running their own DNS.

Is there a way to setup DNS so all dev.example.com and *.dev.example.com entries are located and configured on the dev.example.com DNS?

Basically, I want all of the subdomain lookups to go to my development server. This way I don't have to log onto a separate server to manage DNS for my development box.

Jesse
  • 217
  • 3
  • 12
muncherelli
  • 759
  • 1
  • 4
  • 22
  • 3
    If not, how could "google.com" go on a different server from "serverfault.com"? Wouldn't they both have to be on the ones that handle "com"? – David Schwartz Mar 16 '16 at 06:27
  • I don't think you can without programming. You want to resolve *.dev.example.com ---> *.example.com Alias can solve but is an static solution. I think you're looking for a dynamic solution right? – Oscar Perez Mar 16 '16 at 05:44

3 Answers3

22

The other answer made the assumption that:

You want to resolve *.dev.example.com ---> *.example.com

But that's not how your question seems to read. It sounds to me like you want to delegate control over the dev.example.com domain to your own machine. If that's the case, then the delegation is easy:

  • On whatever machine is your nameserver for example.com, you'd add an NS record that says your dev machine is the nameserver for dev.example.com
  • You'd also add a glue record, an A record giving the IP of your dev machine.

In your case, if this is Bind, you'd have something like this on the nameserver for example.com:

$ORIGIN dev.example.com.
@             IN      NS     dev.example.com.
dev           IN      A      1.2.3.4 

And then on your dev machine you'd set up Bind to be authoritative for dev.example.com (You're on your own for this part, but it's straightforward.)

Ward - Trying Codidact
  • 12,899
  • 28
  • 46
  • 59
  • Yes, this is exactly what I was looking for. I'm not sure why my question got voted down so much. Did I say something wrong? – muncherelli Mar 18 '16 at 03:01
  • 1
    @muncherelli The downvotes might be because it wasn't completely clear what you wanted to do. I thought it sounded like you wanted to delegate nameserving to your dev machine and answered that. – Ward - Trying Codidact Mar 18 '16 at 03:07
  • I did not downvote the question, but I might have on the basis not only that it's unclear but on the basis that questions are supposed to demonstrate basic understanding of the subject matter, and both subdomain delegation and wildcard IPs are really very basic functions of DNS. – Law29 Mar 18 '16 at 04:51
  • 1
    I didn't know I needed to prove my basic understanding of DNS to ask a question. I've been making websites for over 15 years and I've never done this before. – muncherelli Apr 01 '16 at 13:35
  • That a great answer, but what happens if the IP changes? If the server of dev moves to `1.2.3.5`? – João Pimentel Ferreira Aug 05 '19 at 20:07
  • @JoãoPimentelFerreira If the IP changes, first you need to change the IP address at your domain's glue record. Then change the IP address in zone file in your `dev` machine. – Hasanuzzaman Sattar Jun 11 '22 at 11:49
  • What is the role of the "glue record" here? Is it not enough to set the nameserver for the subdomain and then set A/AAAA records in the subdomain's zone file on that nameserver? – balu Aug 06 '22 at 18:08
6

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.

Law29
  • 3,557
  • 1
  • 16
  • 28
0

If I understand correctly your use case, you might have some luck in setting up a local DNS with PowerDNS and it's recursor functionality https://www.powerdns.com/recursor.html

You can then use the forward-zones to delegate the resolution to various zones see the (not so great) documentation : https://doc.powerdns.com/md/recursor/settings/#forward-zones

I've heard good things about UnboundDNS https://unbound.net/ which should be able to provide solutions for this scenario too.

Arthur Lutz
  • 375
  • 3
  • 11