Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subdomains and DNS

Tags:

subdomain

dns

I currently have my own domain name and dedicated server and I offer different packages to my clients. What I want to be able to do is have them sign up with my website and create a package automatically that they can access via their username as a subdomain e.g.

http://yourusername.mywebsite.com

I currently have DNS entries set up for various subdomains with real information for my website e.g.

Name Type IP Address
@ A 1.2.3.4
bugs A 1.2.3.4
support A 1.2.3.4

However, if a new customer signs up at the moment I have to go and manually create an entry for them with their username in it.

I'm sure I've seen websites that manage to do this automatically, does anyone have any ideas how, or any other methods that I should be using?

Thanks,
Mark

like image 434
ca8msm Avatar asked Nov 18 '09 13:11

ca8msm


3 Answers

Since you apparently do not control the name servers, your choices are quite limited. One possibility is to use a wildcard DNS record:

*  A  192.0.2.1

where the star will replace every name. Not ideal (inexisting domains will also appear).

like image 101
bortzmeyer Avatar answered Jan 04 '23 12:01

bortzmeyer


The details depend on which DNS server you're using.

One approach is to have some code that opens the DNS zone file and adds the desired records. On Linux with Bind, you will then need to signal the server to get it re-read the zone file.

like image 40
RickNZ Avatar answered Jan 04 '23 11:01

RickNZ


With Simple DNS Plus, you can easily add such a DNS record through the included HTTP API. For example:

http://127.0.0.1:8053/updatehost?host=yourusername.mywebsite.com&data=1.2.3.4
like image 42
Jesper Avatar answered Jan 04 '23 10:01

Jesper