Programatically create subdomains with their own nameservers

Hi there,

I'm trying to setup a little service where people can register a subdomain and use it for their server by setting the corresponding nameservers of this server.

I'm wondering, how can I programatically create these subdomains with their own nameservers in an efficient way? Such that it'd be possible to have eg. a million of these subdomains?

Any advice is appreciated.

Thanks.

  • Tom

37 Replies

For a good look at how DNS works and some of the tricks you can (and cannot) use, especially in large-scale situations like this, you'll probably want http://oreilly.com/catalog/9780596100575 at the ready.

I haven't personally used it in awhile, but take a look at PowerDNS. It has been around awhile, and supports a number of databases on the back end, SQL and otherwise.

hoopycat if you ask people to not redact their host name when posting, you are asking them to not post it. Is that what you intended?

tr.v., -dact·ed, -dact·ing, -dacts.

1. To draw up or frame (a proclamation, for example).

2. To make ready for publication; edit or revise.

Merriam-Webster says:

Definition of REDACT

transitive verb
3. to put in writing : frame

  1. to select or adapt (as by obscuring or removing sensitive information) for publication or release; broadly : edit

  2. to obscure or remove (text) from a document prior to publication or release

Peter's 3rd definition is the one I'm using. Get a better dictionary :-)

@hoopycat:

For a good look at how DNS works and some of the tricks you can (and cannot) use, especially in large-scale situations like this, you'll probably want http://oreilly.com/catalog/9780596100575 at the ready.

I haven't personally used it in awhile, but take a look at PowerDNS. It has been around awhile, and supports a number of databases on the back end, SQL and otherwise.

Hi HoopyCat,

Thanks for your literature suggestion.

Before I order this book, I would like to know if managing DNS like this is possible with Linode (in an efficient enough way to create a whole lot of subdomains with their own nameservers).

  • Tom

I would bet you would have to run your own name server to do what you want, rather than using the Linode ones.

It certainly should be possible, though.

@bryantrv:

I would bet you would have to run your own name server to do what you want, rather than using the Linode ones.

It certainly should be possible, though.

Apologies if this makes no sense, but can I run my own dns server on a linode server?

Thanks.

@tommedema:

@bryantrv:

I would bet you would have to run your own name server to do what you want, rather than using the Linode ones.

It certainly should be possible, though.

Apologies if this makes no sense, but can I run my own dns server on a linode server?

Thanks.

A linode can do anything that any other server can do, so yes, you can.

Are you sure you need to, though? I'm not entirely clear on what you're trying to do. You want to create subdomains and use those as name servers for customer domains? Is there a reason you can't use Linode's name servers?

Or do you just want to create subdomains for the websites themselves, and want to automatically create the subdomains for customers to access their webpages? You can do that with Linode's name servers through the API, I believe.

@Guspaz:

@tommedema:

@bryantrv:

I would bet you would have to run your own name server to do what you want, rather than using the Linode ones.

It certainly should be possible, though.

Apologies if this makes no sense, but can I run my own dns server on a linode server?

Thanks.

A linode can do anything that any other server can do, so yes, you can.

Are you sure you need to, though? I'm not entirely clear on what you're trying to do. You want to create subdomains and use those as name servers for customer domains? Is there a reason you can't use Linode's name servers?

Or do you just want to create subdomains for the websites themselves, and want to automatically create the subdomains for customers to access their webpages? You can do that with Linode's name servers through the API, I believe.

Hi again,

I'm not trying to do either of those.

Basically, I want to allow other people to create a subdomain and then setup their own nameservers (aka the nameservers of their servers, not mine) for the subdomains that they created.

Thus, a subdomain would function like a top level domain, where the registrant can setup his nameservers so that the domain will lead to the corresponding servers.

But… You can't have a name server for a subdomain…

You just want your clients to be able to create a subdomain under your domain, and point it to their own IP? That's trivial, should be able to do it with the API. You just need to add A-record CRUD support to your application for linode's DNS services.

@Guspaz:

But… You can't have a name server for a subdomain…

You just want your clients to be able to create a subdomain under your domain, and point it to their own IP? That's trivial, should be able to do it with the API. You just need to add A-record CRUD support to your application for linode's DNS services.

I realize that.

However, do you really think the linode DNS API is meant for bulk records? I want this to be setup correctly, so that it can (hypothetically) expand to hundred of thousands of subdomains with their own IPs.

@Guspaz:

But… You can't have a name server for a subdomain…
Ummm…. why not?

Not that it is necessarily a good idea, but AFAIK it can be done.

A side note- I'm not sure you could buy hundreds of thousand of IP addresses, and I'm near certain you couldn't in any single Linode data center.

I really cannot thing of a legit reason to need that many.

@Stever:

@Guspaz:

But… You can't have a name server for a subdomain…
Ummm…. why not?

Not that it is necessarily a good idea, but AFAIK it can be done.

Hmm, didn't realize you can do that. But it's strictly a redirect; the root server is still going to point to your name server, and only when the client queries your name server will it find out that it has to query yet another name server to get info on the subdomain.

@tommedema:

I realize that.

However, do you really think the linode DNS API is meant for bulk records? I want this to be setup correctly, so that it can (hypothetically) expand to hundred of thousands of subdomains with their own IPs.

Well, since Linode won't give you hundreds of thousands of IPs, they might not be happy that you're using their DNS servers to host hundreds of thousands of non-linode IPs…

You should ask them directly.

EDIT: More to the point, I'm not sure anybody is going to give you hundreds of thousands of IPs, not with IPv4 exhaustion 71 days away.

@hoopycat:

Peter's 3rd definition is the one I'm using. Get a better dictionary :-)

Ok ok … :)

@Guspaz:

Well, since Linode won't give you hundreds of thousands of IPs, they might not be happy that you're using their DNS servers to host hundreds of thousands of non-linode IPs…

What would he need hundreds of thousands of IPs for? He's talking about running a DNS redirect, not hosting the sites himself.

@tommedema:

However, do you really think the linode DNS API is meant for bulk records? I want this to be setup correctly, so that it can (hypothetically) expand to hundred of thousands of subdomains with their own IPs.

In theory, it should be able to handle it. At the very least, it can provide a good start while you build your revenue to the point where you can afford a few other Linodes to roll your own DNS infrastructure.

You're right, sorry, I missed that from the original post.

Shouldn't use Linode's DNS services for that. They're provided free to Linode customers for their own stuff, but using it to run a DNS host (rather than, as I thought, hosting DNS for customer websites) isn't cool.

@bryantrv:

A side note- I'm not sure you could buy hundreds of thousand of IP addresses, and I'm near certain you couldn't in any single Linode data center.

I really cannot thing of a legit reason to need that many.

But I don't want to buy hundreds of thousands of IP addresses.

I must have missed something, but I have tried to explain that other people would enter their nameservers, not mine.

Again, I want to create a service where other people can register subdomains for my domain and make these subdomains act like normal domains by allowing the users to set their own nameservers for this subdomain.

How would I achieve something like this?

@glg:

@Guspaz:

Well, since Linode won't give you hundreds of thousands of IPs, they might not be happy that you're using their DNS servers to host hundreds of thousands of non-linode IPs…

What would he need hundreds of thousands of IPs for? He's talking about running a DNS redirect, not hosting the sites himself.

This is very true, thanks for the enlightment.

  • Tom

You can't, sub domains cannot have separate name servers.

Here's how I'm reading this:

Your end goal is to have one system, which you control.

Someone else will connect to your system, and, through a scripted process, pick a subdomain of your domain. The script will add an entry to your dns in order to point that subdomain to a server owned by that other person.

You intend for this system to scale to "hundred of thousands" of subdomains.

Here's my views on the above:

For starters, the idea that you're creating something which will expand to "hundreds of thousands" of users is very unrealistic, and so planning around it is very unnecessary. That's like building a children's bike to handle the weight of a 2 ton child, because one day you might find a hypothetical child that weighs that much.

Also, doing something like this with Linode's DNS servers would be (IMO) controversial, as those servers are provided for Linode's servers, not for external users.

Maybe if you elaborated a bit on why you want to do this, we'd be more able to help you, as it stands, I'm puzzled by what you're actually trying to accomplish.

@obs:

You can't, sub domains cannot have separate name servers.
Yes they can; you can delegate subdomains. See here.

I didn't know about that you learn something new every day. However reading that linode's name servers would still be queried since

"Finally it is important to remember that as far as the internet registration authorities and root/TLD name-servers are concerned sub-domains do not exist. All queries for anything which ends with example.com will be directed to the name-servers for the example.com zone. The example.com name servers are responsible for redirecting the query to any sub-domain name-servers."

