Skip to content

Getting IP addresses for remote nodes

2010 July 29
by Eddie

I recently had the need to get the ip address for a remote node. Wait, scratch that.. I had to get the IP addresses for about 60 remote nodes.

You’re right… I probably could have typed

nslookup targetNode

60 times. But I am a programmer! SO I decided to pass my choir off to a shell script.

If you have a similar need, read on!

The script is simple, just add all target nodes as a space separated list, and run the file.

# author: Edward A Webb (
# license: Just use it! its like 10 lines of shell script...
# add your actual nodes here.....
nodes=( gonzo fenway einstein yogurt toxic babmbi rambo donna INXS etc... )
ips=( ) # placeholder for results
printf "\t Determing IP addresses for provided nodes \n ignore these lines...\n"
for (( i = 0 ; i < ${#nodes[@]} ; i++ ))
	str=$(nslookup ${nodes[$i]} | tail --lines=2 | head --lines=1)
	ips[$i]=$(echo $str | cut -f 2 -d " ")
printf "\t COMPLETE\n Here are the results you care about..\n"
for (( i = 0 ; i < ${#ips[@]} ; i++ ))
	echo address for ${nodes[$i]} is ${ips[$i]} | tee -a ip_results.txt
3 Responses leave one →
  1. July 29, 2010

    Whoa, impressive!

  2. July 20, 2011

    Grade A stuff. I’m unquestinoalby in your debt.

  3. Eddie permalink*
    July 21, 2011

    Thanks @Pait. Just keep software open and robust and I’ll consider it even 😉

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS