I need to enter network zones and their names into a network monitoring software program with a csv file. This software will only take the zone name, the IP address start, and the IP address stop. None of the IP ranges are allowed to overlap.
We get the lists from the Network team and the IP ranges always overlap, so as of now I have been using excel functions to tell if they overlap, then I have to use an IP address calculator and cut and paste to fill in the ranges in between.
Basically I want to turn a list like this (csv):
Zone Name, IPStart, IPStop,Range,Source
Group A,10.0.0.0,10.127.255.255,10.0.0.0/9,New List
Group A Sales,10.16.0.0,10.31.255.255,10.16.0.0/12,New List
Group A Sales Primary routers,10.23.1.0,10.23.1.15,10.24.1.0/28,New List
Group A Sales Web Servers,10.16.0.0,10.19.255.255,10.16.0.0/14,New List
Group A Sales Web Servers - Primary,10.18.0.0,10.18.0.255,10.18.0.0/24,New List
Group A Marketing,10.62.0.0,10.62.255.255,10.62.0.0/16,New List
Group A Research,10.62.0.0,10.63.255.255,10.62.0.0/15,Old List
Group B,10.128.0.0,10.255.255.255,10.128.0.0/9,Old List
Into this (with the other ranges filled out as well):
Zone Name, IPStart, IPStop,Range,Source
Group A,10.0.0.0,10.15.255.255,10.0.0.0/12,New List
Group A Sales,10.24.0.0,10.31.255.255,10.24.0.0/13,New List
Group A Sales Web Servers,10.16.0.0,10.17.255.255,10.16.0.0/15,New List
Group A Sales Web Servers - Primary,10.18.0.0,10.18.0.255,10.18.0.0/24,New List
Group A Sales Web Servers,10.19.0.0,10.19.255.255,10.19.0.0/16,New List
Group A Sales,10.20.0.0,10.21.255.255,10.20.0.0/15,New List
Group A Sales,10.22.0.0,10.22.255.255,10.22.0.0/16,New List
Group A Sales,10.23.0.0,10.23.0.255,10.23.0.0/24,New List
Group A Sales Primary routers,10.23.1.0,10.23.1.15,10.24.1.0/28,New List
Group A Sales,10.23.1.16,10.23.1.31,10.23.1.16/28,New List
Group A Sales,10.23.1.32,10.23.1.63,10.23.1.32/27,New List
Group A Sales,10.23.1.64,10.23.1.127,10.23.1.64/26,New List
Group A Sales,10.23.1.128,10.23.1.255,10.23.1.128/25,New List
Group A Sales,10.23.2.0,10.23.3.255,10.23.2.0/23,New List
Group A Sales,10.23.4.0,10.23.7.255,10.23.4.0/22,New List
Group A Sales,10.23.8.0,10.23.15.255,10.23.8.0/21,New List
Group A Sales,10.23.16.0,10.23.31.255,10.23.16.0/20,New List
Group A Sales,10.23.32.0,10.23.63.255,10.23.32.0/19,New List
Group A Sales,10.23.64.0,10.23.127.255,10.23.64.0/18,New List
Group A Sales,10.23.128.0,10.23.255.255,10.23.128.0/17,New List
Group A Marketing,10.62.0.0,10.62.255.255,10.62.0.0/16,New List
Group A Research,10.63.0.0,10.63.255.255,10.62.0.0/16,Old List
Group B,10.128.0.0,10.255.255.255,10.128.0.0/9,Old List
The program would have to give precedence to the New List over Old List, but still include Old List if it didn't overlap with anything in New List.
I am sort of a beginner in programming but I used to know c++ and I am studying Perl, PHP, and know bash scripting and awk/gawk. I have been looking all over the internet for a program to do this and nothing has come close. I don't even know which language to put it in.
Please, any program or at least some starting point would be really helpful. Thanks
I would eventually have to write portions of this program to compare and edit the zone names to meet a certain length and add zone location based on entries in another file, so keep that in mind please.
EDIT
I have been learning Python, so I think I will use Python for this. I am having trouble finding a way to check for overlap in Python. I think the final code will be a check for overlap, then returning all the IP addresses in both ranges, then removing the smaller range addresses from the bigger range and then calculate the new address ranges: append, and delete the old address ranges. If that makes sense.
I am not actively working on this at this very moment, I am working on other parts of the code to automate the processing of these files. But, I suspect this will be the most complicated part of my code so any help is appreciated.
Thanks, B0T