MJL85 / natlas

natlas - Network Discovery and Auto-Diagramming
GNU General Public License v2.0
518 stars 112 forks source link

Discovery crash on ipv6 address #66

Open kpoman opened 3 years ago

kpoman commented 3 years ago

Hello, I am trying to run a discovery. I get correct result from the root switch and connected ones, however, it crashs when it encounters a workstation that has ipv4 and ipv6. See below logs:

kpoman@vmlab:~/natlas-master$ python3 natlas-cli.py diagram -r 10.1.1.29 -o lffm_natlas.png -c natlas.conf -d 3
natlas v0.12.1
Michael Laforest <mjlaforest@gmail.com>
Python 3.8.10

     Config file: natlas.conf
     Output file: lffm_natlas.png
Out Catalog file: None
       Root node: 10.1.1.29
  Discover depth: 3
   Diagram title: natlas Diagram

Discovery codes:
    . depth             ! connection error
    + discovering node  > numerating adjacencies
    i include node      L leaf node

Discovering network...
1  [root]  +Rack Principal (10.1.1.29)
   [root]  >Rack Principal (10.1.1.29)
2  [lldp]  +.sw35 (10.1.1.35)
3  [lldp]  +.sw38 (10.1.1.38)
4  [lldp]  +.sw36 (10.1.1.36)
5  [lldp]  +.sw37 (10.1.1.37)
6  [lldp]  +.sw39 (10.1.1.39)
Traceback (most recent call last):
  File "/home/kpoman/.local/lib/python3.8/site-packages/pysnmp/hlapi/asyncore/transport.py", line 56, in _resolveAddr
    return socket.getaddrinfo(transportAddr[0],
  File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "natlas-cli.py", line 305, in <module>
    main(sys.argv[1:])
  File "natlas-cli.py", line 96, in main
    exec_mod(mod, argv[1:])
  File "natlas-cli.py", line 167, in exec_mod
    modret = module.entryfunc(natlas_obj, argv)
  File "/home/kpoman/natlas-master/./modules/diagram.py", line 85, in mod_entry
    natlas_obj.discover_network(opt_root_ip, 1)
  File "/home/kpoman/natlas-master/natlas/natlas.py", line 102, in discover_network
    self.network.discover(root_ip)
  File "/home/kpoman/natlas-master/natlas/network.py", line 117, in discover
    self.__discover_node(node, 0)
  File "/home/kpoman/natlas-master/natlas/network.py", line 397, in __discover_node
    child, query_result = self.__query_node(n.remote_ip, n.remote_name)
  File "/home/kpoman/natlas-master/natlas/network.py", line 275, in __query_node
    if (node.try_snmp_creds(self.config.snmp_creds) == 0):
  File "/home/kpoman/natlas-master/natlas/node.py", line 249, in try_snmp_creds
    if (self.snmpobj.get_cred(snmp_creds) == 1):
  File "/home/kpoman/natlas-master/natlas/snmp.py", line 156, in get_cred
    cmdgen.UdpTransportTarget((self._ip, SNMP_PORT)),
  File "/home/kpoman/.local/lib/python3.8/site-packages/pysnmp/hlapi/transport.py", line 19, in __init__
    self.transportAddr = self._resolveAddr(transportAddr)
  File "/home/kpoman/.local/lib/python3.8/site-packages/pysnmp/hlapi/asyncore/transport.py", line 62, in _resolveAddr
    raise error.PySnmpError('Bad IPv4/UDP transport address %s: %s' % (
pysnmp.error.PySnmpError: Bad IPv4/UDP transport address 254.128.0.0.0.0.0.0.2.12.41.255.254.104.242.110@161: [Errno -2] Name or service not knowncaused by <class 'socket.gaierror'>: [Errno -2] Name or service not known
kpoman@vmlab:~/natlas-master$ 

When debugging, I do see a node with this data:

<name=vmlab, ip=['254.128.0.0.0.0.0.0.2.12.41.255.254.104.242.110'], plat=None, ios=None, serial=None, router=None, vss=<enabled=0,domain=None,members=[, ]>, stack=>

looking at that reported IP, it does match with that station ipv6 address: fe80::20c:29ff:fe68:f26e/64

Is there any woakraround ?