epcim
10/20/2015 - 1:41 PM

ifconfig-info.howto.md.sh

ifconfig-info.howto.md.sh

#!/bin/sh

DEV=$1

#reset

IP=""
GW=""
MASK=""
BCAST=""
HWADR=""

IP=`ifconfig $DEV | grep 'inet addr' | awk -F\  '{ print $2 }' | sed -e 's/.*:\(\)/\1/'`
MASK=`ifconfig $DEV | grep 'inet addr' | awk -F\  '{ print $4 }' | sed -e 's/.*:\(\)/\1/'`
GW=`route -n | grep 'UG'| /bin/grep $DEV | awk -F\  '{ print $2 }'`

# warn: walid only for wlan and eth not ppp
BCAST=`ifconfig $DEV | grep 'inet addr'  | awk -F\  '{ print $3 }' | sed -e 's/.*:\(\)/\1/'`
HWADR=`ifconfig $DEV | grep encap  | awk -F\  '{ print $5 }'`

# DEBUG
echo if : $DEV
echo ip : $IP
echo gw : $GW
echo ma : $MASK
echo bc : $BCAST
echo hw : $HWADR