Functions of Linux/Unix Host loopback addresses

Source: Internet
Author: User

Whether it is linux, unix, or windows, there is an IP address such as 127.0.0.1. This is a special IP address called the host loopback address. Open the/etc/hosts file, with at least 127.0.0.1. In daily work, it is very likely that the loopback address is used to complete a certain task. However, there are still few articles about the usage of the loopback address 127.0.0.1. I will write an article here to give some advice.

 

Test Functions

127.0.0.1 is often used to test various network services on the local machine. The following are some examples:

1. test whether the sshd service is normal. Run the command ssh 127.0.0.1 on the console. If a password is required, the sshd service is normal.
2. Test the ftp service.. Run the command ftp 127.0.0.1 on the console:

-bash-3.00# ftp 127.0.0.1ftp: connect: Connection refusedftp>

This output indicates that the ftpd service is abnormal. The ftp output for normal network service provision should be as follows:

-bash-3.00# ftp 127.0.0.1Connected to 127.0.0.1.220 (vsFTPd 2.0.5)Name (127.0.0.1:root):

3. Test the mail service. Run telnet 127.0.0.1 25 and telnet 127.0.0.1 110 on the console to check the running status of the email server.

4. view the ports opened by the system.Nmap is a good choice, and the output result is far more intuitive than netstat.

[root@netmonitor ~]# nmap 127.0.0.1
Starting nmap 3.70 ( http://www.insecure.org/nmap/ ) at 2007-05-15 18:05 CSTInteresting ports on localhost.localdomain (127.0.0.1):(The 1656 ports scanned but not shown below are in state: closed)PORT   STATE SERVICE21/tcp open  ftp22/tcp open  ssh25/tcp open  smtp80/tcp open  http
Nmap run completed -- 1 IP address (1 host up) scanned in 0.224 seconds

 

Local application connection


In an application environment such as apache + php + mysql, applications and mysql databases exist on the same system at the same time, and the socket IP address 127.0.0.1 is commonly used.

Someone may question this question: is it okay if you don't need a loop address? The answer is yes. The ip address of a network interface on the host can replace this loopback address.

HereWhy do we need to emphasize this loopback address? The main reason is convenience and stability.The IP address of the network interface may be changed for some reason (for example, the server is relocated to another geographic location), or the application is migrated to another system, as described in the preceding apache + php + mysql environment, because the loopback address 127.0.0.1 is used, it will not be affected by the change of the IP address, and vice versa.

Some network services are listening to network interfaces. For example, if you set the apache listener to "Listen 192.168.27.201: 80", the dependency is high. Once the network interface is interrupted (down ), the Service itself may also stop. This will not happen if the default listening address 127.0.0.1 is used.

Address: http://network.51cto.com/art/200705/47670.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.