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.

  1. 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.
  2. Open the BIND configuration file:
    CentOS: /etc/named.conf

    Debian: /etc/bind/named.conf
  3. Every 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.

  4. Open DNSmanager database using sqlite:

    sqlite3 /usr/local/mgr5/etc/dnsmgr.db
    BASH
  5. Get the user id from the database:

    select id from user where name='<username>';
    BASH
  6. Get the user name space id from the database:

    select id from namespace where name='<name space>';
    BASH
  7. Get the id that you can use for the newly created domain:

    select max(id)+1 from domain;
    BASH
  8. Add a record about the domain into the database:

    insert into domain ([id],[name],[namespace_id],[user],[dtype]) values ('<id>','<name>','<namespace_id>','<user>','<dtype>');
    BASH

    <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".

  9. If you need to add a large number of records into the database, you can automate this process: 

    1. Provide all the domain names in the file. 

    2. 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
      BASH

      <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".

    3. Start the script.
  10. Restart DNSmanager:

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