Oct 182009
 

It is official, I have begun development on the Web Server and Database for the Port Report Project and the Network Device Manager Project. I will be combining both scripts into a True Network Device Manager. My goal is to create an Open Source Network Device Manager that will give Admins and Engineers complete Insight/Access to their network. It does not matter if you want to know which switch your ESX host is directly connected to or if you want to manage all your Switches/Linux Hosts with this product. We have a few more ideas on what we want to do, but they are just ideas and I will not post them yet.

I will be using Python, Pexpect, PySnmp, SQLAlchemy, and Django for this project. I’m hoping to have an Alpha for users to test by late November or early December. If you are interested in this project, please give me ideas on what you would like to see in this Project. Currently we do not have an official name for the project.  If you have one, let me know as well. All ideas are welcome, as we are trying to make a complete enterprise product out of this project.

Oct 012009
 

Quick update today! User Christianha, pointed out to me that the port_report tool was not matching any MAC address he passed. The reason for this is because he was passing the MAC address in uppercase. As per his suggestion, I fixed line 348 so that before it returns the mac, it willl make the MAC lower case. Then I just realized something…. I reverted line 348 back to way it was and changed line 676 instead..

It was if nmac == cmac:
Now it is  re.search(nmac, cmac, re.IGNORECASE):

I felt this was the safer option..

Thank you Christianha for pointing the issues out..

LD Port Report == Download

May 052009
 

The Port Report Project is essentially a Switch Port Mapper Tool or a Switch Port Mapping Tool like a few other commercial products out there, except The Port Report Project is free. Right now there is no GUI or WEB interface for the project but it is in the works.

This project started off as being a simple 150 line script that did something quite simple… Its only purpose was to find MAC Addresses on a switch. Then I was asked could you also search by IP, so I added that. Now I was asked to search by Port, so I added that. Well you get where this is all going…. My goal now is to build the equivalent of other commercial port mapping tools, but Open Source….

On this page I will be keeping all the updates to this Project, so please keep checking back every now and again for updates.
You can get any revision of the Port Report tool here http://www.linuxdynasty.org/Port-Report-Project/
{quickdown:39}

Any issues with the LD Port Report Project, please discuss here in the forums
This script requires, Pysnmp and Pyasn1. If you have python-setuptools, you can install it by running this..
easy_install pysnmp, easy_install pyasn1

Three things you will need for this script to work..

  1. Pysnmp
  2. Pyasn1
  3. SNMP Access to the switch you want to talk too and its community string.
To make your life easier you should do the following
  1. install python-setuptools
  2. then run easy_install pysnmp
  3. and easy_install pyasn1
  4. or you can download the 2 modules manually.
    pysnmp and pyasn1
  5. then unzip the 2 files and in each directory run python setup.py install

I am using the following revisions from the python cheese shop pysnmp 4.1.12a and pyasn1 0.0.9a

For revision 1.12 and above….. If you installed pyasn1 and pysnmp using easy_install. Please uninstall it now and install the newest revision and run python setup.py install Instead of using easy_install.
Revision history and Examples below…..
Revision 1.13 10/01/09

  • Fixed line 348 as per christianha. return nmac.lower()
    This fix will allow you to pass a MAC in all uppercase and still match though the switch is responding in lowercase.
    00 E0 B8 81 E8 B7 will now match 00 e0 b8 81 e8 b7

Revision 1.12 09/18/09

  • The report option of the script can now follow cdp neighbors using the –follow option or -f.
    When you run the command below it will create ONE CSV file per cdp neighbor it scanned.
    I was able to scan from my core Switch down to the last neighbor in the line ( 44 Neighbors in just under 20 minutes. )
    Which equaled to a little over 4K Mac Addresses
    For instance…port_report.py -d 192.168.101.1 -c public -r -f

Revision 1.11 09/13/09

  • More code clean up and another increase in speed.
  • Also port_report can now follow EtherChannel
  • Added better verbosity
  • Added Sanity Checking for cdp neighbors

 

Revision 1.10 09/09/09

  • Code Clean up and a slight increase in speed ( by a few seconds ) during the search by mac or ip

Revision 1.9
Code changes and Added CDP Support

  • Detect CDP Neighbors during the scan for MAC Addresses or IP Addresses

