[ To find network info ]
netstat -ni -w | grep -v '^lo' | sed -n '2,$ p' | awk '{ print $1, $4 }' | while read DEV_NAME DEV_ADDR
do
DEV_NAME_CUT=`echo ${DEV_NAME} | tr -d '*' | cut -d: -f1`
DEV_MAC=`lanscan | grep -w "${DEV_NAME_CUT}" | awk \
'{for(i=3;i<14;i=i+2) {
m=substr($2,i,2);
MAC=MAC":"m;
}
print MAC;
}' | sed -e 's/^://'`
...
printf "%s %s %s\n" "${DEV_NAME}" "${DEV_MAC}" "${DEV_ADDR}"
done
nwmgr | grep '^lan' | awk '$2=="UP" && $6!="" { print $1, $3, $6 }' | while read DEV_NAME DEV_MAC DEV_REL
do
DEV_MAC=`echo ${DEV_MAC} | awk '{for(i=3;i<14;i=i+2) { m=substr($1,i,2); MAC=MAC":"m; }; print MAC; }' | sed -e 's/^://'`
# if it is a related interface
printf "%s %s %s\n" "${DEV_NAME}" "${DEV_MAC}" "(Related=${DEV_REL})"
done
;;
No comments:
Post a Comment