Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Re: "Password on localhost" [C&C, y'r welcome, Josh]



Scott Robbins writes:

 > localhost means the computer you are physically in front of, and
 > using at the moment.

Right.  The reason is a little complex.  As the OP is probably aware,
the Internet does not transmit data continuously like the telephone or
television, but instead cuts it into packets, and then ships each
packet independently.

So when you send a message (eg, to request a web page) to another
system, first the OS bundles it into a packet.  Then it puts it in a
"buffer", which is just a place (region of memory) to hold the packet
data until the system is ready to send it.  When it's time to send,
the system takes it from the buffer, outputs it to a network
interface, which sends it "over-the-wire" to be received by another
system's interface.  There it is input to a buffer where it waits
until the program (in the example, web server) to handle it is ready.

Now, it turns out to be very useful to have a *loopback* interface.
In this case, there is no wire, and in fact not even a hardware
interface: you just move the packet from the send buffer to the
receive buffer on the same machine!  Since there is no other machine
involved, the loopback interface can have the same address on every
machine without confusion, and that address is 127.0.01.  It is
conventional to give that address the name "localhost", again without
confusion.  (There's no confusion for precisely the same reason that
"I" is unambiguous to the person who says it.)

What this means is that any program that can be used across the
Internet can also be used on the same host *in exactly the same way*,
even without a network card!  This is useful for all kinds of testing,
obviously, but also for many other purposes.  Eg, "pydoc" is a program
that displays documentation for the Python programming language in an
ordinary web browser.  You can run it on a LAN, or across the Internet
even, but it's just as useful on a disconnected host.

Not only is true that on the Internet you can't know that the other
end of the connection is a dog -- you may not even know that that dog
is you, too!

[There's more, Joshbert, so don't pick up yer mug 'o Java quite yet.]

 > localhost is the name that the operating system gives the machine that
 > is running the system.

Actually, that's a little imprecise.  First, it's not the "machine",
it's a network interface.  Second, it can be anything you like, or
nothing at all.  Conventionally it is "localhost", and you'll find it
in scripts and the like.  So it's convenient to follow convention.

 > So, if you look at your /etc/hosts file you'll see something like
 > 127.0.0.1

You'll see exactly that, and these possibly something like ::1 which
is the same thing in the IPv6 domain.  These are defined in the
Internet RFCs.

 > and the name you gave your machine

If your machine is on the Internet (and that name is know on the
Internet), you probably shouldn't see that associated with the
loopback address.  The reason is that it is generally a good idea to
have a 1-1 correspondence between IP addresses and A names.

 > Most have us have been at that, I don't understand anything stage once
 > in awhile. 

Yeah.  Even after 20 years in this community, I can still read posts
by Stallman and his acolytes and realize that at least one end of the
channel (possibly both) has no clue about anything!  Just happened
again today....

[OK, *now* you can indulge your caffeine jones, Josh!]



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links