127.0.0.1 localhost and the difference between the native IP and three!

1,

First is the next time to send the address (Loopback Address):

The loopback address is a special address used to send a host (i.e. a particular destination address) of the communication itself.
It can be said: both services on the same host if the loopback address instead of using the assigned host address, you can bypass the underlying TCP / IP protocol stack. (In other words: no longer do anything link layer, physical layer, Ethernet spread out, but can be processed directly in their network layer, the transport layer)

IPv4 loopback address is: 127.0.0.0 to 127.255.255.255 are loopback address (only two special reserved), any address in this address will not appear in the network
address of the network number 127 is simply not a network addresses (because IP datagram is generated does not reach the external network interface, the packet is not to leave the host)

When the operating system initialization native TCP / IP protocol stack, the protocol stack provided own IP address is 127.0.0.1 (reserved addresses), and injected into the routing table. When receiving the IP layer destination address is 127.0.0.1 (to be exact: the IP network number of 127) when a packet, the network card driver does not call for the second package, but is immediately forwarded to the local IP layer processing, because it does not involve the underlying operations. Accordingly, ping 127.0.0.1 to test the machine as a general TCP / IP protocol stack, whether or not one of the normal judgment.

So: 127.0.0.1 is reserved one address, but is often used to test the native TCP / IP protocol stack it, we can Ping loopback address. Usually if the loopback address Ping barrier, it shows IP stack out of trouble. If you pass, it shows that the Internet is a problem.

2,

localhost First, a domain name (like: www.baidu.com), but also the local addresses, which can be configured to any IP address (that is, can be changed by the hosts of this document), but usually point :( follows)
IPv4: 127.0.0.1 represents

IPv6: express [:: 1]

* 127. The entire network is often used as a default address of the loopback network interface by convention is usually set to 127.0.0.1. We present this address on the host computer, others can not access, even if access is also access their own. Because each TCP / IP protocol stack apparatus basically local / 127.0.0.1

In Windows, this domain are predefined, from C: \ Windows \ System32 \ drivers \ etc \ hosts file can be seen:

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost    ( ipv4)
# ::1            localhost     (ipv6)

In Linux, the definition is located in / etc / hosts in:
127.0.0.1 localhost
Note that this value is modifiable, for example, I changed it to
192.168.2.1 localhost
then go ping localhost, suggesting it becomes a
PING localhost ( 192.168.2.1) 56 (84) bytes of data.

127.0.0.1 The address is usually assigned to the loopback interface. is a special loopback network interface (NIC understood as virtual) for network interaction between the respective native application. As long as the operating system of the network components is normal, loopback will be able to work. Windows can not see this interface, Linux in this interface called lo:

#ifconfig

eth0    Link encap:Ethernet hwaddr 00:00:00:00:00:00          

           inet addr :192.168.0.1 Bcase:192.168.0.255 Mask:255.255.255.0  

           ......

lo        Link encap:Local Loopback        

           inetaddr: 127.0.0.1 Mask: 255.0.0.0        

           ......

Lo it can be seen that the interface address 127.0.0.1. In fact the whole 127. * network are considered able to use, for example, you ping 127.0.0.2 also pass. However, using the default address 127.0.0.1 loopback interface as just a convention, such as the following:

#ifconfig lo 192.168.1.1

#ping localhost # ping nowhere

#ping 192.128.1.1 # can pass

3,

The local IP, we can understand that there are three native card, a card called the loopback (virtual LAN), a known ethernet (wired LAN), one is called wlan (your wireless network card),

Connect to the network, transmission network card, network card and by a firewall restrictions

And external access to the present

Published 161 original articles · won praise 39 · views 360 000 +

Guess you like

Origin blog.csdn.net/hknaruto/article/details/103591610