[TAG] localhost vanishes after rebooting

mso@oz.net mso
Thu Apr 28 00:16:04 MSD 2005


We're going to have to start another column, "Joydeep's Questions". :)

Joydeep wrote:
> I have just checked  *ping 127.0.0.1* and have found  *network
> unreachable*
>
> *ifconfig -a* shows *lo* entry with out the inet-address. I have
> checked /etc/hosts file and get the line
>
> 127.0.0.1  localhost.localdomain debian
>
> so I did   1) ifconfig lo 127.0.0.1
>       2) route add 127.0.0.1
>
> after executing the second line an error message came as
>
>  SIOCADDRT: No such device
>
> now * ping 127.0.0.1 * again started working but after restarting the
> machine
> my localhost vanished and *ifconfig* gave a blank output. have I done any
> mistake to configure the loopback ? how can I solve the problem ?

I had a similar problem a couple weeks ago when my Gentoo configuration
blew up and wouldn't run the network-up scripts.  I configured eth0
manually but didn't bother with lo.  KDE wouldn't start; it just drew a
blank background screen.  Turns out KDE depends on the loopback.  I did
"ifconfig lo up" but that didn't work, so I had to do "ifconfig lo
127.0.0.1".

In kernel 2.2 you had to set all routes, but in 2.4 and 2.6 it
automatically sets the "interface route"; i.e., the one implied by the IP
and netmask.    The only route you have to set is the default gateway.

In any case, the route you're trying to add is 127.0.0.0, not 127.0.0.1. 
Routing is not about going to an IP that's in your computer, it's about
going to IPs not in your computer.  127.0.0.1 is the gateway to 127.0.0.0;
that is, to all 127.x.x.x addresses.  You can use this, for example, in
testing situations.  Say you've developed three secure web sites and want
to test them all using some command-line too.  You can't use name-based
virtual hosts because HTTPS is incompatible with name-based hosts.  So you
can set them all running as 127.0.0.2:443, 127.0.0.3:443, etc.  Since the
IPs look back to your own machine, your Apache can listen for them as
separate virtual hosts.  You could do the same thing by doubling up IPs on
the same interface; e.g., "ifconfig eth0:0 10.0.0.1", but why do that when
you have 127.x.x.x for free?

-- Mike Orr <mso at oz.net>





More information about the TAG mailing list