How to use a simple script to resolve a list of FQDNs to IPs

If you have a list of Fully Qualified Domain Names (FQDN), and you dont want to resolve 1 by one, you can use this simple bash script to do it for you:

#!/bin/sh
# A script for any sh-like shell (bash, ksh, zsh)
NAMES=namelist.txt ADDYS=iplist.txt
for i in `cat $NAMES` do host $i | awk ‘{print $1, $4}’
done > $ADDYS

Thats it 🙂

You may also like