lopes / netbox-scanner

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

Getting Traceback Centos 7 #2

Closed jdtinsley88 closed 5 years ago

jdtinsley88 commented 5 years ago

Traceback (most recent call last): File "nbscanner", line 5, in from configparser import ConfigParser ImportError: No module named configparser

I have installed the following -

pip install configparser Collecting configparser Downloading https://files.pythonhosted.org/packages/7c/69/c2ce7e91c89dc073eb1aa74c0621c3eefbffe8216b3f9af9d3885265c01c/configparser-3.5.0.tar.gz Installing collected packages: configparser Running setup.py install for configparser ... done Successfully installed configparser-3.5.0

But still running into that same issue.

lopes commented 5 years ago

I can't reproduce this error in my environment, but README shows the best way to satisfy dependencies:

$ pip install -r requirements.txt

See README for more details. Let me know if this works.

Regards, José Lopes

On Fri, Dec 21, 2018 at 4:15 PM jdtinsley88 notifications@github.com wrote:

Traceback (most recent call last): File "nbscanner", line 5, in from configparser import ConfigParser ImportError: No module named configparser

I have installed the following -

pip install configparser Collecting configparser Downloading https://files.pythonhosted.org/packages/7c/69/c2ce7e91c89dc073eb1aa74c0621c3eefbffe8216b3f9af9d3885265c01c/configparser-3.5.0.tar.gz Installing collected packages: configparser Running setup.py install for configparser ... done Successfully installed configparser-3.5.0

But still running into that same issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

-- José Lopes de Oliveira Jr.

jdtinsley88 commented 5 years ago

Same thing.

I did go ahead and try this –

pip3 install netbox-scanner

However, I get the following but I cannot find a configuration file to modify –

python nbscanner.py

File "nbscanner.py", line 195

parsing = self.parser([f'{h[0]}/32' for h in hosts])

Thanks,

Jordan

