gethost
Current version: 0.03Updated: 05/Jul/2002
gethost uses local libraries to lookup a hostname or IP address (for reverse lookups). It is useful for troubleshooting, because by using gethostbyname(3) and gethostbyaddr(3) it can check what your system really sees instead of relying on some nameserver's opinion. It can do IPv6.
For example, depending on your OS and setup (like nsswitch) it could check /etc/hosts (and/or maybe NIS).
It can also show the elapsed time (using -t switch) of the gethostbyname(3) call.
Read the manual page gethost(1) (in HTML).
Some examples of the output:
$ gethost 3ffe:8050:201:1860:290:27ff:feab:19a7 -x 127.0.0.1 -t -6 localhost Hostname: www6.netbsd.org Address: 3ffe:8050:201:1860:290:27ff:feab:19a7 Hostname: localhost Address: 127.0.0.1 Hostname: localhost Address: ::1 gethostbyname2() took 0.000 seconds $ ./gethost www.microsoft.com Hostname: www.microsoft.akadns.net Alias: www.microsoft.com Address: 207.46.197.102 Address: 207.46.197.100 Address: 207.46.230.219 Address: 207.46.230.220 Address: 207.46.230.218 $ ./gethost -x 17.254.0.91 Hostname: www.apple.com Address: 17.254.0.91 $ ./gethost -t -x 127.0.0.1 Hostname: localhost Address: 127.0.0.1 gethostbyaddr() took 0.001 seconds $ ./gethost -t kids Hostname: kids Address: 192.168.0.4 gethostbyname() took 0.002 secondsYou can use gethost to see if an IP or hostname resolves:
$ ./gethost bogus > /dev/null 2>&1 || echo 'no good' no good
To Do
- add quiet switch
- use getopt or similar, so -xt works
- add option to output in BIND's master file format.
Current version download:
gethost-0.03.tar.gz (05/Jul/2002)
Previous version download:
gethost-0.02.tgz (12/Apr/2002)
If you have any ideas, please email. Also, please share your feedback: Is it useful?