[Tfug] getting IP's from host names

Bowie J. Poag tfug@tfug.org
Sun Sep 15 07:15:01 2002


What you've ask is a somewhat-loaded question, in that there are several
correct answers.

Oooh boy, here we go......On Unix machines, there is a concept that goes
under several different monickers....its called a "name service switch", a
"dns order" or a "dns chain". Basically, its a statement that tells the
machine how to go about resolving a hostname. Depending on the flavor of
Unix, this is either defined in /etc/resolv.conf, /etc/nsswitch.conf or
/etc/host.conf.... The purpose of this statement is to basically tell the
system "Ok, for all your name resolution needs, go here first and look it
up....If you cant resolve the hostname over there, try using this other
method instead....If that fails as well, try this other method as a last
resort."   ...Mind you this is different from simply declaring multiple
nameservers in /etc/resolv.conf .... A typical "order" statement would read
something like:

hosts bind nis

Mind you, this "order" statement can vary wildly, depending on which flavor
of Unix we're talking about. For example, on another box, it may look like
the following:

hosts=bind,local,yp
aliases=local,bind,yp


....This tells your system that for normal hosts, go ahead and hit up DNS
first, then look around in /etc/hosts, then try NIS (yp is deprecated. It
stands for "yellow pages", the old name Sun used to give what we now know as
NIS.)... Anyway, for local aliases, however, look up any domains in
/etc/hosts first, then hit up the nameservers defined in /etc/resolv.conf,
then as a last resort, try to resolve a hostname via NIS.

Now, if _all of that_ fails, you're still not screwed, because Unix is
beautiful, and sacred. You must bow down to the righteous and holy authority
that is Unix. Repent! Sit down on a Unix manual and let the lord come into
you.  Drop to your knees, sinner! Drop to your knees and realize there is no
such thing as "cant do that" in Unix! Then give me a "love gift" of $50, and
the invisible spook you happen worship will "love" you more.

See, i'm poor, and the advice i'm about to give you would normally cost you
twice that if it came from a consultant, ya bastard. Gimmie money. Now.
Gimmie dat money. Bastard. Being unemployed Unix guy in Tucson is a
redundant statement. Anyway, here's the last ditch way to resolve hostnames
on a local network:

If you're using a dedicated DHCP server of some sort, you can utilize that
box for your local DNS.  A nice little feature of DHCP is that it allows for
machines to pass an optional hostname argument when they request a new DHCP
lease. So, if all of your machines get their IP's via DHCP, and all of your
machines have supplied the DHCP server with this optional hostname argument,
the DHCP server effectively doubles a last-ditch DNS for local machines on
your network.

Now gimmie your freakin money.

Cheers,
Bowie



----- Original Message -----
From: "Paul Scott" <waterhorse@ultrasw.com>
To: <tfug@tfug.org>
Sent: Sunday, September 15, 2002 2:25 AM
Subject: [Tfug] getting IP's from host names


> I have a lot of stuff to read but am not finding the answer to a simple
> question:  How do I get the IP's of my local machines from their
hostnames?
>
> I have bind and dig installed.  Could there be something I haven't
> configured.  Each machine has its own name in its own /etc/hosts.
>
>
> joy:/home/paul# dig janet
>
> ; <<>> DiG 9.2.1 <<>> janet
> ;; global options:  printcmd
> ;; Got answer:
> ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 33986
> ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
>
> ;; QUESTION SECTION:
> ;janet.                         IN      A
>
> ;; AUTHORITY SECTION:
> .                       2220    IN      SOA     A.ROOT-SERVERS.NET.
> NSTLD.VERISIGN-GRS.COM. 2002091401 1800 900 604800 86400
>
> ;; Query time: 104 msec
> ;; SERVER: 209.203.92.100#53(209.203.92.100)
> ;; WHEN: Sun Sep 15 02:21:31 2002
> ;; MSG SIZE  rcvd: 98
>
>
>
> TIA,
>
> Paul Scott
>
> _______________________________________________
> tfug mailing list
> tfug@tfug.org
> http://www.tfug.org/mailman/listinfo/tfug