tigbit

Website design and hosting with email accounts.

retrieve ip address and hostname information
Monday, 17 May 2010 17:10

 

 

#!      /bin/bash

IpList=`ifconfig -a | grep "inet addr:" | grep -v "127.0.0.1" | awk '{print $2}' | awk -F: '{print $2}'`

for ip in $IpList
do
hostname=`nslookup $ip | grep "name =" | awk '{print $4}'`
actualHostname=`hostname`
echo "HOSTNAME $actualHostname LOOKUP $hostname IPADDRESS $ip "
done