Author Topic: Importing Zones etc from BIND  (Read 13309 times)

duncanshannon

  • Jr Member
  • **
  • Posts: 5
  • Karma: +0/-0
Importing Zones etc from BIND
« on: February 01, 2005, 12:45:12 pm »
hi gang-

I saw in the FAQ that there looks like there will be some docs on importing data (from bind) into nictool.

Is this still 'future functionality' or is it possible now?

Has anyone had any luck with it?

thanks

duncan

LogicX

  • Wizard
  • *****
  • Posts: 126
  • Karma: +0/-0
    • http://FPuX.com
Re: Importing Zones etc from BIND
« Reply #1 on: February 01, 2005, 02:30:23 pm »
Its something which is awaiting a coder to tackle it.  Anyone may feel free to take it on, and is encouraged to share their results.
--- May this post be indexed by spiders, and archived for all to see as my internet epitaph.
http://FPuX.com

duncanshannon

  • Jr Member
  • **
  • Posts: 5
  • Karma: +0/-0
Re: Importing Zones etc from BIND
« Reply #2 on: February 01, 2005, 02:51:02 pm »
hrm... i assume it takes a perl hacker?

I could perhaps could try and find some resources, but I dont have any real perl wizards on staff.

duncan

matt

  • Administrator
  • Wizard
  • *****
  • Posts: 635
  • Karma: +0/-0
    • Matt's Personal Site
Re: Importing Zones etc from BIND
« Reply #3 on: February 03, 2005, 12:03:11 pm »
This is currently only available as a service:

http://www.tnpi.biz/store/product_info.php?cPath=23&prod ucts_id=31

I have a script that does all the dirty work but it's nowhere even close to being publishable. It requires some manual setup of the NicTool installation, installation of a set of non-released perl modules, and then finally, editing of the script itself before you can use it.

Of course, if your BIND is set up in any fashion that's the least bit "weird", then it also requires modifications to the bind config file. So, that's what I mean by "it's not publishable" and that's why it's only available as a service.

Matt

duncanshannon

  • Jr Member
  • **
  • Posts: 5
  • Karma: +0/-0
Re: Importing Zones etc from BIND
« Reply #4 on: February 03, 2005, 12:11:45 pm »
hrm.
ok. looks like you also would switch me over to djbdns, eh?

thanks for the info, i know where to go if i end up needing the service.

thanks

adams

  • Jr Member
  • **
  • Posts: 7
  • Karma: +0/-0
Re: Importing Zones etc from BIND
« Reply #5 on: February 23, 2005, 03:34:49 pm »
I was wondering if i make a djbdns a backup dns server to a bind dns server... then switch the djbdns to the primary would that work?

Thinking kind of like a Windows NT4 PDC and Windows 2K BDC Upgrade Switch? or am I totally wrong.

Very Happy


duncanshannon

  • Jr Member
  • **
  • Posts: 5
  • Karma: +0/-0
Re: Importing Zones etc from BIND
« Reply #6 on: February 23, 2005, 08:06:51 pm »
ohhhh. crafty.

id love to hear if that works.

etherealnet

  • Member
  • ***
  • Posts: 13
  • Karma: +0/-0
Re: Importing Zones etc from BIND
« Reply #7 on: March 11, 2005, 12:57:07 pm »
I have a script available that can import data from mydns in a single step or bind in two stages..Very simple to use and works flawlessly. Contact me if interested.

duncanshannon

  • Jr Member
  • **
  • Posts: 5
  • Karma: +0/-0
Re: Importing Zones etc from BIND
« Reply #8 on: March 11, 2005, 01:22:04 pm »
 Very Happy

/me raises his hand.

interested.

etherealnet

  • Member
  • ***
  • Posts: 13
  • Karma: +0/-0
Re: Importing Zones etc from BIND
« Reply #9 on: March 14, 2005, 01:24:53 pm »
Hope this gets you started

#!/usr/bin/perl

############################################################ ################
#    Copyright (C) 2005 by Kyle Polillo, Christopher Richardson            #
#                                                                          #
#    This program is free software; you can redistribute it and#or modify  #
#    it under the terms of the GNU General Public License as published by  #
#    the Free Software Foundation; either version 2 of the License, or     #
#    (at your option) any later version.                                   #
#                                                                          #
#    This program is distributed in the hope that it will be useful,       #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#    GNU General Public License for more details.                          #
#                                                                          #
#    You should have received a copy of the GNU General Public License     #
#    along with this program; if not, write to the                         #
#    Free Software Foundation, Inc.,                                       #
#    59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             #
############################################################ ################

