/usr/sbin/ifconfig -a | grep "inet" | grep -v "inet6" | grep -v "127.0.0.1" |
grep -v "0.0.0.0"|grep -v "192.168.100.2" | awk '{print $2}'
I use above command to get IP addresses on AIX boxes.Values coming here are set to a variable "Host IPs.IP Addresses" in my fingerprinting engine.
Next,i am trying to get interface names associated with these IPs.
So i write
for INTERFACE in `/usr/sbin/ifconfig -a | nawk '$1 ~ /:$/ && $1 !~ /^lo/ {sub(":$", "", $1); print $1}'`
do
val=`/usr/sbin/ifconfig $INTERFACE | grep "@@Host IPs.IP Addresses@@"`
if [ ! -z $val ]
then
echo $INTERFACE
fi
done
Issue:
I have some boxes where i can see duplicate IP addresses ,exactly same.These redundant IPs are causing trouble to above 'for' loop.When my CSV is generated ,i see following rows
<HOSTNAME> <IP> <NETMASK> <DNS> 2010-01-12 en0et0
<HOSTNAME> <IP> <NETMASK> <DNS> 2010-01-12 en0et0
As you can see ,last column is for interface name.
Since 'en0' and 'et0' are two diffrent interfaces but associated with same IP,above loop is faling.
Kindly advice.
Regards
Abhi