Add domains to DNSmanager from BIND configuration file
This article goes you through the steps you need to perform to add into DNSmanager the domain names that are already specified in the BIND configuration file.
- A domains zone must be assigned to a user in DNSmanager. Create a new user, enter his Username and DNS name space. Learn more in the article How to add a new user.
Open the BIND configuration file:
Debian: /etc/bind/named.conf
CentOS: /etc/named.confEvery DNSmanager user is assigned view in the configuration file. view name corresponds to the DNS name space that you specified earlier. All the user's domain zones are included into view. E.g.:
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.user/company.my"; }; };
BASH
Move the domain zones in the configuration file into view of the newly created user.Open DNSmanager database using sqlite:
sqlite3 /usr/local/mgr5/etc/dnsmgr.db
BASHGet the user id from the database:
select id from user where name='<username>';
BASHGet the user name space id from the database:
select id from namespace where name='<name space>';
BASHGet the id that you can use for the newly created domain:
select max(id)+1 from domain;
BASHAdd a record about the domain into the database:
insert into domain ([id],[name],[namespace_id],[user],[dtype]) values ('<id>','<name>','<namespace_id>','<user>','<dtype>');
BASHView details<id> — id that you received in step 7.
<name> — domain.
<namespace_id> — user name space id that you received in step 6.
<user> — user id that you received in step 5.
<dtype> — allows defining whether the DNS-server is a master or slave for the domain zone. If it is the master, enter "master", otherwise, enter "slave".If you need to add a large number of records into the database, you can automate this process:
Provide all the domain names in the file.
Create a file with the script.
#!/bin/bash count=<id> for domain in `cat <file>`; do echo "insert into domain ([id],[name],[namespace_id],[user],[dtype]) values ('$count','$domain','<namespace_id>','<user>','<dtype>');" | sqlite3 /usr/local/mgr5/etc/dnsmgr.db count=$((count+1)) done
BASHView details<id> — id that you received in step 7.
<file> — file with a list of domain names.
<namespace_id> — user name space id that you received in step 6.
<user> — user id that you received on the step 5.
<dtype> — allows to define whether the DNS-server is a master or slave for the domain zone. If it is the master, enter "master", otherwise, enter "slave".
- Start the script.
Restart DNSmanager:
/usr/local/mgr5/sbin/mgrctl -m dnsmgr exit
BASH