update: README + netbox 2.9.x compatability

This commit is contained in:
ndom91 2020-11-16 17:02:25 +01:00
parent 9bca20b010
commit c74a875408
5 changed files with 19 additions and 10 deletions

View File

@ -16,6 +16,13 @@ $ pip install -r requirements.txt
After installation, use the `netbox-scanner.conf` file as an example to create your own and put this file in `/opt/netbox` or prepend its name with a dot and put it in your home directory --`~/.netbox-scanner.conf`. Keep reading to learn more about configuration.
> Starting with Netbox **v2.9.0** there are changes to the way tags are created. You must go into the web UI and explicity create a tag for each module you are planning to use here. So for example, if you want to use the nmap module, you have to create a Netbox tag called 'nmap' before you can successfully use it.
## Quick Start
0. Clone the repo and install the dependencies as shown above.
1. Move the `netbox-scanner.conf` file to your Netbox directory (`/opt/netbox`) and fill out the variables according to your setup.
2. Go to the `samples` subdirectory of this repo and execute `./nmap-scan.sh` to get a first look at the behavior of this project.
## Basics
netbox-scanner reads a user-defined source to discover IP addresses and descriptions, and insert them into NetBox. To control what was previously inserted, netbox-scanner adds tags to each record, so it will know that that item can be handled. In order to guarantee the integrity of manual inputs, records without such tags will not be updated or removed.

View File

@ -47,7 +47,7 @@ class NetBoxScanner(object):
else:
self.netbox.ipam.ip_addresses.create(
address=host[0],
tags=[self.tag],
# tags=[self.tag],
description=host[1]
)
logging.info(f'created: {host[0]}/32 "{host[1]}"')
@ -88,3 +88,4 @@ class NetBoxScanner(object):
))
return True

View File

@ -5,7 +5,7 @@ tls_verify = no
logs = .
[NMAP]
path = samples/nmap
path = /opt/netbox-scanner/samples/nmap
unknown = autodiscovered:netbox-scanner
tag = nmap
cleanup = yes

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
#
# This is just an example.
#
@ -16,11 +16,12 @@
# to look for XML files.
##
NETWORKS = "10.1.2.3/24 10.2.3.4/32 192.168.0.0/19"
TODAY="$(date +%d.%m.%yT%H:%M:%S%Z)"
NETWORKS="10.1.2.3/24 10.2.3.4/32 192.168.0.0/19"
TODAY="$(date +%d%m%yT%H%M%S%Z)"
for net in $NETWORKS; do
nmap -T4 -O -F --host-timeout 30s -oX nmap-"$net".xml
rawNet="${net:0:-3}"
sudo nmap -T4 -O -F --host-timeout 30s -oX nmap-"$rawNet".xml "$net"
done
python ../netbox-scanner.py nmap

0
samples/nmap/.gitkeep Normal file
View File