Subject: Command-line utility for gethostbyname(3)?
To: None <netbsd-users@netbsd.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: netbsd-users
Date: 04/20/2001 11:24:47
Is there a command to resolve a hostname (from /etc/hosts) to an IP?

My /etc/hosts has:
192.168.0.2     rainier

My /etc/resolv.conf doesn't have any "search" order.

My /etc/nsswitch.conf has:
hosts:          files dns

rainier:~$ host rainier
Host not found.
rainier:~$ nslookup rainier
Server:  pilchuck
Address:  192.168.0.1

*** pilchuck can't find rainier: Non-existent host/domain

(And dig just returns a root server.)

It does resolve though:

$ telnet rainier daytime
Trying 192.168.0.2...
Connected to rainier.
Escape character is '^]'.
Fri Apr 20 11:22:10 2001
Connection closed by foreign host.

Is there any command-line utility that is simply an interface to
gethostbyname(3)? (I tried using apropos to find something.)

If not, does this seem like a good option for host(1)?

   Jeremy C. Reed
   http://www.reedmedia.net/