Revision 1.8
Here is a quick update…..

  • I just add dns reverse lookups to the output of this script.

Revision 1.7
Adds support to the following devices..

  1. Cisco
    • Catalyst 6509 w/ Supervisor 720 running IOS
    • Catalyst 3560
    • Catalyst 3550 (SMI)
    • Cisco CIGESM series Chassis Blades
    • Cisco Catalyst 2960
  2. Foundry
    • Foundry Server Iron
  3. Nortel
    • Nortel Passport 8600
    • Nortel 5520 Ethernet Routing Switch
  4. HP
    • HP Procurve 5406xl

 

Revision 1.6
New additions to this revision ….

  • Support for HP Procurve Switches, ( Tested on the newer versions of HP )
  • combined switch_report.py in port_report.py.
  • Added –verbose flag

Previous Releases….

  • Search by MAC or IP or PORT

 

EXAMPLES BELOW…

Below is an example of the integrated CDP following of switches using the -m ( –mac ) option

 

python port_report.py -d switch -c community -m "00 13 20 16 5f f7" 
Switch Connected to 192.168.101.1 
SwitchPort = GigabitEthernet10/3 
SwitchPortSpeed = 1000mb 
SwitchPortDuplex = fullDuplex 
SwitchVlan = vlan176 
SnmpHostName = requestTimedOut 
SnmpHostDescr = requestTimedOut 
HostMAC = 00 13 20 16 5f f7 
HostIP = 192.168.101.101 
HostName = Pointer Record Not set for 192.168.101.101 

Found 00 13 20 16 5f f7 on 192.168.101.5
Switch Connected to 192.168.101.5 
SwitchPort = GigabitEthernet0/24 
SwitchPortSpeed = 1000mb 
SwitchPortDuplex = fullDuplex 
SwitchVlan = vlan176 
SnmpHostName = No SNMP Access 
SnmpHostDescr = No SNMP Access 
HostMAC = 00 13 20 16 5f f7 
HostIP = None 
HostName = None 

Found 00 13 20 16 5f f7 on 192.168.101.6 
Switch Connected to 192.168.101.6 
SwitchPort = GigabitEthernet0/22 
SwitchPortSpeed = 1000mb 
SwitchPortDuplex = fullDuplex 
SwitchVlan = vlan176 
SnmpHostName = No SNMP Access 
SnmpHostDescr = No SNMP Access 
HostMAC = 00 13 20 16 5f f7 
HostIP = None 
HostName = None 

This MAC 00 13 20 16 5f f7 was finally traced to this switch 192.168.101.6

Below I will show you an example of the listing of MAC Addresses per Port using the n (–pname) option

python port_report.py -d 192.168.101.1 -c community -n "10/3"
SwitchPort = GigabitEthernet10/3
SwitchPortSpeed = 1000mb
SwitchPortDuplex = fullDuplex
SwitchVlan = vlan176
SnmpHostName = requestTimedOut
HostDescr = requestTimedOut
HostMAC  = 00 22 64 bb 3e 17
HostIP = 192.168.101.146
HostName = Pointer Record Not set for 192.168.101.146

SwitchPort = GigabitEthernet10/3
SwitchPortSpeed = 1000mb
SwitchPortDuplex = fullDuplex
SwitchVlan = vlan176
SnmpHostName = requestTimedOut
HostDescr = requestTimedOut
HostMAC  = 00 0c f1 bb bf eb
HostIP = 192.168.101.147
HostName = Pointer Record Not set for 192.168.101.147

SwitchPort = GigabitEthernet10/3
SwitchPortSpeed = 1000mb
SwitchPortDuplex = fullDuplex
SwitchVlan = vlan176
SnmpHostName = requestTimedOut
HostDescr = requestTimedOut
HostMAC  = 00 20 4a 83 20 97
HostIP = 192.168.101.30
HostName = Pointer Record Not set for 192.168.101.30

Below is an example of running the –report option.. Also the report option will save the output to disk in a CSV file.