It just allows configuration to be passed on to another server.

I have a feeling that the OP wants to run a dynamic dns service with his domain name and have people "register" a subdomain and update their IP.

One thing to note about Linode's dns service is that it refreshes every 15 minutes which is far too high for that type of service. It's best if you run your own dns server on your Linode.

@melz:

I have a feeling that the OP wants to run a dynamic dns service with his domain name and have people "register" a subdomain and update their IP.

One thing to note about Linode's dns service is that it refreshes every 15 minutes which is far too high for that type of service. It's best if you run your own dns server on your Linode.

This is correct.

So, where should I look to learn how to create such dns server for my linodes?

Thanks.

Hard to say. You might want to start first with selecting a dns server software (e.g. Bind, tinydns, etc.) and then from there, start googling for pre-made package of software/scripts to run a dynamic dns service (rather than write one from scratch). At least you'll have something to work from and be able to customize for your needs.

@melz:

Hard to say. You might want to start first with selecting a dns server software (e.g. Bind, tinydns, etc.) and then from there, start googling for pre-made package of software/scripts to run a dynamic dns service (rather than write one from scratch). At least you'll have something to work from and be able to customize for your needs.

I don't quite understand how this would work though.

Are there any resources available that'd explain why I need to do this and how?

@tommedema:

I don't quite understand how this would work though.

This statement makes it sound like you're attempting to start a project far beyond your knowledge bracket.

Besides asking "how" maybe you should ask "why"?

There's already hundreds of free dynamic DNS providers - why does the world (or more importantly your prospective clients) need another one?

@akerl:

@tommedema:

I don't quite understand how this would work though.

This statement makes it sound like you're attempting to start a project far beyond your knowledge bracket.

This is only logical to me considering my initial post. I am not sure about you, but so far most of my bigger projects have been beyond my current knowledge bracket – most of them have succeeded though.

@vonskippy:

Besides asking "how" maybe you should ask "why"?

There's already hundreds of free dynamic DNS providers - why does the world (or more importantly your prospective clients) need another one?

While this should not be an ethical discussion forum (and thus I do not see any reason for you to ask me that question), the answer is that I currently run a subdomain service where I simply cloak target servers with basic framing or proxying. I have almost 10.000 clients who would like to be able to set the nameservers of their servers.

Since this is a free service, and I am willing to learn, I'm doing these things by myself.

I hope that this thread will start to get a bit more informative after two pages. I can note that I am knowledgeable with Node.js, if that is of any help.

To summarize:

  • someone concluded that I cannot just use linode DNS API. This makes sense to me;

  • it was then concluded that I need to create my own DNS server on a linode;

  • unfortunately, I did not get a single pointer on how to start this.

Thanks.

I usually recommend picking up a copy of DNS & BIND (Albitz & Liu) in threads like these… there's a lot of oddities with DNS that are tough to get from reading a pile of web forums and blogs.

I usually recommend picking up a copy of DNS & BIND (Albitz & Liu) in threads like these… there's a lot of oddities with DNS that are tough to get from reading a pile of web forums and blogs.

FWIW, you'd probably want your DNS server to be database-backed instead of programmatically hacking on zone files… PowerDNS in particular is designed for this, and BIND seems to support it as well.

Also FWIW, Linode's DNS servers may only update every quarter-hour when using the manager or API, but if you set them up as slaves, zone transfers apply immediately.

If you are wanting to cloak the destination, I don't believe dns is the way to do it- you are basically telling the world "this is where to find this subdomain".

@bryantrv:

If you are wanting to cloak the destination, I don't believe dns is the way to do it- you are basically telling the world "this is where to find this subdomain".

Hi Bryantrv,

I don't want to cloak the destination. I simply want to programatically create subdomains that function like domains in that you can enter your own nameservers.

  • Tom

@tommedema:

While this should not be an ethical discussion forum (and thus I do not see any reason for you to ask me that question)
You want free help from strangers and you don't think they deserve the backstory?

And what do "ethics" have to do with this discussion?

@tommedema:

  • it was then concluded that I need to create my own DNS server on a linode;

  • unfortunately, I did not get a single pointer on how to start this.

Setting up a DNS server on a linode is no different from setting one up on a standalone server. You're much better off looking for directions to setup bind or powerdns or whatever else has been suggested here.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct