[lug] Converting IPs to Domain Names and Vice Versa via Bash

Bill Thoen bthoen at gisnet.com
Wed Jan 26 17:38:42 MST 2005


On Wed, 26 Jan 2005, David Morris wrote:

> If the system isn't too old try the 'host' command and pipe
> the result through awk or sed to extract the information you
> need.  On an older system try nslookup, but there is a lot
> more information to filter out.
> 
> As an example:
> 
>     export IP=`host $1 | awk '{print $4}'`

For grins, I tried this but don't understand the results. Check this out.
One IP resolves to two different domains. Then looking up each of those
domains separately I get different IPs from the one I started with. What's
going on?

# host 65.212.140.3
3.140.212.65.in-addr.arpa domain name pointer fw1.cellularonewest.com.
3.140.212.65.in-addr.arpa domain name pointer fw1.wwirelessintl.com.

# host cellularonewest.com
cellularonewest.com has address 65.212.140.11

# host wwirelessintl.com
wwirelessintl.com has address 12.129.20.143





More information about the LUG mailing list