Localhost

Last updated

In computer networking, localhost is a hostname that refers to the current computer used to access it. The name localhost is reserved for loopback purposes. [1] It is used to access the network services that are running on the host via the loopback network interface. Using the loopback interface bypasses any local network interface hardware.

Contents

Loopback

The local loopback mechanism may be used to run a network service on a host without requiring a physical network interface, or without making the service accessible from the networks the computer may be connected to. For example, a locally installed website may be accessed from a Web browser by the URL http://localhost to display its home page.

IPv4 network standards reserve the entire address block 127.0.0.0/8 (more than 16 million addresses) for loopback purposes. [2] That means any packet sent to any of those addresses is looped back. The address 127.0.0.1 is the standard address for IPv4 loopback traffic; the rest are not supported by all operating systems. However, they can be used to set up multiple server applications on the host, all listening on the same port number. In the IPv6 addressing architecture [3] there is only a single address assigned for loopback: ::1. The standard precludes the assignment of that address to any physical interface, as well as its use as the source or destination address in any packet sent to remote hosts.

Name resolution

The name localhost normally resolves to the IPv4 loopback address 127.0.0.1, and to the IPv6 loopback address ::1.

This resolution is normally configured by the following lines in the operating system's hosts file:

127.0.0.1    localhost ::1          localhost 

The name may also be resolved by Domain Name System (DNS) servers, but there are special considerations [1] governing the use of this name:

In addition to the mapping of localhost to the loopback addresses (127.0.0.1 and ::1), localhost may also be mapped to other IPv4 (loopback) addresses and it is also possible to assign other, or additional, names to any loopback address. The mapping of localhost to addresses other than the designated loopback address range in the hosts file or in DNS is not guaranteed to have the desired effect, as applications may map the name internally.

In the Domain Name System, the name .localhost is reserved as a top-level domain name, originally set aside to avoid confusion with the hostnamelocalhost. [4] Domain name registrars are precluded from delegating domain names in the top-level .localhost domain. [1]

Historical notes

In 1981, the block 127.0.0.0/8 got a 'reserved' status, [5] as not to assign it as a general purpose class A IP network. This block was officially assigned for loopback purposes in 1986. [6] Its purpose as a Special Use IPv4 Address block was confirmed in 1994, [7] , 2002 [8] , 2010, [9] , and last in 2013. [2]

From the outset, in 1995, the single IPv6 loopback address ::1 was defined. [10] Its purpose and definition was unchanged in 1998, [11] , 2003, [12] , and up to the current definition, in 2006. [3]

Packet processing

The processing of any packet sent to a loopback address, is implemented in the link layer of the TCP/IP stack. Such packets are never passed to any network interface controller (NIC) or hardware device driver and must not appear outside of a computing system, or be routed by any router. This permits software testing and local services, even in the absence of any hardware network interfaces.

Looped-back packets are distinguished from any other packets traversing the TCP/IP stack only by the special IP address they were addressed to. Thus, the services that ultimately receive them respond according to the specified destination. For example, an HTTP service could route packets addressed to 127.0.0.99:80 and 127.0.0.100:80 to different Web servers, or to a single server that returns different web pages. To simplify such testing, the hosts file may be configured to provide appropriate names for each address.

Packets received on a non-loopback interface with a loopback source or destination address must be dropped. Such packets are sometimes referred to as Martian packets. [13] As with any other bogus packets, they may be malicious and any problems they might cause can be avoided by applying bogon filtering.

Special cases

The releases of the MySQL database differentiate between the use of the hostname localhost and the use of the addresses 127.0.0.1 and ::1. [14] When using localhost as the destination in a client connector interface of an application, the MySQL application programming interface connects to the database using a Unix domain socket, while a TCP connection via the loopback interface requires the direct use of the explicit address.

One notable exception to the use of the 127.0.0.0/8 addresses is their use in Multiprotocol Label Switching (MPLS) traceroute error detection, in which their property of not being routable provides a convenient means to avoid delivery of faulty packets to end users.

See also

Related Research Articles

An Internet Protocol address is a numerical label such as 192.0.2.1 that is assigned to a device connected to a computer network that uses the Internet Protocol for communication. IP addresses serve two main functions: network interface identification, and location addressing.

<span class="mw-page-title-main">Internet Protocol version 4</span> Fourth version of the Internet Protocol

Internet Protocol version 4 (IPv4) is the fourth version of the Internet Protocol (IP). It is one of the core protocols of standards-based internetworking methods in the Internet and other packet-switched networks. IPv4 was the first version deployed for production on SATNET in 1982 and on the ARPANET in January 1983. It is still used to route most Internet traffic today, even with the ongoing deployment of Internet Protocol version 6 (IPv6), its successor.

