How to add domains into DNSmanager manually (if domains are already specified in the named configuration file)

From ISPWiki
Jump to: navigation, search

This article goes you through the steps you need to perform for adding domains that are already specified in named, into DNSmanager.

1. As domains in DNSmanager are assigned to a user and his name space, you will first need to create the user.

2. The panel considers all the zones be included into view (view = user's name space). Be sure to include zones into view.

Example:

view "hoster.me" {
allow-transfer { 127.0.0.1; };
       match-destinations { 149.154.66.80; };
       transfer-source 149.154.66.80;
zone "company.my" {
               type master;
               file "/etc/bind/hoster.mary/company.my";
       };
};

3. DNSmanager stores all the information in the sqlite database. Add the domain into the database.

Database file - /path/to/manager/etc/dnsmgr.db (by default DNSmanager is installed into /usr/local/mgr5/)

For example, the name of the newly created user - named, name space - hoster.me.

Get the user's id from the base.

sqlite> select * from user where name='named';
15|named||$1$uRNrHK8j$wMBkoPr8FvtbC74DoiW3M.|16|on|off|13||0||100|tech@hoster.me|ns1.hoster.me. ns2.hoster.me.|mail mail|ftp www mail|127.0.0.1

15 - id of the named user.

Get the name space's id from the base.

sqlite> select * from namespace where name='hoster.me';
13|hoster.me|0.0.0.6|

13 - id of the hoster.me name space.

Add the domain into the domain table and assign it to the user and name space.

sqlite> insert into domain ([id],[name],[namespace_id],[user],[dtype]) values ('56','company.my','13','15','master');

Restart DNSmanager to apply the changes.

/usr/local/mgr5/sbin/mgrctl -m dnsmgr exit

Automation

You may ask - what should I do if I have two domains? The following is a script that can be used for automating this process.

A list of domains is supposed to be specified in the file /root/domain.txt. For the count variable set the value larger than the last id in the domain table.

#!/bin/bash
count=100
for i in `cat /root/domain.txt`; do
       echo "insert into domain ([id],[name],[namespace_id],[user],[dtype]) values ('$count','$i','13','15','master');" | sqlite3 /usr/local/mgr5/etc/dnsmgr.db 
       count=$((count+1))
done