So I’m migrating an old Cisco Network Registrar DHCP service (circa 1998 product version) to a Win2008R2 box, i found out quite quickly that Cisco does not provide a way to export configuration information for their CNR product… at least not directly. I doubt anyone else out there has such an old crap product but just in case, I spent a bit of time figuring things out and have found a viable way to pull the information out.
First, I utilized nrcmd.bat which comes with the CNR client and provides a very basic cli to the product. Unfortunately this cli doesn’t have a full dump for the DHCP configuration. I did however find a few commands that will provide the needed information to hopefully provide as an input to netsh after a bit of manipulation.
scope listnames
scope <name> listRanges
scope <name> listReservations
policy listnames
policy <name> listOptions
As you can probably tell, I needed a simple loop to actually generate everything. At first I feared this because, pulling the database from CNR (which the client does upon first command) takes 30 seconds. If I executed a loop from an OS level, each command would take 30 seconds to complete. In retrospect I could probably have run them in parallel but I decided to look for a better way.
I found it! The nrcmd.bat file is actually a bit better than expected. It provided a way to feed data directly into it’s cli.
C:\Program Files\Network Registrar\BIN>nrcmd.bat -h
Usage: nrcmd [-C cluster] [-N user] [-P password] [-h] [-r] [-v] [-b < script]
Options:
-b < script Process script file of nrcmd commands.
-h Print this help text.
-r Login as a read-only user.
-v Report the program version and exit.
Notes:
Cluster defaults to localhost if not specfied.
Single commands may be specified as arguments, for
example 'nrcmd -N name -P password zone list'.
Cool, so now its just time to compile the lines to feed into nrcmd.bat. This was done by taking the output of scope listnames and policy listnames from nrcmd.bat and dropping it into file “inputfile” then a quick bash FOR loop did the rest as shown below.
Example inputfile:
Building1
Building2
Building3
Building4 Special Scope
By the way, because the last scope has spaces, I needed to do two additional things… I needed to set the IFS variable which controls the delimiter for the FOR loop, and I also needed to quote it as it was echo’d out for the nrcmd.bat script to know that the spaces were part of the names.
IFS=$'\n';
for l in `cat inputfile`;
do
echo "scope \"$l\" listRanges";
echo "scope \"$l\" listReservations";
done
Alright so all thats left is to take the output of this and feed it into nrcmd.bat! I put the output into a file called “scriptfile.txt” and issued this:
nrcmd.bat -C <CNRservername> -N <user> -P <pass> -r -b < scriptfile.txt > myoutput.txt
Sample output from a policy <name> listoptions just for reference:
nrcmdRO> policy system_default_policy listoptions
100 Ok
(27)all-subnets-local: FALSE
(35)arp-cache-timeout: 60
(28)broadcast-address: 1.1.1.255
(23)default-ip-ttl: 64
(37)default-tcp-ttl: 64
(51)dhcp-lease-time: 604800
(15)domain-name: domain.com
(6)domain-name-servers: 1.2.3.4,1.2.3.5
(36)ieee802.3-encapsulation: FALSE
(26)interface-mtu: 576
(30)mask-supplier: FALSE
(22)max-dgram-reassembly: 576
(5)name-servers: 1.2.3.4,1.2.3.5
(44)netbios-name-servers: 1.2.3.4,1.2.3.5
(46)netbios-node-type: 8
(20)non-local-source-routing: FALSE
(24)path-mtu-aging-timeout: 6000
(25)path-mtu-plateau-tables: 68,296,508,1006,1492,2002,4352,8166,17914,32000,65535
(29)perform-mask-discovery: FALSE
(31)router-discovery: TRUE
(32)router-solicitation-address: 224.0.0.2
(39)tcp-keepalive-garbage: FALSE
(38)tcp-keepalive-interval: 0
(34)trailer-encapsulation: FALSE
I did have to do this separately for the scope and policy as their names were not the same
.. never the less, i now have all the information needed to build my netsh scripts! I’ll probably add to this / follow up as I finish that part as well.
Follow Me!