IP addresses are used to specify the hosts in a numeric way. There are different types of IP addresses in Computer networks. One of them is 127.0.0.1 which seems a bit confusing. 127.0.0.1 is a special-purpose IPv4 address. This address is assigned to the local system and can not be used by other systems.
127.0.0.1 IP Address
127.0.0.1 is mainly designed to test local system network protocols. We can ping
127.0.0.1 like other IP addresses on the local or remote networks. The ping ICMP request will reply with successfully if there is no problem with the operating system network stack. “127.0.0.1” is also called a loopback address because it is connected to the local system, not on a remote system. The IP address range 127.0.0.1/8 is completely registered for loopback purposes. This means Between 127.0.0.1 – 127.0.1.255 are registered for loopback interfaces.
IP Address 127.0.0.1 Use Cases
At first it may seem unecassary to use IP address 127.0.0.1 but it provides some popular use cases.
Loopback 127.0.0.1 can be used for testing purposes in order to check the current system network stack and functionalities. We can ping the 127.0.0.1 and if it is replying properly this means the TCP/IP network stack is working properly.
127.0.0.1 also used to block some applications and domains where the domain translation is pointed to 127.0.0.1. The host’s file contains the following record where the abc.com will be redirected to the localhost.
Alternatively, 127.0.0.1 can be also used to start different services like web server, file server, application server on the local system which can not be accessed by other computers. This is a secure way to make web application development and use the localhost to access and test it.
In this part we will ping the
127.0.0.1 to test our network stack. We will use
ping utilyty which is explained in detail in the following tutorial.
$ ping 127.0.0.1
Ping 127.0.0.2 and 127.0.0.3
As stated previously the 127.0.0.1/8 range is completely registred for loopback interfaces which are created on the local system. We can also ping 127.0.0.2, 127.0.0.3 upto 127.0.0.255 as the same where they will reply.
> ping 127.0.0.2 > ping 127.0.0.3
In order to see the 127.0.0.1 different from other IP addresses, we can trace IP addresses. Tracing will check the route to the given IP address and print intermediate hops and IP addresses. Below we can see that tracing to 127.0.0.1 only created a single step which takes less than 1ms. This simply means that 127.0.0.1 is on our computer. When we trace to the google.com we can see that it takes a lot much more time.
> tracert 127.0.0.1
> tracert google.com
localhost is just a hostname used to solve DNS to
127.0.0.1 .Localhost will work
127.0.0.1 interchangebly. We can see that this domain name is defined in
/etc/hosts for Linux and
/Windows/etc/ for Windows operating systems. We can change the IP address or change the name of the host.
AND print it like below.
$ cat /etc/hosts
IPv6 127.0.0.1 As ::1
IPv6 also has the same functionality for the “127.0.0.1“. This address is expressed as
::1 in a short manner but the real or full IP address is