#mydns2nictool.pl

use DBI;
use NicToolServerAPI();

#Begin configuration stuff

$ntuser = "root";               #nictool username
$ntpass = "somepass";           #nictool password
$ntport = "8082";               #nictool port
$nthost = "localhost";          #nictool host
$sqluser = "root";              #sql username for mydns
$sqlpass = "somepass";          #sql password
$sqlhost = "localhost";         #sql host
$sqldb = "mydns";               #sql dbname
$nameservers = "1,2";           #comma seperated list of nameservers by nt_nameserver_id
$ntgid = "1";                   #nt_group_id
$description = '';

#End configuration stuff

my $nt_server_obj = new NicToolServerAPI();
$NicToolServerAPI::data_protocol="soap";
$NicToolServerAPI::use_https_authentication = 0;
$NicToolServerAPI::server_host         = $nthost;
$NicToolServerAPI::server_port         = $ntport;

my $auth = $nt_server_obj->send_request( action => "login", username => "$ntuser", password => "$ntpass" );

my ($dbh, $sth, $sth2);

sub opendb{

       $dbh = DBI->connect("DBI:mysql:database=$sqldb;host=$sqlhost","$sqluser ", "$sqlpass", {'RaiseError' => 1});
}

sub execute{
       $sth = $dbh->prepare($_[0]); #sql statement
       $sth->execute; #execute sql statement
}

sub execute2{
       $sth2 = $dbh->prepare($_[0]);
       $sth2->execute;
}

sub closestate{
       $sth->finish(); #stop execution of sql statement
}

sub closedb{
       $dbh->disconnect(); #disconnect from sql database
}

&opendb();

my $sql_statement = "select * from soa";

execute($sql_statement);
while(my $hashref=$sth->fetchrow_hashref()){
       my $id = $hashref->{'id'};
       my $zone = $hashref->{'origin'};
       my $ttl1 = $hashref->{'ttl'};
       my $mailaddr = $hashref->{'mbox'};
       my $refresh = $hashref->{'refresh'};
       my $expire = $hashref->{'expire'};
       my $retry = $hashref->{'retry'};
       my $minimum = $hashref->{'minimum'};
       my $serial = $hashref->{'serial'};
       my $sql_statement2 = "select * from rr where zone=$id";
       print "creating $zone\n";

my %params = (
         nt_zone_id => '',
         nt_group_id => "$ntgid",
         zone => $zone,
         serial => $serial,
         ttl => $ttl1,
         nameservers => $nameservers,
         mailaddr => $mailaddr,
         description => $description,
         refresh => $refresh,
         retry => $retry,
         expire => $expire,
         minimum => $minimum
       );
       my $retval = $nt_server_obj->send_request( action => "new_zone", nt_user_session => $auth->{nt_user_session},%params);
       print $retval->{'error'}." ".$retval->{nt_zone_id}."\n";
       my $zone_id = $retval->{nt_zone_id};
       if($zone_id){
               &execute2($sql_statement2);
               while(my $hashref2 = $sth2->fetchrow_hashref()){
                       my $name = $hashref2->{'name'};
                       if(!$name){
                               $name = $zone;
                       }
                       my $ttl2 = $hashref2->{'ttl'};
                       my $type = $hashref2->{'type'};
                       my $aux = $hashref2->{'aux'};
                       my $data = $hashref2->{'data'};
                       my %params2 = (
                                       nt_zone_record_id => '',
                                       nt_zone_id => "$zone_id",
                                       name => "$name",
                                       ttl => "$ttl2",
                                       description => '',
                                       type => "$type",
                                       address => "$data",
                                       weight => "$aux"
                                       );
                       my $retval2 = $nt_server_obj->send_request( action => "new_zone_record", nt_user_session => $auth->{nt_user_session},%params2);
               }
               $sth2->finish();
       }
}

&closestate();
&closedb();

MHammett

  • wiki
  • **
  • Posts: 2
  • Karma: +0/-0
Re: Importing Zones etc from BIND
« Reply #10 on: June 07, 2015, 07:22:37 am »
I see this thread is over 10 years old now. Is this still the preferred method for importing BIND zones? I have a system (IXP Manager) that outputs BIND zone files. My goal is to get these into a nictool managed environment.

matt

  • Administrator
  • Wizard
  • *****
  • Posts: 635
  • Karma: +0/-0
    • Matt's Personal Site
Re: Importing Zones etc from BIND
« Reply #11 on: July 07, 2015, 10:00:23 am »
nt_import.pl is included with NicTool and does a fine job of importing zone flies (extensively tested with 100's of thousands of zones).

Matt