Internet Protocol or IP uses a 32-bit IPv4 or 128-bit IPv6 address for identifying a device on a network. This is analogous to lớn our physical trang chủ address which is used for delivering our mails và online shopping items, for reaching lớn us, etc. Our physical home address is a phối of numbers and words, but in the case of computers, they only understand numeric addresses in a specific format. Even if we type an address like “www.domain.com”, computers will resolve it into a numerical format using the DNS mechanism.
Bạn đang xem: 404 not found
An IP address is a private one if it is used only inside a local network. On the other hand, a public IP is used for accessing networks và devices outside a private LAN và over the internet. Three different ranges of IP addresses are assigned in a private block by the mạng internet Assigned Numbers Authority (IANA). RFC 1918 specifies these three ranges as follows:
10.0.0.0 -10.255.255.255172.16.0.0 - 172.31.255.255192.168.0.0 – 192.168.255.255
The address block 127.0.0.0/8 is reserved for loopback or localhost addresses. It is basically an IP address range that is private at the host level. Any IP address inside this range cannot be used for any network. Let us explore in-depth- the concept of localhost IP or 127.0.0.1.
What is Localhost or 127.0.0.1?
Localhost refers lớn the name of a computer itself. Localhost redirects khổng lồ the IP address 127.0.0.1, which is also called the loopback address. Actually, any IPv4 address in block 127.0.0.0/8 is designated as a loopback address. Applications usually prefer lớn use 127.0.0.1 for their networking service. The IP address 127.0.0.1 is normally assigned to lớn the loopback interface. A loopback interface is technically a closed circuit. This means any TCP or UDP packet arriving at the loopback interface (localhost or 127.0.0.1) will be routed lớn the computer itself without going khổng lồ the outside network or on the internet.
Localhost is basically used by many software programs like web servers, database servers, etc. Khổng lồ provide their services. In most cases where multiple applications are using the localhost address, they can be configured lớn use different port numbers. This can be usually done by modifying their configuration files.
Need of Localhost
The main purpose of using Localhost is lớn develop & test applications before deploying them to lớn production environments. One of the popular examples is WordPress development. One can use the local environment to demo new plugins & updates before deploying them lớn the real world. Some applications like Stringer RSS reader can be used only through Localhost. If you want to check if the Localhost is properly phối on your computer, just install the Apache website server & navigate khổng lồ the address http://localhost or http://127.0.0.1. This will bring the Apache homepage. If it is IPv6 localhost, you can access it by going lớn URL HTTP ://<::1>/ to lớn access this web page on other devices on your LAN, you will need its private IP assigned by the DHCP server. Similarly, if you want lớn access this web page from a remote location, you will require a public IP address.
Besides 127.0.0.1, the localhost can also be mapped to lớn other loopback IP addresses. For instance, you can still access the Apache start page with any address from 127.0.0.1 khổng lồ 127.0.0.255 in the network 127.0.0.0/28.
The new IPv4 successor, IPv6 is a next-generation internet Protocol (IP). It has a 128-bit IP address. Like a 32-bit IPv4 loopback address, IPv6 also specifies a 128-bit loopback address. The notation for an IPv6 localhost address is::1/128. Normally applications are configured khổng lồ use both the IPv4 & IPv6 addresses. If you have previously installed Apache web server on your Linux server, you will notice that you can visit the Apache start page with the IPv6 localhost address. The choice of using IPv6 or IPv4 loopback IP may depend on your requirement. Maybe you want lớn develop your application lớn use only the IPv6 addresses, in that case, you can configure IPv6 localhost networking for it. Each has its own benefits over the other.
Name Resolution for Localhost
In almost every operating system, there exists a host file that resolves hostname to an IP address. This file also contains the name resolution for both the IPv4 & IPv6 localhost. Let us quickly look at the content of this file on an Ubuntu 20.04 OS. Mở cửa a terminal (ctrl+alt+t) và type:
The above command will display the contents of the host’s tệp tin on the terminal, as shown here:
From the above picture, we can see that label 1 corresponds to IPv4 localhost, & label 2 corresponds khổng lồ IPv6 localhost.
Xem thêm: Phân Tích 8 Câu Thơ Đầu Bài Tình Cảnh Lẻ Loi Của Người Chinh Phụ Chi Tiết
In this guide, we have explored various features and uses of localhost or loopback IP. It is really a great boon for application development as it provides great flexibility & many possibilities.