Tracking Network Devices

Edit: Still good stuff.

Originally posted November 18, 2014 on AIXchange

Which switch port is your network port plugged into?

Oftentimes this simple bit of information goes undocumented. Perhaps everything is being plugged in at a remote site by some ‘hands and eyes” guys and you’re just not sure if the cabling has been completed or if it’s correct according to the documentation you received. Or maybe you just want more information about the network device that you’re plugging into.

I was reminded of an interesting method for obtaining this information. Before I get into it, keep in mind that this might not work depending on the switch you’re connecting to or its security settings. That said, I’ve had pretty good luck with it so far.

To get this working in my environment, I first needed to see what physical cards I’d connected to the switch. I accomplished this with the lscfg command, which displayed the cards available in my system:

lscfg | grep en

In my test machine I have these ports:

To determine which ports are reporting that they’re up, I ran:

            for i in 0 1 2 3 4 5 6 7

            do

            echo ent$i ; netstat -v ent$i | grep Status

            done

I received this output:

            ent0

            No network device driver information is available.

            ent1

            Physical Port Link Status: Down

            Logical Port Link Status: Down

            DCBX Status: Enabled

            MAC ACL Status: Disabled

            VLAN ACL Status: Disabled

            ent2

            Physical Port Link Status: Up

            Logical Port Link Status: Up

            DCBX Status: Disabled

            MAC ACL Status: Disabled

            VLAN ACL Status: Disabled

            ent3

            Physical Port Link Status: Up

            Logical Port Link Status: Up

            DCBX Status: Disabled

            MAC ACL Status: Disabled

            VLAN ACL Status: Disabled

            ent4

            No network device driver information is available.

            ent5

            Link Status: Down

            Transmit and Receive Flow Control Status: Disabled

            ent6

            Link Status: Down

            Transmit and Receive Flow Control Status: Disabled

            ent7

            Link Status: Down

            Transmit and Receive Flow Control Status: Disabled

This showed me the status of every port. In my case, I know that the ports that report “no network driver information is available” are part of my Shared Ethernet adapters, so that gives me an idea of which adapters are being used by SEA on this VIO server. 

The method that I will now describe will work on network ports that don’t have an SEA on them. Maybe you have your own method to use once your port is already up and active in an SEA? If so, let me know in comments.

In above output, ent2 and ent3 are reporting that they’re up. I put a dummy IP address on them:

ifconfig en2 10.9.0.1 netmask 255.255.255.0

ifconfig en2 up

Then I ran tcpdump:

tcpdump -nn -v -i en2 -s 1500 -c 1 ‘ether[20:2] == 0x2000’

After a short wait, I received this output:

            tcpdump: listening on en2, link-type 1, capture size 1500 bytes

            08:09:13.046930 CDP v2, ttl: 180s, checksum: 692 (unverified)

                        Device-ID (0x01), length: 22 bytes: ‘ucs6120-A(SSI140206FM)’

                        Address (0x02), length: 13 bytes: IPv4 (1) 10.33.0.31

                         Port-ID (0x03), length: 12 bytes: ‘Ethernet1/20’

                         Capability (0x04), length: 4 bytes: (0x00000228): L2 Switch, IGMP snooping

                         Version String (0x05), length: 70 bytes:

                           Cisco Nexus Operating System (NX-OS) Software, Version 5.2(3)N2(2.22c)

                         Platform (0x06), length: 9 bytes: ‘N10-S6100’

                         Native VLAN ID (0x0a), length: 2 bytes: 705

                         AVVID trust bitmap (0x12), length: 1 byte: 0x00

                         AVVID untrusted ports CoS (0x13), length: 1 byte: 0x00

                         Duplex (0x0b), length: 1 byte: full

                         MTU (0x11), length: 4 bytes: 1500 bytes

                         System Name (0x14), length: 9 bytes: ‘ucs6120-A’

                         System Object ID (not decoded) (0x15), length: 14 bytes:

                          0x0000:  060c 2b06 0104 0109 0c03 0103 864f

                         Management Addresses (0x16), length: 13 bytes: IPv4 (1) 10.33.0.31

                         Physical Location (0x17), length: 14 bytes: 0x00/Lab Switch 1

            4 packets received by filter

            0 packets dropped by kernel

 I can do the same thing with en3.

From this I know what kind of switch I’m connected to, what port is it connected to, what OS the switch is running, the VLAN I’m on, the MTU size, the management address of the machine, etc.

Be sure to read the link above for additional information about ether channel and other details.

What other methods do you use to determine which the physical ports your machines are using?