Loopback address loopback addresses

Source: Internet
Author: User

first, related loopback address basic concept

What does the loopback address of a device on a router mean?

The local loopback interface (or address), also known as the loopback address (loopback addresses).

This type of interface is the most widely used virtual interface, which is used on almost every router. Common in the following uses:
1 as an administrative address for a single router
After the system administrator completes the network planning, in order to facilitate management, a loopback interface is created for each router, and an IP address is specified separately on the interface as an administrative address, which is used by the administrator to remotely log on to the router (telnet). The address actually plays a function similar to the device name.
But there are usually many interfaces and addresses on each router, so why not pick one out of it.
The reason for this is as follows: Because the Telnet command uses a TCP message, one of the router's interfaces is down because of a failure, but other interfaces can still telnet, meaning that the TCP connection to the router still exists. Therefore, the selected Telnet address must never be down, and the virtual interface satisfies such requirements. Because such interfaces do not require interoperability with the end-to-end, the address of the loopback interface is usually specified as a 32-bit mask in order to conserve address resources.
2 using this interface address as a dynamic routing protocol OSPF, BGP router ID dynamic routing protocol OSPF, BGP need to specify a router ID for this protocol as the router's unique identifier and required to be unique throughout the autonomous system. Because the router ID is a 32-bit unsigned integer, this is very much like an IP address. Also, the IP address is not duplicated, so the router's router ID is typically specified as the same as the address of an interface on the device. Because the IP address of the loopback interface is usually considered a router's identity, it is also the best choice for the router ID.
3, use this interface address as BGP to establish the source address of the TCP connection
In the BGP protocol, the establishment of a neighbor relationship between two routers running BGP is done through TCP connection.
When you configure a neighbor, you typically specify that the loopback interface is the source address for establishing a TCP connection (usually used only for IBGP, for the same reason as 2.1, to enhance the robustness of the TCP connection)
The configuration commands are as follows:
Router ID 61.235.66.1
Interface Loopback 0
IP address 61.235.66.1 255.255.255.255
Router BGP 100
Neighbor 61.235.66.7 Remote-as 200
Neighbor 61.235.66.7 Update-source LoopBack0
4, in the Windows system, the use of 127.0.0.1 as a local loopback address.

application of Java class

InetAddress
Extends Object implements Serializable

This class represents an Internet Protocol (IP) address.

An instance of InetAddress contains an IP address and may also contain the appropriate hostname (depending on whether it is constructed with a host name or if reverse host name resolution has been performed).

Boolean isloopbackaddress ()
Check whether InetAddress is a utility routine for loopback addresses.

By obtaining a reference to the InetAddress subclass object, you can invoke various methods of inetaddress to obtain the IP address information in the InetAddress subclass object, for example, by calling Getcanonicalhostname () Obtain the standard host name from the domain Name Service, gethostaddress () obtains the IP address, gethostname () obtains the host name, Isloopbackaddress () determines whether the IP address is a loopback address.

List1 is a demo code:

Inetaddressdemo.java
import java.net.*;

Class Inetaddressdemo
{public
static void main (string [] args) throws Unknownhostexception
{
string  host = "localhost";

if (args.length = = 1)
host = args [0];

InetAddress ia = inetaddress.getbyname (host);

System.out.println ("Canonical Host Name =" +
ia.getcanonicalhostname ());
System.out.println ("Host address =" +
ia.gethostaddress ());
System.out.println ("Host Name =" +
ia.gethostname ());
System.out.println ("is loopback address =" +
ia.isloopbackaddress ());
}

When there is no command-line argument, the code output is similar to the following result:

Canonical Host Name = localhost

Host address = 127.0.0.1

Host Name = localhost

is loopback address = True


  

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.