Importing Zones etc from BIND

Started by duncanshannon, February 01, 2005, 12:45:12 PM

Previous topic - Next topic

duncanshannon

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

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" target="_blank">http://fpux.com

duncanshannon

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

This is currently only available as a service:

http://www.tnpi.biz/store/product_info.php?cPath=23&products_id=31" target="_blank"> 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

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

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

ohhhh. crafty.

id love to hear if that works.

etherealnet

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

 Very Happy

/me raises his hand.

interested.

etherealnet

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

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

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