[svlug] able to ping using IP but not able using hostname

Rick Moen rick at linuxmafia.com
Wed Dec 6 16:46:58 PST 2006


Quoting Prasad Paranjape (prasad_ishan at yahoo.com):

> Hello Gurus,

Hello yourself.  You had:

> In-Reply-To: <20061206232439.GE18077 at linuxmafia.com>

...caused by your posting as a _reply_ to my post, making it appear to
be part of the same thread.  Please, whenever you are starting a
completely new topic, do so using a fresh non-reply posting, rather than
misleadingly "replying" to a different thread.


> 1) Linux Box 1 Is configured to obtain IP address from
> DHCP running on Router.
> 2)Linux Box 2 Is configured to obtain IP address from
> DHCP running on Router.
> 
> The /etc/hosts files on both the machines I have entries for the other
> host with fixed private IP addresses ( Though I am using DHCP to
> obtain IP addresses).

This is part of your problem.  Obviously, the entries are going to end
up being wrong.  Inherently, /etc/hosts is really useful only for IP
address assignments that aren't subject to change.

> Now I am able to connect to Internet from both the hosts as router is
> connected to cable modem.
> 
> I can ping to Box 2 from Box 2 using the IP address of the Box1 but
> not using the hostname and same happens vice versa.
> 
> I know there should be something wrong with names resolving but know
> very little and nothing about it.

OK, here's your problem:  The two hosts' IP addresses are subject to
change, because the router assigns them dynamically.  You want to have
consistently usable names for your hosts.  That goal requires that
either you make the router cease changing the underlying IPs (assign
them statically), or make the router publish DNS information for the two
hosts that automatically follows their changing IP assignments.

So, you're not actually asking a Linux problem; the problem really has
nothing to do with the two Linux boxes.  You need to control in some
fashion what the router is doing, e.g., make it either publish dynamic 
DNS information or keep the two hosts' IP addresses fixed in the future.

There's one exception (workaround):  In theory, you could leave the
router alone, and configure your two Linux hosts to register their
changing IPs with a dynamic DNS daemon that one of them runs -- and have
the two Linux hosts get their name information from there.

Honestly, that workaround would be a whole lot of trouble, especially
when you could make your life a whole lot simpler by just making the
router's IP assignments static (or effectively static).  If your
learning networking, for heaven's sake start with static IPs if humanly
possible.





More information about the Svlug mailing list