Switchport information


#1

If you want to know on which port your server is connected, you can use following commands.

lldpctl is based on and validated with cisco CDP (Cisco Discovery Protocol)
lldpctl


LLDP neighbors:


Interface: eth0, via: CDPv2, RID: 3, Time: 64 days, 03:09:46
Chassis:
ChassisID: local 123123132
SysName: 123123132
SysDescr: cisco WS-C6506 running on
Cisco Internetwork Operating System Software
IOS ™ s3223_rp Software (s3223_rp-ENTSERVICESK9_WAN-M), Version 12.2(18)SXF17a, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright © 1986-2010 by cisco Systems, Inc.
Compiled Mon 01-Mar-10 20:55 by tinhuang
TTL: 180
MgmtIP: 192.168.0.1
Capability: Bridge, on
Capability: Router, on
Port:
PortID: ifname GigabitEthernet2/1
PortDescr: GigabitEthernet2/1
VLAN: 111, pvid: yes VLAN #111


Interface: eth1, via: LLDP, RID: 2, Time: 64 days, 03:09:56
Chassis:
ChassisID: mac 67:be:db:c8:51:81
SysName: 123123132
SysDescr: Cisco IOS Software, C2960S Software (C2960S-UNIVERSALK9-M), Version 12.2(53)SE2, RELEASE SOFTWARE (fc3)
Technical Support: http://www.cisco.com/techsupport
Copyright © 1986-2010 by Cisco Systems, Inc.
Compiled Wed 21-Apr-10 06:08 by prod_rel_team
TTL: 120
MgmtIP: 172.12.12.1
Capability: Bridge, on
Capability: Router, off
Port:
PortID: ifname Gi0/5
PortDescr: GigabitEthernet0/5


Or you can check this also with tcpdump which should work for all type of hardware switches:

tcpdump -nn -v -i eth0 -s 1500 -c 1 ‘ether[20:2] == 0x2000’
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 1500 bytes
13:59:12.961511 CDPv2, ttl: 180s, checksum: 692 (unverified), length 477
Device-ID (0x01), length: 34 bytes: ‘123123132’
Version String (0x05), length: 291 bytes:
Cisco Internetwork Operating System Software
IOS ™ s3223_rp Software (s3223_rp-ENTSERVICESK9_WAN-M), Version 12.2(18)SXF17a, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright © 1986-2010 by cisco Systems, Inc.
Compiled Mon 01-Mar-10 20:55 by tinhuang
Platform (0x06), length: 14 bytes: ‘cisco WS-C6506’
Address (0x02), length: 13 bytes: IPv4 (1) 192.168.255.42
Port-ID (0x03), length: 18 bytes: ‘GigabitEthernet1/5’
Capability (0x04), length: 4 bytes: (0x00000009): Router, L2 Switch
Prefixes (0x07), length: 30 bytes: IPv4 Prefixes (6): 127.0.0.0/8 192.168.255.32/28
VTP Management Domain (0x09), length: 0 byte: ‘’
1 packets captured
1 packets received by filter
0 packets dropped by kernel