OpenNetAdmin

Track. Automate. Configure.

Home About Features Community Develop
Download this project as a tar.gz file

Import existing data

sdaa

16-03-2009 05:33:39

Is there a way to import existing data, or using a bulk import of some kind? Would be nice to import existing DNS data for instance.

regards
Stig

Matt

16-03-2009 20:26:24

Yes.

First off I would point you to the DCM utility. It is the command line interface to the ONA system and allows you to do all kinds of scripted maintenance to the database. It is quite easy to take spreadsheets of info and use DCM to load them into the system (with some formatting and basic data validation first).

With that said, there are still many other tasks that could be automated. I've done some work related to these but they have not been tested in "real" environments for accuracy and their worth as a useful tool.

I'll go ahead and post a few of them in their "raw" form here and you guys can take them for what they are worth (not much) and do what you will. We can turn them into more useful and generic tools for all to use. A few that I have played with are:

tinydns (djbdns)
bind
dhcpd (isc)
cisco 'show ip route'
nmap
cisco 'show run'

These tools are in various states of completeness. I will hopefully be releasing the nmap and 'show run' parsers soon. They are the most complete and are actually worked into the GUI interface much more.

Anyway, I'll post a few shortly here to get peoples minds going on what can be done.

Matt

16-03-2009 21:19:30

Ok, here is an easy one. Since we need to start out by adding subnets to put all of our hosts on, what better place to get a list of subnets than from a router?

Here is a very simple command line tool to take the output of a "show ip route" command from a Cisco IOS device. I'll first off show the commands etc and then describe some details and caveats.


  1. [*:73vnee0e]Simple show ip route output as our starting point

    router#show ip route
    Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
    D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
    N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
    E1 - OSPF external type 1, E2 - OSPF external type 2
    i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
    ia - IS-IS inter area, * - candidate default, U - per-user static route
    o - ODR, P - periodic downloaded static route

    Gateway of last resort is not set

    10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
    D 10.7.7.2/32 [90/21024000] via 10.1.1.1, 00:14:05, Serial0
    D 10.7.7.0/24 [90/21024000] via 10.1.1.1, 00:14:05, Serial0
    C 10.1.1.0/24 is directly connected, Serial0
    C 10.1.1.1/32 is directly connected, Serial0
    C 192.168.0.0/24 is directly connected, Ethernet0

    [*:73vnee0e]Save the output of the show command in a text file, lets call it showroute.out[/*:73vnee0e]
    [*:73vnee0e]Execute the following command:
    cat showroute.out |sed -e "s/EX//"|awk '{print $2}'|grep /|egrep -v "\/0|\/32"|sed -e "s/\(.*\)\/\(.*\)/dcm.pl -r subnet_add name=SHOWROUTE-\1 ip=\1 netmask=\/\2 type=LAN/"
    [*:73vnee0e]You will get the following output:

    dcm.pl -r subnet_add name=SHOWROUTE-10.7.7.0 ip=10.7.7.0 netmask=/24 type=LAN
    dcm.pl -r subnet_add name=SHOWROUTE-10.1.1.0 ip=10.1.1.0 netmask=/24 type=LAN
    dcm.pl -r subnet_add name=SHOWROUTE-192.168.0.0 ip=192.168.0.0 netmask=/24 type=LAN

    [*:73vnee0e]You can either output this to another file and execute it as a shell command or just cut/paste the lines to your shell. [/*:73vnee0e]
    [/list:u:73vnee0e]

    Now, there are a few things to be aware of when doing this process.


    1. [*:73vnee0e]Be careful of summarized routes. Your route table may have summarized routes that do not represent the actual subnet that you should be adding to the database. It is best to process show ip routes from routers that are closest to the subnets you are wanting to add to help reduce the possibility of summarized routes.[/*:73vnee0e]
      [*:73vnee0e]In this example the type of subnet will be designated "LAN". You need to set it to something, this is nice and generic. You will want to make sure these are set to what you want them to be. This can be done after the fact via that GUI or just make the change before you execute the command to load them[/*:73vnee0e]
      [*:73vnee0e]When you add new Class A subnets you may be prompted with something like "ERROR => This subnet is the first in the 10.0.0.0 class A range. You must first create at least the following DNS domain: 10.in-addr.arpa". This is a requirement for DNS to have a PTR zone to associate IPs to. Once you define a few of these you will no longer need to set them for that particular Class A range. You can do this quickly by issuing the following command as an example: dcm.pl -r domain_add name=10.in-addr.arpa
      [*:73vnee0e]You can either leave the default name that is prefixed with SHOWROUTE (to make it easier to know how it was put into the database) or go through and give a meaningful name to each subnet. If you do change the name, make sure you put quotes around it if it has spaces so the shell does not get confused. The spaces will, however, be converted to hyphens when loaded.[/*:73vnee0e]
      [*:73vnee0e]Lastly, be sure to examine
      [/list:u:73vnee0e]

      Well I hope this helps. Its one of the more simple processes to get started but it is more than nothing. It should give you a good idea of what could be done. I'll post a few more in the next few weeks. Some will be much more robust, maybe :)

sdaa

19-03-2009 15:10:01

Thanks a lot for this info. I found out about dcm when reading some more on the site, obvious manuals are not the thing I read initially... ;)

So I have made some imports, especially VLANs from cisco, using RANCID for this. And I have my own script to check reverse-ip to forward, and back to see if dns-data is correct. This info is also easy to import. Been away for a while, but I will see if there is something to post.

I must also congratulate you to a very fine application, this is to my opinion THE application of the year. I have been waiting for this for years, testing different others for DNS/DHCP mgmt. But they have been either to hard to install or not flexible enough. It was when I searched for IPAM at sourceforge that this came up, and after 10 minutes I was totally dedicated to OpenNetAdmin. I stopped using that spreadsheet at once, replacing it with ONA.

So keep on with the good work, I will probably post a few feature requests and bug-reports, but you have really succeeded with this app.

Regards
Stig

Matt

20-03-2009 21:25:40

Glad you found dcm, and don't worry, obvious manuals are not something I write very much either as evidenced by the lack of much documentation on the site.

Sounds like you are well on your way to getting data into the system. Guess its about time for me to post another tool to get data into ONA.

Thank you very much for the kind words. I'm glad ONA is something you find useful. Keep the feature requests and bug reports coming. Those are the things that keep me motivated to work on things!