Host name and internet id

Jonathan I. Kamens jik at athena.mit.edu
Wed Apr 3 23:29:38 AEST 1991


In article <3131 at beguine.UUCP>, Brian.Chan at samba.acs.unc.edu (Brian Chan) writes:
|> how do you find out the host numeric addess (eg 128.x.x.x) if you only
|> know its name like foo.bar.edu? 

  I'm assuming that you're using a machine that uses Internet name service to
resolve hostnames, rather than a large /etc/hosts table.  If your site uses
/etc/hosts, then go find your site admin, shoot him, and then replace him with
a site admin who will upgrade your software so that it uses Internet name
server (that's a joke, OK? :-).

  You can use the bindtest, nslookup or dig utilities to find out an Internet
address given a host name.  All of those utilities have sources floating
around the net; if you can't find them and want to, let me know and I'll see
what I can dig up.

  Alternatively, if you're not interested in the complexity of those
utilities, you can just write a short C program to call gethostbyname() on the
string you pass it, and then print out the address in the data that is
returned using inet_ntoa.

  In fact, we've got a utility here to do that.  I've shar'd the source file
and the man page together into a shar file and put it in
/pub/tmp/hostinfo.shar on pit-manager.mit.edu (18.72.1.58).  It's also
retrievable via E-mail by sending a message to
"mail-server at pit-manager.mit.edu" with "send tmp/hostinfo.shar" in the subject
or body of the message.  It'll only stay there for a week, though, so make
sure to grab it.  

  A couple notes: First of all, you should know that a site can have more than
one IP address.  The hostinfo program I mentioned above deals with that
properly.  Second, you should know that a host that looks like an internet
site can have no IP addresses at all.  Most of those are Mail eXchange, or MX,
addresses, which means that when mailers ask the name servers, "How do I send
mail to this host?" the name server responds with, "You send the mail to this
other host instead, and it'll take care of final delivery of the mail."

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list