From: José Lopes notifications@github.com Sent: Friday, December 21, 2018 12:38 PM To: forkd/netbox-scanner netbox-scanner@noreply.github.com Cc: jdtinsley88 jtinsley@LRECOK.COOP; Author author@noreply.github.com Subject: Re: [forkd/netbox-scanner] Getting Traceback Centos 7 (#2)

I can't reproduce this error in my environment, but README shows the best way to satisfy dependencies:

$ pip install -r requirements.txt

See README for more details. Let me know if this works.

Regards, José Lopes

On Fri, Dec 21, 2018 at 4:15 PM jdtinsley88 <notifications@github.com mailto:notifications@github.com > wrote:

Traceback (most recent call last): File "nbscanner", line 5, in from configparser import ConfigParser ImportError: No module named configparser

I have installed the following -

pip install configparser Collecting configparser Downloading https://files.pythonhosted.org/packages/7c/69/c2ce7e91c89dc073eb1aa74c0621c3eefbffe8216b3f9af9d3885265c01c/configparser-3.5.0.tar.gz Installing collected packages: configparser Running setup.py install for configparser ... done Successfully installed configparser-3.5.0

But still running into that same issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

-- José Lopes de Oliveira Jr.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/forkd/netbox-scanner/issues/2#issuecomment-449465740 , or mute the thread https://github.com/notifications/unsubscribe-auth/ArlVOHzRIpu8AWF5UE_otX_8_y4cTlqzks5u7Sp1gaJpZM4Zefmv . https://github.com/notifications/beacon/ArlVOHBi8CC2pfP-C5v1Dyr5Ib5yEKjtks5u7Sp1gaJpZM4Zefmv.gif

lopes commented 5 years ago

That is not the same problem. f-strings are only present in Python 3.6+ and I noticed, you're using 3.5. The first issue has a solution: https://github.com/forkd/netbox-scanner/issues/1

jdtinsley88 commented 5 years ago

Okay, I installed python 3.7.0 from source. Now I get this error even though I have nmap installed.

python3.7 nbscanner.py

Traceback (most recent call last):

File "nbscanner.py", line 6, in

from nmap import PortScanner

ModuleNotFoundError: No module named 'nmap'

From: José Lopes notifications@github.com Sent: Friday, December 21, 2018 1:01 PM To: forkd/netbox-scanner netbox-scanner@noreply.github.com Cc: jdtinsley88 jtinsley@lrecok.coop; Author author@noreply.github.com Subject: Re: [forkd/netbox-scanner] Getting Traceback Centos 7 (#2)

That is not the same problem. f-strings are only present in Python 3.6+ and I noticed, you're using 3.5. The first issue has a solution: #1 https://github.com/forkd/netbox-scanner/issues/1

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/forkd/netbox-scanner/issues/2#issuecomment-449471309 , or mute the thread https://github.com/notifications/unsubscribe-auth/ArlVOP6dRUBL9yKC6F2cYrvMMZMd0vWZks5u7S_tgaJpZM4Zefmv . https://github.com/notifications/beacon/ArlVODtn0IwdMuVv6JCh6KrvEh2j4whdks5u7S_tgaJpZM4Zefmv.gif

lopes commented 5 years ago

Man, CentOS is a bit different from other distros in Python3, please read the distro docs.

Maybe the best way to install Python3 in CentOS is shown below.

# yum -y install https://centos7.iuscommunity.org/ius-release.rpm
# yum -y update && yum -y upgrade
# yum install git python36u python36u-pip
#
# wget https://github.com/forkd/netbox-scanner/archive/master.zip
# unzip netbox-scanner-master.zip -d netbox-scanner
# cd netbox-scanner
# pip3.6 install -r requirements.txt
# python netbox-scanner/nbscanner

If your problem persists, I suggest you to use another Linux version or search in CentOS community, because that's not a problem with netbox-scanner, but with your setup.

jdtinsley88 commented 5 years ago

Okay, now I have it working, except for the conf file. I have created a token through the Web Interface.

In the conf file, I have entered a network under the “Scan” section and also entered under the “NETBOX” section, http://localhost for the address (where I have NetBox installed), entered the token.

Here is the output I received –

python3.6 netbox-scanner/nbscanner

Traceback (most recent call last):

File "netbox-scanner/nbscanner", line 75, in

nbs.sync(networks)

File "/root/netbox-scanner/netbox-scanner-master/netbox-scanner/nbscanner.py", line 223, in sync

self.sync_network(network)

File "/root/netbox-scanner/netbox-scanner-master/netbox-scanner/nbscanner.py", line 157, in sync_network

self.sync_host(host)

File "/root/netbox-scanner/netbox-scanner-master/netbox-scanner/nbscanner.py", line 131, in sync_host

nbhost = self.netbox.ipam.ip_addresses.get(address=host[0])

File "/usr/lib/python3.6/site-packages/pynetbox/lib/endpoint.py", line 157, in get

filter_lookup = self.filter(**kwargs)

File "/usr/lib/python3.6/site-packages/pynetbox/lib/endpoint.py", line 247, in filter

for i in req.get()

File "/usr/lib/python3.6/site-packages/pynetbox/lib/query.py", line 240, in get

return req_all(self.url)

File "/usr/lib/python3.6/site-packages/pynetbox/lib/query.py", line 222, in req_all

req = make_request(url)

File "/usr/lib/python3.6/site-packages/pynetbox/lib/query.py", line 219, in make_request

raise RequestError(req)

pynetbox.lib.query.RequestError: The request failed with code 400 Bad Request

From: José Lopes notifications@github.com Sent: Friday, December 21, 2018 1:22 PM To: forkd/netbox-scanner netbox-scanner@noreply.github.com Cc: jdtinsley88 jtinsley@lrecok.coop; Author author@noreply.github.com Subject: Re: [forkd/netbox-scanner] Getting Traceback Centos 7 (#2)

Man, CentOS is a bit different from other distros in Python3, please read the distro docs.

Maybe the best way to install Python3 in CentOS is shown below.

yum -y install https://centos7.iuscommunity.org/ius-release.rpm

yum -y update && yum -y upgrade

yum install git python36u python36u-pip

#

wget https://github.com/forkd/netbox-scanner/archive/master.zip

unzip netbox-scanner-master.zip -d netbox-scanner

cd netbox-scanner

pip3.6 install -r requirements.txt

python netbox-scanner/nbscanner

If your problem persists, I suggest you to use another Linux version or search in CentOS community, because that's not a problem with netbox-scanner, but with your setup.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/forkd/netbox-scanner/issues/2#issuecomment-449476219 , or mute the thread https://github.com/notifications/unsubscribe-auth/ArlVOA1Crl7XsRd5NaCzsImy_lTxSUJ7ks5u7TTmgaJpZM4Zefmv . https://github.com/notifications/beacon/ArlVOGX5Irzpkpc6qeF0JPnWs1BuW9Drks5u7TTmgaJpZM4Zefmv.gif

lopes commented 5 years ago

Which version of NetBox are you using there? netbox-scanner was tested only in v2.4.

It seems that your NetBox instance fails to add a new IP: nbhost = self.netbox.ipam.ip_addresses.get(address=host[0])

Edit: not to add, but netbox-scanner is not able to retrieve an IP addr from your NB instance.

jdtinsley88 commented 5 years ago

I got it working now.

Also, a couple more questions –

  1. Is there any way to modify the description from nmap to include the MAC Address?
  2. How do you include tags to match up to different networks? Such as “network1” for one subnet and “network2” for another subnet.

From: José Lopes notifications@github.com Sent: Friday, December 21, 2018 3:27 PM To: forkd/netbox-scanner netbox-scanner@noreply.github.com Cc: jdtinsley88 jtinsley@lrecok.coop; Author author@noreply.github.com Subject: Re: [forkd/netbox-scanner] Getting Traceback Centos 7 (#2)

Which version of NetBox are you using there? netbox-scanner was tested only in v2.4.

It seems that your NetBox instance fail to add a new IP: nbhost = self.netbox.ipam.ip_addresses.get(address=host[0])

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/forkd/netbox-scanner/issues/2#issuecomment-449502459 , or mute the thread https://github.com/notifications/unsubscribe-auth/ArlVOMS7KO66oZ0659jYPABaTL7oZKAhks5u7VIpgaJpZM4Zefmv . https://github.com/notifications/beacon/ArlVOF5TBzegGKrw172TWKzJ3SwNWeZMks5u7VIpgaJpZM4Zefmv.gif

lopes commented 5 years ago
  1. I really tried to do that, but Nmap can't find MAC addresses between networks*. It would be great to store that information.

  2. There's no way to do that in the current version of netbox-scanner. It only adds a tag to allow admins control what is managed automatically by this script. In my case, I have seen no other use for tags. I control networks using the prefix field in NetBox.

Good to know it it working right now.