jamiecaesar / securecrt-tools

SecureCRT scripts, written in Python, for doing various tasks when connected to Cisco equipment.
Apache License 2.0
252 stars 77 forks source link

s_switchport_mapping.py wrong output #44

Closed aegcni81 closed 5 years ago

aegcni81 commented 5 years ago

Hello friend. Sorry for bother you again, but there is a BUG (wrong output) with s_switchport_mapping.py script when using VRF. The issue is the following:

I have 1 VRF with 2 different VLAN's (and subnets). When running s_switchport_mapping.py script it's showing wrong subnet in the output, for example:

CSV result from s_arp_to_csv.py (everyting is correct):

ADDRESS AGE MAC INTERFACE TYPE 10.29.118.5 13 74c9.9a1f.1345 Vlan3105 ARPA 10.29.118.6 3 74c9.9a1f.120d Vlan3105 ARPA 10.29.119.5 8 74c9.9a1f.1345 Vlan3106 ARPA 10.29.119.6 8 74c9.9a1f.120d Vlan3106 ARPA

CSV result from s_switchport_mapping.py (wrong IP for VLAN 3105):

Interface Status MAC MAC Vendor DNS Name IP Address VLAN Description TenGigabitEthernet8/3 connected 74c9.9a1f.1345 Ericsson AB 10.29.119.5 3106 SERVER TenGigabitEthernet8/3 connected 74c9.9a1f.1345 Ericsson AB 10.29.119.5 3105 SERVER TenGigabitEthernet8/3 connected a4a1.c2eb.4bb6 Ericsson AB 10.29.119.44 3106 SERVER TenGigabitEthernet8/3 connected a4a1.c2eb.4bb6 Ericsson AB 10.29.119.44 3105 SERVER

The correct subnet for VLAN 3105 is 10.29.118.X

Best regards.

jamiecaesar commented 5 years ago

Hm, ok. I'll take a look at it. I might need you to send me some outputs so I can try to reproduce the issue, but I'll start looking at it on my own first.

jamiecaesar commented 5 years ago

Oh, I see what the problem is. The host has the same MAC address on multiple VLANs, and (if I remember right) the script just looks up the MAC address only and will only choose one. I'll have to update the logic to account for both the MAC and VLAN combination. I'm not sure on an ETA for that with everything going on this week -- hopefully in a week or so. Hopefully it isn't a huge problem for you!

aegcni81 commented 5 years ago

Thank you Jamie.

As you said, that's not a big problem. What I have been done, it's just remove the VLAN I'm not interested in from the first CSV file and everything work as expected.

Please let me know if you find the time to fix it and thanks again for your help.

Best regards.

jamiecaesar commented 5 years ago

Found a little time to make a change. If you don't mind, please switch to the 'devel' branch and try the version of the switchport mapping script and see if that works. I'm not sure if you used git to clone the repository, or just downloaded the zip. If using git, you should be able to just "git checkout devel" and then "git pull" to get the latest, otherwise you'll need to download the zip of the devel branch and try that script. If it fixes your problem, I'll merge it into the master branch.

aegcni81 commented 5 years ago

Hello Jamie.

I really appreciate your work, It's awesome.

The script is now working as expected, thanks again.

Regards.

jamiecaesar commented 5 years ago

Thanks. Closing this issue and I'll merge the updated version into the master branch.