python port_report.py -d 192.168.101.5 -c community --report
GigabitEthernet0/1,00 1c c0 12 6a 8b,None,None,vlan180,up,up,fullDuplex,1000mb,
GigabitEthernet0/1,00 20 4a 12 2b 68,None,None,vlan180,up,up,fullDuplex,1000mb,
GigabitEthernet0/1,00 12 44 94 dc 40,192.168.101.132,Pointer Record Not set for 192.168.101.132,vlan180,up,up,fullDuplex,1000mb,
GigabitEthernet0/1,00 21 5a c7 81 16,None,None,vlan180,up,up,fullDuplex,1000mb,
GigabitEthernet0/3,00 20 4a 12 2b 71,None,None,vlan180,up,up,halfDuplex,10mb,

Below is an example of searching by IP Addresses -i (–ip)..

python port_report.py -d 192.168.101.1 -c ommunity -i "192.168.101.200"
Switch Connected to 192.168.101.1
SwitchPort = GigabitEthernet1/17
SwitchPortSpeed = 1000mb
SwitchPortDuplex = unknown
SwitchVlan = vlan175
SnmpHostName = zenmon.linuxdynasty.org
SnmpHostDescr = Linux zenmon.linuxdynasty.org 2.6.18-92.1.22.el5 #1 SMP Tue Dec 16 12:03:43 EST 2008 i686HostMAC  = 00 14 38 4f 5e 38HostIP = 192.168.101.200HostName = zenmon.linuxdynasty.org
Apr 072009
 

 

The Port Report Project is essentially a Switch Port Mapper Tool or a Switch Port Mapping Tool like a few other commercial products out there, except The Port Report Project is free. Right now there is no GUI or WEB interface for the project but it is in the works.

The other day I was speaking to a buddy of mine. I asked him how cool would it be, if you could just get the port on a switch that you are plugged into, in one line?? So since I thought about it… I figured why not…. I just finished writing the first revision ( I’m assuming more to come). I must say that I am quite pleased with it. Right now you can pass the switch you want to talk too, the community string, and either the MAC or IP address of the host device. In return you will get the MAC Address, IP Address, Port Description (VLAN), and Port you are plugged into.

This script requires, Pysnmp and Pyasn1. If you have python-setuptools, you can install it by running this..
easy_install pysnmp, easy_install pyasn1

 

Three things you will need for this script to work..

  1. Pysnmp
  2. Pyasn1
  3. SNMP Access to the switch you want to talk too and its community string.
To make your life easier you should do the following
  1. install python-setuptools
  2. then run easy_install pysnmp
  3. and easy_install pyasn1
  4. or you can download the 2 modules manually.
    pysnmp and pyasn1
  5. then unzip the 2 files and in each directory run python setup.py install

I am using the following revisions from the python cheese shop pysnmp 4.1.7a  and pyasn1 0.0.6a

 

Revision 2, will even add more features like…

  • Trying to find out what is plugged into a certain Port.
  • Passing a list of switches
  • follow chained switches
  • Gettinginfo from non vlan ports.
  • If you have more ideas, please let me know..

Update 1.7….This is a big update for Port Report…. In this revision the following brands and devices are supported

  1. Cisco
    • Catalyst 6509 w/ Supervisor 720 running IOS
    • Catalyst 3560
    • Catalyst 3550 (SMI)
    • Cisco CIGESM series Chassis Blades
    • Cisco Catalyst 2960
  2. Foundry
    • Foundry Server Iron
  3. Nortel
    • Nortel Passport 8600
    • Nortel 5520 Ethernet Routing Switch
  4. HP
    • HP Procurve 5406xl

The Script has been tested with the above devices… If you have run this script against other devices, please let us know. Also the speed in the report function has drastically increased. I ran this script against a 6509 with 800+ devices connected to it in just over 2 minutes.

You can download the script here {quickdown:44}

Update..  revision 1.6 has been released.

  • Support for HP PROCURVE switches
  • Added Verbose option
  • Combined switch_report.py in port_report.py

Update, version 1.4…
Only changes that have been made are below..

  • Code Clean up
  • added check by port name
  • Added Error Checking
  • fixed a few bugs with matching the ifIndex port to the bridgeport