<span class="mw-page-title-main">IPv6</span> Version 6 of the Internet Protocol

Internet Protocol version 6 (IPv6) is the most recent version of the Internet Protocol (IP), the communications protocol that provides an identification and location system for computers on networks and routes traffic across the Internet. IPv6 was developed by the Internet Engineering Task Force (IETF) to deal with the long-anticipated problem of IPv4 address exhaustion, and was intended to replace IPv4. In December 1998, IPv6 became a Draft Standard for the IETF, which subsequently ratified it as an Internet Standard on 14 July 2017.

The Internet Protocol (IP) is the network layer communications protocol in the Internet protocol suite for relaying datagrams across network boundaries. Its routing function enables internetworking, and essentially establishes the Internet.

In computer networking, the User Datagram Protocol (UDP) is one of the core communication protocols of the Internet protocol suite used to send messages to other hosts on an Internet Protocol (IP) network. Within an IP network, UDP does not require prior communication to set up communication channels or data paths.

Classless Inter-Domain Routing is a method for allocating IP addresses for IP routing. The Internet Engineering Task Force introduced CIDR in 1993 to replace the previous classful network addressing architecture on the Internet. Its goal was to slow the growth of routing tables on routers across the Internet, and to help slow the rapid exhaustion of IPv4 addresses.

<span class="mw-page-title-main">Subnet</span> Logical subdivision of an IP network

A subnetwork, or subnet, is a logical subdivision of an IP network. The practice of dividing a network into two or more networks is called subnetting.

<span class="mw-page-title-main">Classful network</span> Early system for organizing the IPv4 address space

A classful network is an obsolete network addressing architecture used in the Internet from 1981 until the introduction of Classless Inter-Domain Routing (CIDR) in 1993. The method divides the IP address space for Internet Protocol version 4 (IPv4) into five address classes based on the leading four address bits. Classes A, B, and C provide unicast addresses for networks of three different network sizes. Class D is for multicast networking and the class E address range is reserved for future or experimental purposes.

Bogon filtering is the practice of filtering bogons, which are bogus (fake) IP addresses of a computer network. Bogons include IP packets on the public Internet that contain addresses that are not in any range allocated or delegated by the Internet Assigned Numbers Authority (IANA) or a delegated regional Internet registry (RIR) and allowed for public Internet use. The areas of unallocated address space are called the bogon space.

Zero-configuration networking (zeroconf) is a set of technologies that automatically creates a usable computer network based on the Internet Protocol Suite (TCP/IP) when computers or network peripherals are interconnected. It does not require manual operator intervention or special configuration servers. Without zeroconf, a network administrator must set up network services, such as Dynamic Host Configuration Protocol (DHCP) and Domain Name System (DNS), or configure each computer's network settings manually.

<span class="mw-page-title-main">Anycast</span> Network addressing and routing methodology

Anycast is a network addressing and routing methodology in which a single IP address is shared by devices in multiple locations. Routers direct packets addressed to this destination to the location nearest the sender, using their normal decision-making algorithms, typically the lowest number of BGP network hops. Anycast routing is widely used by content delivery networks such as web and name servers, to bring their content closer to end users.

In Internet networking, a private network is a computer network that uses a private address space of IP addresses. These addresses are commonly used for local area networks (LANs) in residential, office, and enterprise environments. Both the IPv4 and the IPv6 specifications define private IP address ranges.

The name localhost is reserved by the Internet Engineering Task Force (IETF) as a domain name label that may not be installed as a top-level domain in the Domain Name System (DNS) of the Internet.

In computer networking, the multicast DNS (mDNS) protocol resolves hostnames to IP addresses within small networks that do not include a local name server. It is a zero-configuration service, using essentially the same programming interfaces, packet formats and operating semantics as unicast Domain Name System (DNS). It was designed to work as either a stand-alone protocol or compatibly with standard DNS servers. It uses IP multicast User Datagram Protocol (UDP) packets and is implemented by the Apple Bonjour and open-source Avahi software packages, included in most Linux distributions. Although the Windows 10 implementation was limited to discovering networked printers, subsequent releases resolved hostnames as well. mDNS can work in conjunction with DNS Service Discovery (DNS-SD), a companion zero-configuration networking technique specified separately in RFC 6763.

In the Internet addressing architecture, the Internet Engineering Task Force (IETF) and the Internet Assigned Numbers Authority (IANA) have reserved various Internet Protocol (IP) addresses for special purposes.

In computer networking, a link-local address is an network address that is valid only for communications on a local link, i.e. within a subnetwork that a host is connected to. Link-local addresses are most often unicast network addresses assigned automatically through a process known as stateless address autoconfiguration (SLAAC) or link-local address autoconfiguration, also known as automatic private IP addressing (APIPA) or auto-IP. Link-local addresses are not all unicast; e.g. IPv6 addresses beginning with ff02:, and IPv4 addresses beginning with 224.0.0. are multicast addresses that are link-local.

