Managing loopback interfaces

Adding a loopback interface


[NOTE: ]

NOTE: This task is not support by Switch 2530 (J9772A–J9783A) products.


Prerequisites

Before you use the CLI to add a loopback interface, you must be at the global configuration level.

Adding a loopback interface

To add a loopback interface on the switch:

  1. Use the interface loopback <number> command to create the loopback interface. The number argument is a value from 1 to 7.

  2. Use the ip address <ip address> command to configure an IP address for the loopback interface.

    You can configure up to 32 IP addresses on a loopback interface. You do not need to specify a network mask. A loopback interface uses the default subnet mask 255.255.255.255.

Examples

A loopback interface configured with one IP address

switch(config)# interface loopback 1
switch(config)# ip address 10.1.1.1

Loopback interfaces configured with multiple IP addresses

This example shows the addition of two loopback interfaces, each with two IP addresses configured.

switch(config)# interface loopback 0
switch(lo0)# ip address 172.16.101.8
switch(lo0)# ip address 172.16.101.9
switch(lo0)# exit
switch(config)# interface loopback 1
switch(lol)# ip address 172.16.102.1
switch(lol)# ip address 172.16.102.2

Removing a loopback interface


[NOTE: ]

NOTE: This task is not support by Switch 2530 (J9772A–J9783A) products.


Prerequisites

Before you use the CLI to remove a loopback interface, you must be at the global configuration level.

Removing a loopback interface

Use the no interface loopback <number> command to remove a loopback interface. The number argument is a value from 1 to 7, specifying the loopback interface to be removed.

You cannot remove the default loopback interface (number 0) with IP address 127.0.0.1.

Displaying loopback interface configurations

Do one of the following:

  • Use the show ip command to display a list of the loopback interfaces, which are sorted according to the loopback number.

    The list of loopback interfaces is displayed below other IP configuration parameters, such as packet TTL and ARP age-out values, and VLAN IP configurations. The default loopback interface (lo0) with IP address 127.0.0.1 is not displayed in the list because it is permanently configured on the switch.

  • Use the show ip route command to display the loopback interfaces in a list of IP routing entries. The list is sorted according to the destination IP address.

Examples

The show ip command output

This example displays the IP addresses configured for two user-defined loopback interfaces (lo1 and lo2).

switch# show ip

 IP Routing : Enabled

   Default Gateway : 15.255.128.1
   Default TTL     : 64
   Arp Age         : 20
   Domain Suffix   :
   DNS server      : 

                    |                                           Proxy ARP
   VLAN             | IP Config  IP Address      Subnet Mask    Std Local
   ---------------- + ---------- --------------- -------------- ----------
   DEFAULT_VLAN     | Manual     10.0.8.121     255.255.0.0     No   No
   VLAN2              Manual     192.168.12.1   255.255.255.0   No   No
   VLAN3              Disabled


                           Loopback Addresses
   Loopback   IP Config    IP Address           Subnet Mask
   --------   ----------   ------------------   ---------------
   lol        Manual       172.16.110.2         255.255.255.255 
   lo2        Manual       172.16.112.2         255.255.255.255 
   lo2        Manual       172.16.114.1         255.255.255.255

The show ip route command output

This example displays the configuration of the default loopback interface (lo0) and one user-defined loopback interface (lo2).

switch# show ip route

                                IP Route Entries

Destination        Gateway         VLAN Type      Sub-Type   Metric    Dist.
------------------ --------------- ---- --------- ---------- --------- ----
10.0.0.0/16        DEFAULT_VLAN    1    connected             1         0
127.0.0.0/8        reject               static                0         0
127.0.0.1/32       lo0                  connected             1         0
172.16.10.121/32   lo2                  static                1         0
172.16.100.0/24    10.0.8.11       1    ospf       IntraArea  1         1
172.16.102.0/24    VLAN2           2    connected             1         0

Summary of loopback interface configuration

Summary of loopback interface configuration:

  • You can configure a loopback interface only from the CLI; you cannot configure a loopback interface from the WebAgent or Menu interface.

  • Loopback interfaces share the same IP address space with VLAN configurations. The maximum number of IP addresses supported on a switch is 2048, which includes all IP addresses configured for both VLANs and loopback interfaces (except for the default loopback IP address 127.0.0.1).

  • Each IP address that you configure on a loopback interface must be unique in the switch. This means that the address cannot be used by a VLAN interface or another loopback interface.

  • For example, if you configure a VLAN with IP address 172.16.100.8/24, you cannot configure a loopback interface with IP address 172.16.100.8. In the same way, if you configure a loopback interface (lo1) with IP address 172.16.101.8, you cannot configure another loopback interface (lo2) with IP address 172.16.101.8.

  • You can configure multiple IP addresses on a loopback interface (lo0 to lo7). Up to 32 IP addresses are supported on a loopback interface.

Overview of loopback interfaces

By default, each switch has an internal loopback interface (lo0) with the IP address 127.0.0.1. This IP address is used only for internal traffic transmitted within the switch and is not used in packet headers in egress traffic sent to network devices.

You can configure up to seven other loopback interfaces (lo1, lo2, lo3, and so on) on the switch to use to transmit network across the network. Each loopback interface can have multiple IP addresses. Routing protocols, such as RIP and OSPF, advertise the configured loopback addresses throughout a network or autonomous system.

User-defined loopback addresses provide the following benefits:

  • A loopback interface is a virtual interface that is always up and reachable as long as at least one of the IP interfaces on the switch is operational. As a result, a loopback interface is useful for debugging tasks since its IP address can always be pinged if any other switch interface is up.

  • You can use a loopback interface to establish a Telnet session, ping the switch, and access the switch through SNMP, SSH, and HTTP (WebAgent).

  • A loopback IP address can be used by routing protocols. For example, you can configure the loopback IP address as the router ID used to identify the switch in an OSPF area. Because the loopback interface is always up, you ensure that the switch's router ID remains constant and that the OSPF network is protected from changes caused by downed interfaces.

OSPF does not require that you use an IP address as the router ID. OSPF only requires the router ID to be a unique value within the autonomous system (AS). However, if you configure the loopback IP address as the router ID, OSPF can reach the switch if any switch interface is up. (Normally, OSPF automatically configures the router ID with the IP address of a switch interface. The disadvantage is that if the interface goes down, OSPF can no longer ping the switch using the router ID even if other interfaces are operational.)

For more information about how to configure a loopback IP address to participate in an OSPF broadcast area, see the titled "(Optional) Assigning Loopback Addresses to an Area" in the Multicast and Routing Guide.