lopes / netbox-scanner

A scanner util for NetBox
MIT License
159 stars 40 forks source link

Addresses not in proper prefix after scanning #6

Closed mikeb93 closed 4 years ago

mikeb93 commented 5 years ago

EDIT: See PR #7

Hi,

thanks for this script, it's working great. Only issues I have is that the Addresses which are found are not getting added into any prefix. Looks like this is happening because there is no VRF added to the addresses.

Is there any way we can associate VRFs to the scanned subnets which will then be added to the addresses? Also there are almost no hostnames or such added to the description. Can we maybe have an option to add vendor names to the description (from mac addresses)?

Thank you in advance. I'll try to find a way myself with my very very limited python skills, I'd buy you a beer or two If you can help out though! :)

lopes commented 5 years ago

The main purpose of this script is to add only IP addresses --/32--, not prefixes. That's because I assume that the network organisation --prefixes, aggregations, and VRFs-- must be done manually by NOC engineers. It's quite hard to presume a prefix from a given IP address --e.g., 10.1.2.3/32 could belong either to prefix 10.1.2.0/24 or to prefix 10.1.2.0/25 or to prefix 10.1.2.0/26...

This way, IP address prefixes and aggregations are done by humans, because only they know how network should be organised. I've just reviewed you PR --thanks in advance--, but AFAIK, single IP addresses should be registered in /32 prefix, not using the mask of prefix they belong.

I'll keep both the issue and PR opened, to hear more from you.

BTW, sorry for the delay. I'm pretty busy these days, and, yes, I accept that beer. :)

mikeb93 commented 4 years ago

Hi, thanks for your reply and no worries about the delay. In my specific case, the prefixes were already created. In my PR I'm asking the API for the prefix the single IP belongs to. Basically the same thing I'd do manually. You don't usually have a 10.1.2.0/24, 10.1.2.0/25 and 10.1.2.0/26 prefix at the same time. I did not consider different VRFs though (not sure how to, yet. I'll try to find a way to consider VFRs).

Maybe this can be implemented optionally like with a parameter --add-prefix for example?

lopes commented 4 years ago

Your suggestion is good: if a certain flag is used, netbox-scanner will guess the prefix and append it to IP addr. If we use the current version of your PR, hosts will be recorded with network addresses, which is not right.

mikeb93 commented 4 years ago

I'm trying to update my PR to implement this if a flag is set but my free time for this is limited as well.

mikeb93 commented 4 years ago

Please check PR #7 which I updated. I commented on the PR

lopes commented 4 years ago

Thanks for your help. I created issue #18 and this will be fixed there along with other improvements.