24 November 2010

Host Info - Network Interfaces

As part of the 'host info' series, we're on to network interfaces.
I know, can't be too hard, run 'ifconfig'.  That's fine if you want IP
(layer 3) related information, but what about layer 2 details?  To get
link status, associated interface speed, duplex, and VLAN tagging
(802.1q trunking) information, following comes into play.  Like before,
the details of our hosts are:
        HOSTS:          snorkle (sunhost), tux (linhost), beastie (bsdhost)
        PROMPT:         host [0]
        Solaris INFO:   Solaris 10, x86
        Linux INFO:     CentOS 5.4, x86
        FreeBSD INFO:   FreeBSD 8.1, x86
Solaris can be a curious thing to the uninitiated.  Similar to attached
disks
, Solaris needs to be told to show you a network interface.
Why do you care?  If you were to run 'ifconfig -a' on a Solaris box, only
interfaces which have been plumbed will be displayed, as opposed to Linux
and FreeBSD where all interfaces are displayed.  As such, the following
commands might display more interfaces than 'ifconfig'.  So in Solaris:

    For Solaris versions 10 and newer we can get all but the VLAN
    information from 'dladm show-dev':
        snorkle [0] /usr/sbin/dladm show-dev -p
        e1000g0 link=up speed=1000 duplex=full
        e1000g1 link=up speed=1000 duplex=full
        e1000g2 link=unknown speed=0 duplex=half
    For VLAN information and the supporting network interfaces, use
    'dladm show-link':
        snorkle [0] /usr/sbin/dladm show-link -p
        e1000g0 type=non-vlan mtu=1500 device=e1000g0
        e1000g876000 type=vlan 876 mtu=1500 device=e1000g0
        e1000g1 type=non-vlan mtu=1500 device=e1000g1
        e1000g2 type=non-vlan mtu=1500 device=e1000g2
    Unfortunately, for Solaris versions prior to 10, we have to sift
    through the output of 'prtconf' (-D lists the drivers loaded to
    manage the various attached devices, including network interfaces):
        sunhost [0] /usr/sbin/prtconf -D
        System Configuration:  Sun Microsystems  sun4u
        Memory size: 4096 Megabytes
        System Peripherals (Software Nodes):

        SUNW,Sun-Blade-1500-S (driver name: rootnex)
            scsi_vhci, instance #0 (driver name: scsi_vhci)
            packages
                SUNW,builtin-drivers
                deblocker
                disk-label
                terminal-emulator
                dropins
        <snip...>
                pci, instance #1 (driver name: pci_pci)
                    pci108e,1000
                    SUNW,qfe, instance #0 (driver name: qfe)
                    pci108e,1000
                    SUNW,qfe, instance #1 (driver name: qfe)
                    pci108e,1000
                    SUNW,qfe, instance #2 (driver name: qfe)
                    pci108e,1000
                    SUNW,qfe, instance #3 (driver name: qfe)
            ppm, instance #0 (driver name: jbusppm)
            pci, instance #1 (driver name: pcisch)
                network, instance #0 (driver name: bge)
        <snip...>
    In the above, there are 4 qfe interfaces and 1 bge.  It's off to
    'ndd' to get all but the VLAN informatin.  (On 'sunhost', only the
    'bge' interface has been plumbed, thus only it will show in 'ifconfig
    -a' output.)  For the 'qfe' interfaces, each is a pseudo interface
    managed by the 'qfe' driver.  To query one of them, we need to tell
    'ndd' which pseudo interface to examine.  This interface (qfe1)
    has no link (0 = disabled, 1 = enabled):
        sunhost [0] /usr/sbin/ndd -set /dev/qfe instance 1
        sunhost [0] /usr/sbin/ndd -get /dev/qfe link_status
        0
    Whereas 'bge0' is currently connected:
        sunhost [0] /usr/sbin/ndd -get /dev/bge0 link_status
        1
    Each interface type may support different features.  The following
    is how to get a list of them for a 'qfe' interface with 'ndd':
        sunhost [0] /usr/sbin/ndd -get /dev/qfe \?
        ?                             (read only)
        transceiver_inuse             (read only)
        link_status                   (read only)
        link_speed                    (read only)
        link_mode                     (read only)
        ipg1                          (read and write)
        ipg2                          (read and write)
        use_int_xcvr                  (read and write)
        pace_size                     (read and write)
        adv_autoneg_cap               (read and write)
        adv_100T4_cap                 (read and write)
        <snip...>
    To get the link speed:
        sunhost [0] /usr/sbin/ndd -get /dev/bge0 link_speed
        1000
    To get the duplex, some network adapters use 'link_mode' while others
    use 'link_duplex'.  Additionally, there are differences in the output
    depending on the adapter.  The following details several interface
    types and the decode of the related output:
        link_mode: qfe, hme, ge, fjgi:

                1       FDX
                0       HDX
                *       Error

        link_mode: dmfe; link_duplex: ce, bge, ipge, e1000g, nxge:

                2       FDX
                1       HDX
                0       Unknown
                *       Error
    Unfortunately, in previous Solaris releases, there isn't a command
    to decode which underlying interface supports a logically configured,
    VLAN tagged interface.  (VLAN tagged interfaces, if they exist, will
    be listed in 'ifconfig -a' output.)  Using 'e1000g876000' from the
    'dladm' output, the naming convention breaks down to:
        driver-name + VLAN_ID * 1000 + device-instance
    Which gives us:
    
        e1000g + 876 * 1000 + 0 = e1000g876000
    
In Linux:
   
    Linux provides 'ethtool' to get all but the VLAN informatin.
    'ethtool', however, only works on one interface at a time, so to get
    a list of configured interfaces to pass to 'ethtool', use 'ifconfig'
        tux [0] /sbin/ifconfig -a | /bin/awk '/^[a-zA-Z]/ { print $1 }'
        eth0
        eth0.876
        eth1
        lo
    A listing of the network interface driver information for eth1:
        tux [0] /sbin/ethtool -i eth1
        driver: pcnet32
        version: 1.32
        firmware-version:
        bus-info: 0000:00:08.0
    Listing the details of the interface, including the speed, duplex,
    and link status:
        tux [0] /sbin/ethtool eth1
        Settings for eth1:
                Supported ports: [ TP MII ] 
                Supported link modes:   10baseT/Half 10baseT/Full
                                        100baseT/Half 100baseT/Full
                Supports auto-negotiation: Yes
                Advertised link modes:  10baseT/Half 10baseT/Full
                                        100baseT/Half 100baseT/Full
                Advertised auto-negotiation: Yes 
                Speed: 100Mb/s
                Duplex: Full
                Port: MII
                PHYAD: 0
                Transceiver: internal
                Auto-negotiation: on
                Current message level: 0x00000007 (7)
                Link detected: yes
    Check out '/proc/net/vlan/config' for information detailing VLAN
    tagged interface, correlative VLAN ID, and the supporting network
    interface:
        tux [0] /bin/cat /proc/net/vlan/config 
        VLAN Dev name    | VLAN ID
        Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
        eth0.876       | 876  | eth0
In FreeBSD:

    Simply running 'ifconfig -a' provides all the information we need
    in FreeBSD:
        beastie [0] /sbin/ifconfig -a
        em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
                options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
                ether 08:00:27:ce:11:c0
                media: Ethernet autoselect (1000baseT <full-duplex>)
                status: active
        em1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
                options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
                ether 08:00:27:d2:4e:8b
                inet 10.72.38.35 netmask 0xffffff00 broadcast 10.72.38.255
                media: Ethernet autoselect (1000baseT <full-duplex>)
                status: active
        lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
                options=3<RXCSUM,TXCSUM>
                inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
                inet6 ::1 prefixlen 128
                inet 127.0.0.1 netmask 0xff000000
                nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
        vlan876: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
                options=3<RXCSUM,TXCSUM>
                ether 08:00:27:ce:11:c0
                inet 7.7.6.191 netmask 0xffffff00 broadcast 7.7.6.255
                media: Ethernet autoselect (1000baseT <full-duplex>)
                status: active
                vlan: 876 parent interface: em0
Next at bat, boot parameters of a running host.