19

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.

2
  • 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? Commented Mar 16, 2016 at 5:44
  • 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"? Commented Mar 16, 2016 at 6:27

3 Answers 3

23

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

7
  • 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? Commented Mar 18, 2016 at 3: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. Commented Mar 18, 2016 at 3: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
    Commented Mar 18, 2016 at 4: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. Commented Apr 1, 2016 at 13:35
  • 1
    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
    Commented Aug 6, 2022 at 18:08
7

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.

1
  • This was a great answer too, gave the point to @Ward due to more explanation. Commented Mar 18, 2016 at 3:11
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .