Shell Script To Create BIND Zone Files

in Categories Domain last updated March 24, 2009

First, you need to customize configuration file as follows.

Sample configuration file

Define your default TTL, EMAIL ID and other stuff. Also, set your mail server and nameserver IPs using bash array. Save file as follows

Add additional records using LoadCutomeARecords(). You can create multiple nameserver configuration file and call it from Shell script to create BIND zone file

How do I use this script?

Simply type the command as follows to create a zone file for domain with as default www IP:
# ./
Sample output:

To save output to a zone file called /var/named/chroot/etc/bind/master/c/, type:
# ./ > /var/named/chroot/etc/bind/master/c/

Share this on:

7 comment

    1. sorry but… you try …
      # chmod 755 before execute this script?

  1. I’ve been working on a few scripts to enable adding and removal of records.
    Don’t suppose anything exists already?

  2. Hi,

    I realize this post is several years old now, but I came across it looking to simplify my life. This script worked perfectly. In an effort to further simply my life however, I added your script to a simple launcher to make the db file, add the zone to named.conf.local, restart bind and run an nslookup on the newly created domain. If you or anyone else that finds this page are interested, I am pasting it below.

  3. I’m working on a same script i’m onthe satrt i got eveything copied but the editing part is where ibe stuck but i figure it out any way when i need help i ask youhere guys thanks

    nice script any way

    i migh use some of your ideas mr vivek

  4. Great Mr.Vivek

    I trying to make complete Bind Script (From A-Z)
    – asking to Adding Static IP
    – asking Adding Hostname of server
    – Installing bind
    – configure /etc/named.conf
    – configure /var/named/
    – configure /var/named/

    % I’m still beginner , but I’ll better %

    thank you sir

    Have a question? Post it on our forum!