-1

How can I create zones for 50 domains on Ubuntu 12 VPS? I have webmin (which allows me to use BIND to create/ manage zones). I was able to figure out what gets created to add a zone successfully.

But creating record for 50 domains is time consuming and I will make errors.

What is the best way to add the same quickly? Can someone share an example of shell script or something to achieve it? Or some third party tools which can help me achieve the same?

The format for each zones will be the same as below:

File 1: /etc/bind/named.conf.local

zone "dummy.org" {
    type master;
    file "/var/lib/bind/dummy.org.hosts";
    };

----------------------
File 2: /var/lib/bind/<dummy.org.hosts>


$ttl 38400
dummy.org.       IN      SOA     abc.com. dns.abc.com (
                        1366568118
                        10800
                        3600
                        604800
                        38400 )
dummy.org.       IN      NS      ns1.abc.com.
dummy.org.       600     IN      A       <MyIP>    
www.dummy.org.   600     IN      A       <My IP>
2
  • 2
    If you can't script this you really should consider learning some bash scripting.
    – ceejayoz
    May 11, 2013 at 18:11
  • Well, I am still learning stuff. If you can point to few bash scripting tutorials, I will be more than glad to learn
    – DataRiver
    May 12, 2013 at 4:32

1 Answer 1

1

For starters, you should to adjust your zone writing methodology to be reusable between zones. Avoid using RRs ending in a dot unless you explicitly have to.

  1. You're not taking advantage of the @ character, which represents the current origin. By default, the origin scope for a zone file will be the same as the "zone" declaration in named.conf. (put more simply, the @ character will always default to being what you specified after "zone" in named.conf, with a period appended to the end if it's not already present)
  2. You're not taking advantage of the fact that lines beginning with a tab or whitespace (you must omit the name of the record) are considered to have the same name scope as the preceding record.
  3. If you need to define a massive number of zones that do not have any uniquely distinguishing records and the only thing that changes is the name of the zone, they can all share the same zone file. You just need to make sure that any references to the zone itself adhere to tip #1. (use @)
  4. You only need to include a trailing dot when referring to data outside of the current zone. www will refer to www.dummy.org. inside of this zone. ns1.abc.com. requires the dot at the end because it's outside of the dummy.org. zone and should be left alone.

Putting the above to use within your current example:

  • the SOA record could list @ instead of dummy.org. (tip #1)
  • the NS record and first A record can either omit the record name entirely (tip #2), or replace dummy.org. with @ (tip #1)
  • www.dummy.org. can just be www (tip #4)

Remove the uniquely identifying data as described above. At that point, this zone file becomes a starting point for any other zones that share the same data. Copy the zone file to other zone files as many times as would be appropriate, then concern yourself with the data that is unique to each of your zones.

2
  • :Thank you for writing a detailed answer. I am not an expert in BIND/ DNS. I have some basic information of how DNS works. all my domains need to point to the same server with same details. So, that being said, what changes will I need to do to enable least changes and still allow multiple zones to be created with ease?
    – DataRiver
    May 12, 2013 at 4:30
  • I do exactly this for about two dozen domains, the vast majority simply use a symlink to the generic domain, and a few get copied so an extra A record or whatever can be added, makes maintenence so much easier. I also have a trivial makefile that takes my zone files (all named by domain) and creates the relevent chunk of named.conf, it also can do the same for slaving zones.
    – LapTop006
    May 12, 2013 at 6:22

Not the answer you're looking for? Browse other questions tagged .