How To Add Subdomain(Subzone) DNS Record In Linux?

Recently we got a requirement to configure a Sub-domain(sub-zone) record in DNS server.  Its little bit advanced concept but very much easy to configure. The most known records are as follows.

A record for Adding an IP address record

NS record for a Name Server record

PTR record for a pointer record( i.e. Reverse IP lookup record)

CNAME record for a Canonical name record(i.e. alias to a A record)

MX record for a Mail Exchange record ie Mail server.

SRV record for a Service record(for example Microsoft OCS server record) and this can be used for location based IP address record.

And many more records are there which are less used and for specific use. Here we are going to discuss about how to create sub-domain record and why its used?

Why is a sub-domain record is required?

Ans : To maintain a group of hosts with same sub-domain and for easy or administration.

How to create a sub-domain in Linux?

1. Through Fully delegate the sub-domain(which requires an entry in named.conf file and a separate zone file)

2. pseudo sub domain or virtual sub-domain(no need to give entry in named.conf file and just an entry in existing zone file)

In this post we will show you how to configure Pseudo sub domain.

For example my domain name is I want to create 3 sub-domain records for following hosts

If  you observe above host entries we just created a sub-domain for all my Indian servers.

Go to last line of your existing zone file. Give below entries as follows

;Sub-domain definitions
;Req by Meghana_bm, added by Surendra on  26-1-2011
ns1           IN      A
mx2           IN      A
www          IN      A 

Let us explore above lines. We have given $ORIGIN to indicate my sub-domain is in So what ever mention after this line it will suffice our sub-domain(ie in, India) to ns1, mx2 and www respectively.

The following two tabs change content below.
Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.
  • F Kh121

    how config zone deligation in sub domain?

  • krushna

    Thanks dude , started working straight way

  • Rich M

    You say “In your zone file”…why don’t you say where it should be? In my user directory?

    • Surendra Anne

      Hi Rich,

                   Zone files location is not persistent across the nix, so just given zone file instead of location.

  • chaitanya

    I do have only one ip and i want add 3 subdomains to the same ip.
    i do have access to virtual machine of it, and i made entry of these subdomains in VirtualHost.

    ;Sub-domain definitions
    ;Req by Meghana_bm, added by Surendra on  26-1-2011
    blog           IN      A
    forum          IN      A
    contact       IN      A

    is this possible to have same ip assigned to multiple subdomains… plz reply fast