We use ssh to connect to cisco switches through linux box.it prompts for a password and then we are logged in.I was just wondering if i could find out a way to list out all the cisco switches connected to the linux machine.Approximately there are around 3000 switches that i can ssh to from the linux machine.
-
Are you allowed to run nmap or other port scanning software? That would give you a list of devices which are connected to your network which you can then filter by MAC. (Cisco MACs: See miniwebtool.com/mac-address-lookup/?s=cisco ). Or use ZenMap (a GUI frontend) to do the same.– HennesApr 11, 2013 at 5:04
-
yes i am allowed– munishApr 11, 2013 at 5:10
2 Answers
You did not specify which Linux distribution. If it is one with a package manager then add the nmap package. If it has no package manager or if you want to compile it yourself go to http://nmap.org and get the tarball.
Compile it and test it on a few known host (a few so initial tests are quick).
Examples:
nmap -v 127.0.0.1
(-v is verbose)
nmap 172.16.0.0/12
(One way to scan a large range)
nmap 192.168.1.1-254
(an other way to specify a range)
In your case you might want the flags s
and n
.
nmap -sn 192.168.1.252 Starting Nmap 5.51 ( http://nmap.org ) at 2013-04-11 07:22 W. Europe Daylight Time Nmap scan report for 192.168.1.252 Host is up (0.00s latency). MAC Address: 00:1E:E5:7A:47:5B (Cisco-Linksys) Nmap done: 1 IP address (1 host up) scanned in 0.39 seconds
Use these to scan your entire own network amdlog the results to a file. Then sort that on the brand name or MAC and you have your desired list.
Nmap supports arp-scan which would be effective in a LAN. Since all you need is the MAC, TCP port scan can be omitted. It's important to run nmap as the superuser (sudo works too):
$ su -c 'nmap -PR -oN arp-scan.txt 10.3.0.0/27'
Password:
(...)
$ grep '^[NM][Am]' arp-scan.txt
Nmap scan report for tryggve.lan (10.3.0.3)
MAC Address: 00:16:17:6D:AC:3A (MSI)
Nmap scan report for 10.3.0.6
MAC Address: 00:19:DB:F6:EB:B6 (Micro-star International CO.)
Nmap scan report for deeebian.lan (10.3.0.7)
$ awk '/MSI|Micro/ {print $3}' arp-scan.txt
00:16:17:6D:AC:3A
00:19:DB:F6:EB:B6
source:
http://nmap.org/book/man-host-discovery.html
You can also discover recently contacted MACs with ip(1), but then you would have to manually correlate the results with the mac-prefixes from /usr/share/nmap/nmap-mac-prefixes.
# ip neighbor
-
-
Install the equivalent package of sys-apps/iproute2 on your system, but nmap is the better option for this task. Apr 11, 2013 at 12:52