[CentOS] 6.x - find interface with link up

Thu Dec 15 22:04:35 UTC 2011
Les Mikesell <lesmikesell at gmail.com>

On Thu, Dec 15, 2011 at 3:39 PM,  <m.roth at 5-cent.us> wrote:

>>>> In earlier versions 'mii-tool' would iterate over interfaces and show
>>>> which have link up.   In 6.x it wants an interface as a parameter.
>>>> What is the appropriate way to find which of some number of of
>>>> interfaces are connected?   Better yet, what is the least typing to
>>>> get the mac addresses of those interfaces?
>>> ethtool, or even lshw.
>> How do you make ethtool iterate over the available interfaces?
> I suppose that would be a script. lshw - which is clearer than just
> dmidecode, would do it.
> Dumb question: in /etc/sysconfig/network-scripts, do the ifcfg-* have

They do, but the case I want to cover is where an existing server is
cloned, or the disk has been moved from a failed chassis to a spare.
And in this case the existing files will be wrong, and the nics will
be named more or less randomly.   Assume the hands-on operators don't
know much about linux and you can't actively help until they get at
least one of the right IP's on the right NIC.

With 5.x I'd use mii-tool to find the connected interface (connecting
one wire at a time if necessary), then ifconfig on that interface to
get the hwaddr, then edit that into the ifcfg-* file for the names I
want the active NICs to have, and reboot.   That's awkward enough to
ask someone to do who already prefers windows, and it looks like it
just got harder by having to explicitly run mii-tool for each possible
interface (and we always have 4 to 6 per box).   There has to be a
better way.   I thought 6.1 was going to have a new NIC name
convention but I haven't had time to look into it and have to make
something work now.

   Les Mikesell
    lesmikesell at gmail.com