Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a system with more than 50 different Linux machines (BLADE machines) with the following IP range ( each Linux machine have 4 eth - eth1,2,3,4)

The system connected to 4 Cisco switches via LANS cable

My target is to verify each eth in the Linux machine were this eth connected to which port in the switch

for example


   machine1 results

   linux_machine1_eth0  connected to switch_1_port_15
   linux_machine1_eth1  connected to switch_2_port_15
   linux_machine1_eth2  connected to switch_1_port_16
   linux_machine1_eth3  connected to switch_2_port_16

   machine2 results

   linux_machine2_eth0  connected to switch_1_port_22
   linux_machine2_eth1  connected to switch_4_port_7
   linux_machine2_eth2  connected to switch_1_port_23
   linux_machine2_eth3  connected to switch_4_port_8


My question which tool can help to identify which eth in the Linux machines connected to which port in the switch?

       remark -     1. the tool can be also script that runs on the Linux machines
                    2. we have access to the switch by telnet 
share|improve this question
do you have access to the cisco switch? – Thomas Berger Aug 21 '11 at 13:06
No I dont have access -:) – Diana Aug 21 '11 at 13:08
Than, there is no way i think. Sorry – Thomas Berger Aug 21 '11 at 13:14
I think you wrong First we can create tool that search the MAC address on the eth and by show mac-address-table on the Cisco switch – Diana Aug 21 '11 at 13:19
But you need access to the switch for that! And you i thought you don't have that???? – Thomas Berger Aug 21 '11 at 13:29

I think you will have to go to each switch and issue the command

show mac-address-table

and make a note of the information provided. Then go to each linux machine and do something like

echo $(hostname); ifconfig eth0 | grep HWaddr | awk '{print " "$1,$5}'

Now you have 2 lists to match up.

share|improve this answer
@Lain the problem is that I need user/password for the cisco switch , second there are some free tolls that I can use them so why to development new script/cod ? – Diana Aug 21 '11 at 20:32

If CDP is enabled on the switch, you can give cdpr a try. It's a simple program that you run on the servers and listen to the CDP announces.

petrus@seth:~$ sudo cdpr
cdpr - Cisco Discovery Protocol Reporter
Version 2.2.1
Copyright (c) 2002-2006 -

1. eth0 (No description available)
2. wlan0 (No description available)
3. virbr0 (No description available)
12. lo (No description available)
Enter the interface number (1-12):1
Using Device: eth0
Waiting for CDP advertisement:
(default config is to transmit CDP packets every 60 seconds)

Device ID
  value:  switch01           
Port ID
  value:  0/15

cdpr can also upload the details to a web server using a GET request.

share|improve this answer
cdpr is work via - SNMP? , need to run cdpr on linux machine? – Diana Aug 21 '11 at 14:19
@Diana : cdpr runs on linux machines indeed. And if I understand you correctly, no there is no SNMP involved. CDP is another network protocol. – petrus Aug 21 '11 at 15:47
If CDP is enabled you can simply dump the network traffic and listen for broadcasts. In these broadcasts you will see the name, module and port of the cisco switch/router. – Nils Aug 21 '11 at 19:42
@Nils if CDP isnt enabled , so in this case we can enable this protocol from the cisco switch ? , if yes how ( by which cisco command ? ) – Diana Aug 21 '11 at 20:10
@Diana: I am no cisco-admin - but it is propably somewhere in the manual... – Nils Aug 21 '11 at 20:43

You could write a perl script using Net::Telnet::Cisco and Net::OpenSSH to automate this. I'll provide one here if i find some time today.


As asked by the questioner in a comment: If you want to get the informations via SNMP, there is an excelent documentation in the cisco library:

In short: You need to merge the outputs of five snmpwalks (where crumpy is you switchname)

snmpwalk -c public crumpy . # get vlan states
snmpwalk -c public@1 crumpy .     # get mac table
snmpwalk -c public@1 crumpy .     # get the switchport numbers for the vlans (here Vlan1)
snmpwalk -c public@1 crumpy .     # switchport to if number
snmpwalk -c public@1 crumpy .     # get the interface names

From the Docs:

6. Link a MAC address to the port on which the address was learned.

* From Step 1, the MAC address is: = Hex: 00 00 0C 07 AC 08

*  From Step 2, the bridge port tells that the MAC address belongs to bridge port number 13: = 13 

*  From Step 3, the bridge port number 13 has ifIndex number 2: = 2

*  From Step 4, the ifIndex 2 corresponds to port Fast Ethernet 0/1:
      ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.2 = Fa0/1
share|improve this answer
Hi Thomas : I get the error about - snmpwalk -c public crumpy . getaddrinfo: crumpy Temporary failure in name resolution snmpwalk: Unknown host (crumpy) (Resource temporarily unavailable) – Diana Aug 21 '11 at 14:35
crumpy must be replaced by you switch name, sorry, forgotten, updated my post – Thomas Berger Aug 21 '11 at 14:38
Thomas ( I add the alias crumpy with the IP adddress in /etc/hosts ) and I get: snmpwalk -c public crumpy . snmpwalk: No securityName specified – Diana Aug 21 '11 at 14:46
try to add -v 1 to the snmpwalk command. – Thomas Berger Aug 21 '11 at 14:49

OpenNMS does this well through its Linkd feature, automatically discovering links between nodes through SNMP, CDP and via routing information. It also allows you to create topology maps.

The switch's links page looks like this: enter image description here

While the node's links page looks like: enter image description here

Other than that, you're stuck with some version of a show mac address routine on the switch.

share|improve this answer
please explain how you get the GUI screens , from the site installation I see how to install the packages on linux 4 but I have linux - 5 and the tool fit for linux 4 , about your GUI screens - how to create screens topology ? from the DEMO I not see this screens – Diana Sep 1 '11 at 12:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.