A quick bash script I put together to display a list of configured ethernet interfaces, and some useful information about them.
Known to work in RHEL4/5/6, Fedora and CentOS.
Code:
#!/bin/bash
echo -e "Interface\tMAC Address\t\tIP Address\tSpeed\t\tLink"
for x in `/sbin/ifconfig | grep Link | awk '{print $1}' | sort | egrep -v 'inet6|lo'`
do
MAC=$(/sbin/ifconfig $x | grep "Link" | egrep -v inet6\|lo | awk '{print $5}')
IP=$(/sbin/ifconfig $x | grep "inet addr" | cut -d: -f2 | cut -d' ' -f1)
SPEED=$(/sbin/ethtool $x 2>/dev/null | grep "Speed" | cut -d: -f2 | sed 's/^[ \t]*//')
LINK=$(/sbin/ethtool $x 2>/dev/null | grep "Link detected" | cut -d: -f2 | sed 's/^[ \t]*//')
echo -e $x"\t\t"$MAC"\t"$IP"\t"$SPEED"\t"$LINK
done
echo -e "\n"
exit 0