Wednesday, January 07, 2009

How to do a simple parking domain server works

Probably a lot of you are trying to understand how it works a parking domains server. You may have some ideas about how to do a new bussines with your registered domains and a private parking domain server. If you have already some domains on some parking domains servers then you already have traffic on them so you have a good place to start a new bussines.

1. What do you need for a parking domain server ?

- A private server
- Linux (debian in my case)
- Some knowledge about Linux,DNS and webservers.
- A directory script / some affiliates / publisher account etc.
- Mimimum 2 ip addresses for your server
- A domain name for your service

2. How it works the parking domain server ?

You probably asked yourself how this stuff works. It's very simple: all those systems have a DNS that manages all parked domains with the same DNS data (same ip address for web, email and so on). After a DNS query your browser will get the IP from DNS and sends the request to web server what will answer with a page custom made for the domain what you requested.

3. How can we do a parking domain server ?

First we need to have a fresh linux installed system with network and both ip's configured on this system.

Second we need to configure a DNS server (in our case bind 9 from Internet Systems Consortium http://www.isc.org/index.pl) to respond on all parked domains with the same data.

Third we need to configure a web server (in our case Apache 2 http://www.apache.org) to respond to all domains with the same page.

DNS Server configuration

We create a file in /etc/bind/ named db.simple-parked with the next content:


$TTL 86400
@ IN SOA ns1.yourdomain.com. root.yourdomain.com. (
2004112801 ; Serial //YYYYMMDDCC
8h ; Refresh
4h ; Retry
2w ; Expire
1h ) ; Minimum
NS ns1.yourdomain.com.
NS ns2.yourdomain.com.


www A your_primary_ip
@ A your_primary_ip

ns1 A your_primary_ip
ns2 A your_secondary_ip

mail A your_primary_ip
imap CNAME mail
pop CNAME mail
smtp CNAME mail

@ MX 10 mail

Note: Serial is a combination of Year - Month - Day and counter where counter (CC) is incremented every time when you restart/reload your bind configuration. In each day the counter (CC) is starting from 0.

After DNS Configuration we need to tell DNS to know about this configuration so we need to modify named.conf.local (this is in my system. In other system probably you will modify directly named.conf file)

so at end of the file we add :

zone "parked-domain1.com" {
type master;
file "/etc/bind/db.simple-parked";
};

zone "parked-domain2.com" {
type master;
file "/etc/bind/db.simple-parked";
};

zone "parked-domain3.com" {
type master;
file "/etc/bind/db.simple-parked";
};

and so on ...

Obviously you will do a script (Perl/php) to to add/remove/modify from named.conf.local by your parked users.

After that we need to reload the new conf of the bind to get the new domains. I want to restart the bind hourly not every time when a user add a new domain or modify something in his parked domains. For that we create a new file in /etc/cron.hourly named bind-reload with the next content:

#!/bin/bash
/usr/sbin/rndc reload

The DNS part is ready ... was easy ... what do you think ?

Now we need to configure the Apache server to respond to all domains.
We replace the /etc/apache2/enabled-sites/default with

NameVirtualHost *

ServerAdmin webmaster@localhost
DocumentRoot /var/www
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined


and that's all.

After that you need a script (php/Perl) what is getting the domain name what you connected and personalise the webpage/directory or what you have in root of /var/www. For example just do a simple php script in root of /var/www

index.php
echo "Server: ".$_SERVER['HTTP_HOST'];
?>

4. Conclusion

I think this are the necessary steps to do a simple parking domain system. From here you need to configure a script/directory,banners on default page, an admin area for users etc ...

Some of you probably ask why 2 ip address on requirements ? Because a lot of Registras are not accepting 1 name server for your domains and is more safety in this way.

That's all folks.

No comments:

Post a Comment