Sub-domain management is very much similar to main domain name configuration. The main difference is that it is attached to the main domain name. Request for subdomain is routed to DNS server which has DNS information for the main domain. Sub-domain DNS records resolved to a IP address, the rquest is sent to the web server that is assigned with the IP address. the request can now be moved to the website. By many DNS server entries, subdomain configuration can be taken care of and application setup for management of load or applications.
DNS server should have pointer to the sub domain as CNAME or hostname or MX entry for emails. If the IP address of the main domain name and sub-domain name are the same, we then use CNAME or alias. A records are used if the IP points to the different dedicated server in case of load balancing server setup.
CNAME is used when the IP address of the sub-domain and the main domain are the same. It means the parent domain and child-domain points to the same IP address such as :
www IN CNAME domain.com.
subdomain1 IN CNAME domain.com.
subdomain2 IN CNAME domain.com.
A record is setup when the main domain is different from the sub-domain. This is in case of a load balancing or server cluster setup such as :
subdomain1 IN A 123.2.33.45.
subdomain2 IN A 123.2.33.46.
MX records are mail exchanger sub-domains in case of email setup that will be pointing to the dedicated web server IP address and used for different email account such as :
subdomain1 IN MX 10 subdomain1.domain.com.
subdomain2 IN MX 10 subdomain2.domain.com.
If the sub-domain is configured on a different DNS name server, nameserver records is created for the sub-domain. Different nameservers can reduce security issues.
DNS Server sends the request for the sub-domain to the IP address, it starts functioning. It then needs to be configured to manage the request based on the IP address / Host headers. It is utilized by web servers to host different domains / sub-domain on one IP address.
In a Windows dedicated server, we have to use IIS manager to add sub-domains that will be assigned to IP address. Port is then set to 80. Host header can be added by clicking on advanced tab nect to IP address configuration for website application. Sub-domain that points to sub-directory of website which is then home directory for the sub-domain.
In a Linux dedicated server, we use Apache web server which is configured by virtual host entry in httpf.conf :
Listen 80
NameVirtualHost *
ServerName www.domain.com
DocumentRoot /home/httpd/htdocs/
ServerName subdomain.domain.com
DocumentRoot /home/httpd/htdocs/subdomain/