A loopback interface is a virtual interface that can be created within a network device and behaves much the same as a physical interface.
Loopback interfaces can be configured on a Cisco router or a switch and have many uses. In this article, we’ll examine what they are, how they can be configured, and how they are helpful in a modern IP network.
The term loopback goes back to the days of analog telephony. The concept involves setting up a connection so that any sent signals from a device are immediately and only received by that same device.
The signal is essentially “looped back” to the sender. This methodology was used to perform transmission tests of telephone access lines.
This term has been adopted in IP networking in several ways. One is the loopback address block of 127.0.0.0/8, as defined in RFC 5735.
IP addresses within this range, such as 127.0.0.1 for example, can be used by a host to refer to itself. This is also known as a localhost address. Communicating with such an address essentially causes the sending device to communicate with itself.
Another way the term has been used, not to be confused with the loopback address, is with the concept of the loopback interface.
This is a virtual Layer 3 network interface that can be created and used just like any other interface. In essence, this is not a genuinely proper loopback since this is not used by a host to communicate with itself but can be used to communicate with other network devices.
What is a Loopback Interface?
A loopback interface is a logical entity that can be created within a router or a switch. When created, it has many of the same characteristics as a Layer 3 port on a router or a Switched Virtual Interface (SVI) on a switch.
It can be assigned an IP address, it obtains a virtual MAC address, and it can be both the source and destination of data transmissions with other network entities.
The only thing it lacks, compared to a physical Layer 3 port on a router, is the ability to be connected to a subnet with additional hosts.
How to Configure a Loopback Interface
Loopback interfaces can be configured quite easily on both Cisco routers and switches. Below you will find the configuration involved in each case.
Configuring a loopback interface on a Cisco router
The first thing to do is to issue the interface loopback command in global configuration mode to create a loopback interface. Notice the following command line output:
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#interface loopback ?
<0-2147483647> Loopback interface number
Each loopback interface is assigned a loopback interface number. This number can be between 0 and 2147483647.
Theoretically, you can create that many loopback interfaces on a router. However, you will quickly run out of memory and CPU resources on the device before you get even close to creating so many.
Let’s create a loopback interface with an interface number of 1:
R1(config)#interface loopback 1
*Jan 4 09:39:01.352: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1, changed state to up
A Syslog message appears, informing us that the Loopback1 interface has come up. That’s a good sign. Now we are in interface configuration mode, the same mode we would enter when configuring a physical interface.
Let’s configure an IP address on this loopback interface:
R1(config-if)#ip address 192.168.100.1 255.255.255.0
Let’s take a look at all of the interfaces on this particular router:
R1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 10.255.1.235 YES NVRAM administratively down down
GigabitEthernet0/1 192.168.12.1 YES NVRAM up up
Loopback0 22.214.171.124 YES NVRAM up up
Loopback1 192.168.100.1 YES manual up up
We see all the interfaces on the router, including physical and loopback interfaces, as well as their assigned IP addresses.
Configuring a loopback interface on a Cisco switch
A loopback interface can be configured on a Cisco switch in a very similar manner. The commands are almost identical. The following commands create a loopback with an interface number of 1, and assign an IP address to it:
SW1(config)#interface loopback 1
*Jan 4 09:50:33.620: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1, changed state to up
SW1(config-if)#ip address 10.10.10.1 255.255.255.0
We can verify that the loopback has been configured correctly using the following command:
SW1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 unassigned YES unset up up
GigabitEthernet0/1 unassigned YES unset up up
GigabitEthernet0/2 unassigned YES unset up up
GigabitEthernet0/3 unassigned YES unset up up
GigabitEthernet1/0 unassigned YES unset up up
GigabitEthernet1/1 unassigned YES unset up up
Loopback1 10.10.10.1 YES manual up up
Vlan500 192.168.1.1 YES manual down down
At this point the switch is configured with a loopback interface and an SVI that are configured with IP addresses. The rest of the interfaces are operating as switchports, that is, only at Layer 2.
We can verify that the loopback interface is operating correctly by pinging it like so:
SW1# ping 10.10.10.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.1, timeout is 2 seconds:
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Difference between an SVI and a loopback interface
Note that even though an SVI and a loopback are both virtual Layer 3 interfaces, they differ in the way they operate.
Firstly, The SVI exists on a particular VLAN and typically acts as the default gateway for any hosts connected to that VLAN. A loopback interface on a switch does not belong to any VLAN and must have an IP address in a subnet that is distinct from subnets associated with any particular VLAN.
Note also that an SVI will go down if there is not at least one active physical interface assigned to the VLAN to which the SVI belongs.
Note in the output in the previous section, the configured Vlan500 SVI has a status of down and a protocol of down.
This is because there are no active access ports assigned to VLAN 500. A loopback interface is not affected by such restraints, and is always active as long as the switch has power.
What makes loopback interfaces special?
Several characteristics of loopback interfaces make them especially useful for particular applications:
- Loopback interfaces will not go down if a cable is unplugged or a physical interface fails.
- Traffic sent from and destined to the network device itself can be sent and received using the IP address of the loopback interface instead of the address of a physical interface through which other traffic passes.
- A loopback interface can be used to communicate directly with the device on which it is configured using Telnet, SSH, or other communication protocols, as long as at least one of the physical interfaces on the device is operational.
Loopback interface use cases
The above characteristics make loopback interfaces very useful for control plane operations and network maintenance. Some of the most useful applications of loopback interfaces include:
- Network device management – Administrators can obtain communication with network devices using CLI or web management interfaces by connecting directly to the IP addresses assigned to a loopback interface of a device.
- Routing protocols – Many routing protocols, such as OSPF, EIGRP, and BGP, will use loopback addresses of routers and L3 switches to assign a router ID, which uniquely identifies that device within the routing domain.
- Source and destination address for network monitoring – Many network monitoring systems that use SNMP, Netflow, or IPSLAs can use the loopback interfaces to send and receive monitoring data. The loopbacks can also be used to benchmark pings and traceroutes within a network for network auditing, testing, and observation.
Note that most uses of loopback interfaces have to do with network maintenance, monitoring, and upkeep. End users will rarely come across any use for a loopback interface on a network device, nor will they ever get any direct benefit from their implementation.
Loopback interfaces are constructs that are useful in many respects but are nevertheless leveraged by other protocols, programs, and applications.
As entities themselves, they do little more than create an interface through which communication can take place. Knowing how other entities use them is an important part of further understanding their significance in networking.
- The Most Important Cisco Show Commands You Must Know (Cheat Sheet)
- Cisco Show Interface Command on Routers and Switches Explained
- Discussion and Explanation of OSPF Graceful Restart and Shutdown
- Explanation and Configuration of OSPF MD5 Authentication on Cisco Networks
- Explanation of BGP Neighbor Adjacency States on Cisco Devices