Operating System - Linux
1829700 Members
2091 Online
109992 Solutions
New Discussion

Re: I need to how to find IP address

 
girishb
Frequent Advisor

I need to how to find IP address

Hi there,

I have a list of 100 hostnames and I need to find out ip addresses of each.

How do I get it fast?

Its a pain to use ping on each host to find out ip address.

Can I have a script to do it or or any other suggestion.

Please help its urgent !!

Thanks
Girish
3 REPLIES 3
Ivan Ferreira
Honored Contributor

Re: I need to how to find IP address

If your name resolution works fine, you can use a script like this:

for IP in `seq 254`; do
ping -c 1 192.168.1.$IP
host 192.168.1.$IP
done

Or something like this:

for HOST in ` awk '{ print $2 }' /etc/hosts` ; do
ping -c 1 $HOST
done
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Alexander Chuzhoy
Honored Contributor

Re: I need to how to find IP address

Sure, it can be done with script.
How does the list look like - the script will have to parse it,so...


P.S.
You also have 100% of unassigned points.
girishb
Frequent Advisor

Re: I need to how to find IP address

Found the solution