Loopback Interfaces
This topic discusses about the use of loopback interface, step-by-step procedure on how to configure loopback interfaces with examples.
Loopback Interface Overview
The Internet Protocol (IP) specifies a loopback network with the (IPv4) address
127.0.0.0/8
. Most IP implementations support a loopback interface
(lo0
) to represent the loopback facility. Any traffic that a
computer program sends on the loopback network is addressed to the same computer. The
most commonly used IP address on the loopback network is 127.0.0.1
for
IPv4 and ::1
for IPv6. The standard domain name for the address is
localhost
.
A network device also includes an internal loopback interface
(lo0.16384
). The internal loopback interface is a particular instance
of the loopback interface with the logical unit number 16384.
You use the loopback interface to identify the device. While you can use any interface address to determine if the device is online, the loopback address is the preferred method. Whereas interfaces might be removed or addresses changed based on network topology changes, the loopback address never changes.
When you ping an individual interface address, the results do not always indicate the health of the device. For example, a subnet mismatch in the configuration of two endpoints on a point-to-point link makes the link appear to be inoperable. Pinging the interface to determine whether the device is online provides a misleading result. An interface might be unavailable because of a problem unrelated to the device configuration or operation. You can use the loopback interface to address these issues.
Junos OS Evolved supports two different filters to control the flow of local packets: one for network control traffic (loopback traffic) and one for management traffic. For additional information, see Top Differences Between Junos OS Evolved and Junos OS.
Benefits
-
As the loopback address never changes, it is the best way to identify a device in the network.
-
The loopback interface is always up and reachable as long as the route to that IP address is available in the IP routing table. Hence, you can use the loopback interface for diagnostics and troubleshooting purposes.
-
Protocols such as OSPF use the loopback address to determine protocol-specific properties for the device or network. Further, some commands such as
ping mpls
require a loopback address to function correctly. -
Junos OS creates a separate loopback interface for the internal routing instance, which prevents any filter on
lo0.0
from disrupting internal traffic.
Loopback Interface Configuration
You (a system administrator, network administrator, or end user) can use this procedure to configure the loopback interface on your device.
- Configure the Loopback Interface
- Example: Configure Two Addresses on the Loopback Interface with Host Routes
- Example: Configure Two Addresses on the Loopback Interface with Subnetwork Routes
- Example: Configure an IPv4 and an IPv6 Address on the Loopback Interface with Subnetwork Routes
Configure the Loopback Interface
When specifying the loopback address on a device, do not include a destination prefix. Also, in most cases, specify a loopback address only on unit 0 and no others.
For Layer 3 virtual private networks (VPNs), you can configure multiple logical units for the loopback interface. This allows you to configure a logical loopback interface for each virtual routing and forwarding (VRF) routing instance. For more information, see the Junos OS VPNs Library for Routing Devices.
For some applications, such as SSL for Junos XML protocol, at least one address
for the interface lo0.0
must be 127.0.0.1
.
You can configure loopback interfaces using a host (recommended), a subnetwork
address for both inet
and inet6
address families,
or an ISO network entity title (NET) address for the iso
address
family. Many protocols require a loopback address as their source address.
Configuring a loopback address as a donor interface for unnumbered interfaces
enables these protocols to run on unnumbered interfaces.
In some cases, the loopback interface can also be the router identifier (router ID). If the router ID is not explicitly configured, the device determines its router ID as shown in the following table:
If the loopback interface is: | Then the default router ID is: |
---|---|
Configured | The loopback interface |
Not configured | The lowest IP address of any interface in operational state
up |
In both cases, the router ID changes when the operational state of the interface changes. Therefore, we recommend configuring the address on a stable loopback interface.
If you configure more than one address on the loopback interface, we recommend that you configure one to be the primary address. The device selects the primary address as the router ID when the router ID is not configured. The device also uses the primary address as the default source address for traffic sourced from the loopback interface by the Routing Engine.
To configure the physical loopback interface (lo0
), include the
following statements at the [edit interfaces]
hierarchy level:
[edit interfaces] lo0 { unit 0 { family inet { address loopback-address; address <loopback-address2>; ... } family inet6 { address loopback-address; } } }
You can configure one or more addresses on the loopback interface. You can configure
more than just unit 0
for lo0
, but you must place
each additional unit in a separate routing instance.
Example: Configure Two Addresses on the Loopback Interface with Host Routes
In the following example, the user configures two addresses on the loopback interface with host routes:
[edit] user@host# edit interfaces lo0 unit 0 family inet [edit interfaces lo0 unit 0 family inet] user@host# set address 10.0.0.1 [edit interfaces lo0 unit 0 family inet] user@host# set address 172.16.0.1 [edit interfaces lo0 unit 0 family inet] user@host# top [edit] user@host# show interfaces lo0 { unit 0 { family inet { 10.0.0.1/32; 172.16.0.1/32; } } }
Example: Configure Two Addresses on the Loopback Interface with Subnetwork Routes
In some instances, you may need to advertise a subnetwork route as internal rather than a Type 5 route for an redistributed static route using OSPF. In this scenario, you may want to configure subnetwork routes on the loopback interface, as shown in the following example:
[edit] user@host# edit interfaces lo0 unit 0 family inet [edit interfaces lo0 unit 0 family inet] user@host# set address 10.2.0.1/16 [edit interfaces lo0 unit 0 family inet] user@host# set address 192.16.0.1/24 [edit interfaces lo0 unit 0 family inet] user@host# top [edit] user@host# show interfaces { lo0 { unit 0 { family inet { 10.2.0.1/16; 192.16.0.1/24; } } } }
Example: Configure an IPv4 and an IPv6 Address on the Loopback Interface with Subnetwork Routes
In the following example, the user configures an IPv4 and an IPv6 address on the loopback interface with subnetwork routes:
[edit] user@host# edit interfaces lo0 unit 0 family inet [edit interfaces lo0 unit 0 family inet] user@host# set address 192.16.0.1/24 [edit interfaces lo0 unit 0 family inet] user@host# up [edit interfaces lo0 unit 0 family] user@host# edit interfaces lo0 unit 0 family inet6 [edit interfaces lo0 unit 0 family inet6] user@host# set address 2001:db8::200:f8ff:fe75:50df/64 [edit interfaces lo0 unit 0 family inet6] user@host# top [edit] user@host# show interfaces { lo0 { unit 0 { family inet { 192.16.0.1/24; } family inet6 { 2001:db8::200:f8ff:fe75:50df/64; } } } }