ZNHOO Whatever you are, be a good one!

127.0.0.1 VS 0.0.0.0

  1. Before a host is reachable, it must has an network interface device to which IP from ISP is assigned. That is to say, network interface undertakes networking functionalities.
  2. On open public netwoks like 'Internet', usually a host is given with a IP with which a hostname is registered/associated. For example, 'google.com' binded to its server IPs.
  3. On some small local networks, network implementation might be narrowed to reduce complexity. So usually on a LAN, you host IP is not registered with your hostname. For example, your personal PC only gets an IP.
  4. A host can be reached by IP from ISP. Meanwhile, every host has a special reserved IP 127.0.0.1/32 (not from ISP) bound to the loopback network interface, which works only within the host itself. So a host never reach any other host (except itself) on the network by 127.0.0.1.

    Actually 127.0.0.0/8 - This block is assigned for use as the Internet host loopback address. A datagram sent by a higher-level protocol to an address anywhere within this block loops back inside the host. This is ordinarily implemented using only 127.0.0.1/32 for loopback. Addresses within the entire 127.0.0.0/8 block do not legitimately appear on any network anywhere.

    The same convention is defined for computer’s that support IPv6 addressing using the connotation of ::1.

    The purpose of the loopback range is testing of the TCP/IP protocol implementation on a host. Since the lower layers are short-circuited, sending to a loopback address allows the higher layers (IP and above) to be effectively tested without the chance of problems at the lower layers manifesting themselves. 127.0.0.1 is the address most commonly used for testing purposes.

  5. We can say 127.0.0.0/8 within the bound of a host forms a tiny network which only includes the host itself. So within this tiny loopback network, the host IP is associated/registered with a loopback hostname 'localhost'.
  6. But usually in system, we are suggested to set another hostname like in Gentoo /etc/conf.d/hostname. As stated in item 3, this value is usually registered with IP from ISP, especially for personal PCs on LAN. Such hostname value is just a local label for the host. If unset, value in /detc/conf.d/hostname is default to 'localhost' such that the hostname is regesitered to the tiny loopback network. Even set, you can still bind it to loopback network by adding '127.0.0.1 hostname' into /etc/hosts.
  7. "0.0.0.0" is a valid address syntax. So it should parse as valid wherever an IP address in traditional dotted-decimal notation is expected. The all-zero value does have a special meaning. So it is "valid", but has a meaning that may not be appropriate (and thus treated as not valid) for particular circumstances. It is basically the "no particular address" placeholder. It depends on the context of use to determine what "no particular address" really does.

    In the context of a route entry, it usually means the default route.

    In the context of servers, 0.0.0.0 means "all IPv4 addresses on the local machine". If a host has two ip addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, it will be reachable at both of those IPs by other hosts. At the same time, server host itself can also reach the service by 127.0.0.0/8.

    The IPV6 form of 0.0.0.0 is ::0 or just ::.

  8. On my Gentoo, I use RDP to connect to local headless VB WinXP. The default headless listening address is 0.0.0.0 which means other host in the networks can reach the headless WinXP too.

    So set it to 127.0.0.1 explicitly.