#!/bin/sh
#
# ident "@(#)bbip.sh 1.2     01/05/29 SMI"
#
# Copyright (c) 2000 by Sun Microsystems, Inc.
# All rights reserved.
#                       

PATH=/bin:/usr/bin

interface=`netstat -i | nawk -v H=$1 '{ if ( H==$4 ) print $1 }'`
if [ "$interface" != "" ]; then
	ipaddr=`netstat -in | nawk -v I=$interface '{ 
			if ( I==$1 ) print $4 
		}'` 
else
	ipaddr="127.0.0.1"
fi

echo $ipaddr 

exit 0