So from the looks of it this script does work on Cisco Switches,which has been tested. But does not work on HP Procurve switches. I would like to add this feature to this script but I do not have HP switches to test on.  If anyone would like me to add this feature to HP switches oranyother manufacturer please let me know and maybe we can work together to get it working.

     example below...    python get_port.py -d "switch" -c "community" -m "mac address"

    MAC Address = 00 14 28 1f 2d 38    IP Address = 192.168.101.100    PortDescr = Vlan175    Port = GigabitEthernet1/17

    python get_port.py -d "switch" -c "community" -i "ip address"

    MAC Address = 00 14 28 1f 2d 38    IP Address = 192.168.101.100    PortDescr = Vlan175    Port = GigabitEthernet1/17

Please post any questions related to this script here.. http://www.linuxdynasty.org/forums/Scripting/scripting/port_report
You can download the script here… get_port.py

python port_report.py -d 192.168.101.1 -c public --report GigabitEthernet1/11,00 21 5a 80 0b a6,192.168.101.23,vlan51,up,up,fullDuplex,1gbps,GigabitEthernet1/12,00 12 79 83 3b f3,192.168.101.24,vlan51,up,up,fullDuplex,1gbps,

python port_report.py -d 192.168.101.1 -c public -i "192.168.101.201"This IPAddress is not in the ARP table

python port_report.py -d 192.168.101.1 -c public -i "192.168.101.202"--verboseFri Apr 24 15:15:41 2009  Main StartedFri Apr 24 15:15:41 2009  In snmpget function Fri Apr 24 15:15:42 2009  Out of snmpget function Cisco Internetwork Operating System Software IOS (tm) s72033_rp Software (s72033_rp-JK9S-M), Version 12.2(17d)SXB7, RELEASE SOFTWARE (fc2)Technical Support: http://www.cisco.com/techsupportCopyright (c) 1986-2005 by cisco Systems, Inc.Compiled ThuFri Apr 24 15:15:42 2009  Finished Checking for macFri Apr 24 15:15:42 2009  Found IPFri Apr 24 15:15:42 2009  192.168.101.202 is a Cisco Switch Fri Apr 24 15:15:42 2009  In generic_mac_or_ip Function00 14 38 4f 5e 38 Fri Apr 24 15:15:42 2009  Looping Through CommTableFri Apr 24 15:15:42 2009  In CommTable For LoopFri Apr 24 15:15:42 2009  First If Statement Fri Apr 24 15:15:42 2009  Looping Through CommTableFri Apr 24 15:15:42 2009  In CommTable For LoopFri Apr 24 15:15:42 2009  Looping Through CommTableFri Apr 24 15:15:42 2009  In CommTable For Loop

python port_report.py -d 192.168.101.1 -c public -i "192.168.101.209"MAC  = 00 14 38 7f 6e 38Port = GigabitEthernet1/17Vlan = 175IPAddr = 192.168.101.209

python port_report.py -d 192.168.101.1 -c public -m "00 14 38 4f 5e 39"MAC  = 00 14 38 4f 5e 39Port = GigabitEthernet1/17Vlan = 175IPAddr = 192.168.101.201

python port_report.py -d 192.168.101.1 -c public -n "1/40"Port 1/40 has the below MAC Addresses associated with itMAC  = 00 1b 95 97 3c 81Port = GigabitEthernet1/40Vlan = 1IPAddr = The IP Address for this MAC is not in the ARP Table

MAC  = 00 15 fa b4 10 06Port = GigabitEthernet1/40Vlan = 174IPAddr = The IP Address for this MAC is not in the ARP Table

Total MAC Addresses associated with this interface 2

python port_report.py -d 192.168.101.1 -c public -n "1/2"Port 1/2 has the below MAC Addresses associated with itMAC  = 08 00 0f 20 b3 aaPort = GigabitEthernet1/2Vlan = 176IPAddr = 192.168.101.104

MAC  = 08 00 0f 21 d3 78Port = GigabitEthernet1/2Vlan = 173IPAddr = 192.168.101.105

MAC  = 08 00 0f 20 b3 aaPort = GigabitEthernet1/2Vlan = 175IPAddr = 192.168.101.115

Warning: fopen(/home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/lib/standard.txt) [function.fopen]: failed to open stream: No such file or directory in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 104

Warning: fread(): supplied argument is not a valid stream resource in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 105

Warning: fclose(): supplied argument is not a valid stream resource in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 106
.