• Welcome to The Network People Support Forums. Please login or sign up.

Import and Management scripts

Started by monachus, April 01, 2006, 04:37:08 AM

Previous topic - Next topic

monachus

I'm posting these scripts up for general use.  The DNS import script started out from another script on this site, and credit should be given to that author for pointing me in the right direction.

I'm not providing any support for these.  If I update them, I might repost them here.  More likely, though is that I'll put up a NicTool blog or something and put updates there.  If so, I'll try to remember to put that address back here.  :)

If you find bugs or make slick mods, please let me know, and I'll either fix them or include them, etc.

*** I'll actually load the scripts as replies to this message, since I can only load one attachment at a time.
Adrian Goins - President / CEO
Arces Network, LLC
http://www.arces.net

PGP Key: 1024D/8AADA4B8 2009-04-20
Fingerprint: E3CD 96EA DF3F B345 7ADB  FB74 31EC 9F54 8AAD A4B8

monachus

* addserver: adds a nameserver to a single zone, a list of zones from a file, a regex for zones, or all zones.  useful for applying nameservers to zones after an import or a system-wide change.  Also allows for -r option to remove a nameserver instead of adding it.  Ignores servers that already exist (actually removes and re-adds them).

Usage:  addserver { -a | -z zone | -f file } [ -r ] [ -h ] -s server
       -z : Name of zone to change
       -a : Change all zones
       -f : File with zones, one per line
       -s : Nameserver to add
       -p : -s is a regex
       -r : Remove it instead of adding it
       -h : Display this help
Adrian Goins - President / CEO
Arces Network, LLC
http://www.arces.net

PGP Key: 1024D/8AADA4B8 2009-04-20
Fingerprint: E3CD 96EA DF3F B345 7ADB  FB74 31EC 9F54 8AAD A4B8

monachus

* zone2nic:  loads zonefiles into NicTool via zone transfer from a designated server or from the default nameservers for the zone.  Will ask you which nameservers to bind to the zones, or -a specifies all nameservers that the user can publish to.

Usage:  zone2nic { -z zone | -f file | -h } [ -s server ] [ -a ] [ -g group ]
       -z : Name of zone to import
       -h : Display this help
       -f : File with zones, one per line
       -s : Nameserver to query - pulls from zone if missing.
       -a : Bind to all NicTool nameservers
       -g : Group to insert zones into

Update 2006-04-07:  
  * added -g option to load zones into subgroups
  * changed nameserver search methodology (update the docs, matt!)

Adrian Goins - President / CEO
Arces Network, LLC
http://www.arces.net

PGP Key: 1024D/8AADA4B8 2009-04-20
Fingerprint: E3CD 96EA DF3F B345 7ADB  FB74 31EC 9F54 8AAD A4B8

monachus

* nic2cache will poll the database for zones that your NicTool installation manages and export them with the first three nameservers assigned to them.  This export will be written out to a directory you specify as your dnscache root, allowing dnscache to look at your local servers for information instead of climbing all the way out to the root servers and then coming back in.

This is most useful for the following situations:

1.  You have your DNS installation behind load balancers and are querying it from inside.  In this case, your local machine may not be able to talk to the VIP on the load balancer (for  networking reasons that I'm not going to go into here).  By having it export locally, your server can just talk to itself and friends.

2.  You have private DNS zones that you don't publish to the Internet.  Having your dnscache instance talk to the internal nameservers responsible for these zones makes the information exist in the cache, and thereby makes it accessible.

3.  You delegate responsibility for zones and records to clients, and you would like to have the latest information available to you and others who use your cache, rather than waiting for TTLs to expire and the root servers (or forwarding caches) to update.

Usage: nic2cache [-h] [-d host] [-u user] [-p pass] [-n name] -l dir
       -d : host to connect to
       -n : db to connect to
       -u : user to connnect as
       -p : pass to connect with
       -l : directory to write to
       -h : display this help

The script will ask for optional values if values are not present.  Alternatively, you can edit the commented block and specify permanent values.

Enjoy.
Adrian Goins - President / CEO
Arces Network, LLC
http://www.arces.net

PGP Key: 1024D/8AADA4B8 2009-04-20
Fingerprint: E3CD 96EA DF3F B345 7ADB  FB74 31EC 9F54 8AAD A4B8

matt


Wow, nice job on the scripts. I've just reviewed the code and you have done a very nice job. Thank you for making them available to the community.

Matt

rainer_d

Do I mean it or are the scripts really unavailable since the forum-upgrade?

Can you fix that, Matt?
Or can the original poster just re-post them?

cu,
Rainer
--
FreeBSD - The Power To Serve

matt

May 24, 2006, 08:41:50 AM #6 Last Edit: March 14, 2007, 05:08:50 AM by matt
Doh!  Change is never without a little pain.

Attachments are below.

Matt

LogicallyRogue

I know this happens on "addserver" but it might happen on other scripts as well...

When I ran ./addserver -a -r -s x1.nictool.com, it edited all the zones on the equilivant Page 1 of the "NicTool" group.  It didn't go any further.  Granted, I don't have any of my zones in sub-groups (yet), so the behavior might not happen

I'm not sure if this behavior is on the NicTool SOAP side or on the addserver script side - but is there a patch for this behavior? 


patwoo

I modified zone2nic to do an exact match instead of contains. It is deleting zone that aren't really a duplicate.

Before

    185         # See if this zone already exists
    186         $resp = $nt->send_request(
    187             action              => "get_group_zones",
    188             nt_user_session     => $ntuser->{nt_user_session},
    189             nt_group_id         => ( $gid ),
    190             include_subgroups   => 1,
    191             search_value        => $zone,
    192             quick_search        => 1,
    193         );

After

    185         # See if this zone already exists
    186         $resp = $nt->send_request(
    187             action              => "get_group_zones",
    188             nt_user_session     => $ntuser->{nt_user_session},
    189             nt_group_id         => ( $gid ),
    190             include_subgroups   => 1,
    191             Search              => 1,
    192             '1_field'           => "zone",
    193             '1_option'          => "equals",
    194             '1_value'           => $zone
    195         );

matt

I have added the addserver and zone2nic scripts to the NicToolServer distribution. They are in the api/contrib directory. I didn't add nic2cache because the SQL changes I've made in NicTool 2.10 have broken it (it use SQL queries instead of the API).

monachus

Quote from: matt on November 13, 2011, 05:19:01 AM
I have added the addserver and zone2nic scripts to the NicToolServer distribution. They are in the api/contrib directory. I didn't add nic2cache because the SQL changes I've made in NicTool 2.10 have broken it (it use SQL queries instead of the API).

First:  Thanks!  Second:  We use nic2cache on our servers, so as soon as we have 2.10 installed, we'll update it to use the API and resubmit it for inclusion.
Adrian Goins - President / CEO
Arces Network, LLC
http://www.arces.net

PGP Key: 1024D/8AADA4B8 2009-04-20
Fingerprint: E3CD 96EA DF3F B345 7ADB  FB74 31EC 9F54 8AAD A4B8

flow

Hello,

The script provided with Nictool which is named zone2nic.pl send me back the following error on  every extraction :   
Use of uninitialized value in substr at /usr/local/share/perl/5.10.1/NicToolServer/Export.pm line 189.
substr outside of string at /usr/local/share/perl/5.10.1/NicToolServer/Export.pm line 189.
Use of uninitialized value $last_ts in concatenation (.) or string at /usr/local/share/perl/5.10.1/NicToolServer/Export.pm line 191.

Thank you

Flow

matt

This error has already been corrected. The change is on github and will be in the v2.14 release.