An IPv6 transition mechanism is a technology that facilitates the transitioning of the Internet from the Internet Protocol version 4 (IPv4) infrastructure in use since 1983 to the successor addressing and routing system of Internet Protocol Version 6 (IPv6). As IPv4 and IPv6 networks are not directly interoperable, transition technologies are designed to permit hosts on either network type to communicate with any other host.

The Internet Protocol Version 4 address 0.0.0.0 can have multiple uses.

<span class="mw-page-title-main">IPv6 address</span> Label to identify a network interface of a computer or other network node

An Internet Protocol Version 6 address is a numeric label that is used to identify and locate a network interface of a computer or a network node participating in a computer network using IPv6. IP addresses are included in the packet header to indicate the source and the destination of each packet. The IP address of the destination is used to make decisions about routing IP packets to other networks.

References

  1. 1 2 3 S. Cheshire; M. Krochmal (February 2013). Special-Use Domain Names. IETF. doi: 10.17487/RFC6761 . ISSN   2070-1721. RFC 6761.Proposed Standard. Updates RFC  1918 and 2606.
  2. 1 2 M. Cotton; L. Vegoda; B. Haberman (April 2013). R. Bonica (ed.). Special-Purpose IP Address Registries. IETF. doi: 10.17487/RFC6890 . ISSN   2070-1721. BCP 153. RFC 6890.Best Common Practice. Obsoletes RFC  4773, 5156, 5735 and 5736. Updated by RFC  8190.
  3. 1 2 R. Hinden; S. Deering (February 2006). IP Version 6 Addressing Architecture. Network Working Group. doi: 10.17487/RFC4291 . RFC 4291.Draft Standard. Obsoletes RFC  3513. Updated by RFC  5952, 6052, 7136, 7346, 7371 and 8064.
  4. D. Eastlake; A. Panitz (June 1999). Reserved Top Level DNS Names. Network Working Group. doi: 10.17487/RFC2606 . BCP 32. RFC 2606.Best Common Practice. Updated by RFC  6761.
  5. J. Postel (September 1981). ASSIGNED NUMBERS. Network Working Group. doi: 10.17487/RFC0790 . RFC 790.Obsolete. Obsoleted by RFC  820. Obsoletes RFC  776, 770, 762, 758, 755, 750, 739, 604, 503, 433 and 349.Obsoletes IENs: 127, 117, 93.
  6. J. Reynolds; J. Postel (November 1986). ASSIGNED NUMBERS. Network Working Group. doi: 10.17487/RFC0990 . RFC 990.Obsolete. Obsoleted by RFC  1010. Obsoletes RFC  960. Obsoletes IENs 127, 117, and 93.
  7. J. Reynolds; J. Postel (October 1994). ASSIGNED NUMBERS. Network Working Group. doi: 10.17487/RFC1700 . STD 2. RFC 1700.Obsolete. Obsoleted by RFC  3232. Obsoletes RFC  1340, 1060, 1010, 990, 960, 943, 923, 900, 870, 820, 790, 776, 770, 762, 758, 755, 750, 739 604, 503, 433 and 349. Obsoletes IENs: 127, 117, 93.
  8. IANA (September 2002). Special-Use IPv4 Addresses. Network Working Group. doi: 10.17487/RFC3330 . RFC 3330.Obsolete. Obsoleted by RFC   5735.
  9. M. Cotton; L. Vegoda (January 2010). Special Use IPv4 Addresses. Internet Engineering Task Force. doi: 10.17487/RFC5735 . ISSN   2070-1721. BCP 153. RFC 5735.Obsolete. Obsoleted by RFC  6890.
  10. R. Hinden; S. Deering (December 1995). IP Version 6 Addressing Architecture. Network Working Group. doi: 10.17487/RFC1884 . RFC 1884.Obsolete. Obsoleted by RFC  2373.
  11. R. Hinden; S. Deering (July 1998). IP Version 6 Addressing Architecture. Network Working Group. doi: 10.17487/RFC2373 . RFC 2373.Obsolete. Obsoleted by RFC  3513. Obsoletes RFC  1884.
  12. R. Hinden; S. Deering (April 2003). IP Version 6 Addressing Architecturen. Network Working Group. doi: 10.17487/RFC3513 . RFC 3513.Obsolete. Obsoletes RFC  2373. Obsoleted by RFC  4291.
  13. Raymond, Eric S. "The Jargon File".
  14. "MySQL :: MySQL 5.5 Reference Manual :: 4.1 Overview of MySQL Programs".