interface loopback [number]
Creates a virtual loopback interface on a router, used for router ID selection, management reachability, and testing without physical hardware.
Definition: interface loopback [number] is a Cisco IOS global config command. Creates a virtual loopback interface on a router, used for router ID selection, management reachability, and testing without physical hardware.
Overview
The `interface loopback [number]` command creates a virtual loopback interface on a Cisco router. Unlike physical interfaces, loopback interfaces are always up/up as long as the router is operational, making them ideal for stable router identification, management reachability, and testing. This command is entered in global configuration mode and creates a logical interface that behaves like an Ethernet interface but without any physical hardware dependency.
Loopback interfaces are commonly used for OSPF router ID selection, BGP peering, iBGP update sources, SNMP management, and as a stable source for diagnostic pings. They are also crucial for network troubleshooting because they provide a consistent IP address that is not subject to link failures. When you need a reliable IP address for a router that does not change with physical interface status, loopback is the go-to solution.
Alternatives include using a physical interface IP, but that risks unreachability if the link goes down. In the broader workflow, loopback interfaces are typically configured early in the router setup to establish a management plane, then referenced in routing protocols and management access lists. Important IOS behavior: loopback interfaces are created with a default MTU of 1514 bytes (or 1500 depending on IOS version), and they do not support subinterfaces.
The command requires privilege level 15 (enable mode) to enter global config. The running-config immediately reflects the new interface, and the interface number can range from 0 to 2147483647, though common practice uses small numbers like 0 or 1. Loopback interfaces do not generate link-layer events, so they are not affected by cable disconnections.
They are also used for NetFlow export sources and for testing routing protocol behavior without physical connectivity. In summary, the loopback interface is a fundamental building block for stable network design and troubleshooting.
interface loopback [number]When to Use This Command
- Setting a stable router ID for OSPF or EIGRP that doesn't depend on physical interface status
- Creating a management IP address that is always reachable via routing protocols
- Testing routing protocols and connectivity without needing physical cables
- Providing a termination point for BGP sessions or tunnel endpoints
Parameters
| Parameter | Syntax | Description |
|---|---|---|
| number | <0-2147483647> | The loopback interface number. Valid values range from 0 to 2147483647. Common practice uses small numbers like 0, 1, or 2 for simplicity. A common mistake is using a number that conflicts with an existing loopback interface; the router will enter interface configuration mode for that existing interface instead of creating a new one. |
Command Examples
Create a loopback interface and assign an IP address
interface loopback 0
ip address 10.0.0.1 255.255.255.255Router(config)# interface loopback 0 Router(config-if)# ip address 10.0.0.1 255.255.255.255 Router(config-if)# end Router# show ip interface brief Interface IP-Address OK? Method Status Protocol Loopback0 10.0.0.1 YES manual up up GigabitEthernet0/0 192.168.1.1 YES manual up up GigabitEthernet0/1 unassigned YES unset administratively down down
The 'interface loopback 0' command creates loopback 0 and enters interface configuration mode. 'ip address 10.0.0.1 255.255.255.255' assigns a /32 IP address. 'show ip interface brief' confirms the loopback is up/up, meaning it is always active. The /32 mask is typical for loopbacks.
Configure multiple loopback interfaces for OSPF router IDs
interface loopback 1
ip address 10.0.0.2 255.255.255.255
interface loopback 2
ip address 10.0.0.3 255.255.255.255Router(config)# interface loopback 1 Router(config-if)# ip address 10.0.0.2 255.255.255.255 Router(config-if)# interface loopback 2 Router(config-if)# ip address 10.0.0.3 255.255.255.255 Router(config-if)# end Router# show ip ospf Routing Process "ospf 1" with ID 10.0.0.2 ...
Multiple loopbacks can be created. OSPF automatically selects the highest IP address on a loopback as the router ID (unless manually set). Here, loopback 1's IP 10.0.0.2 becomes the OSPF router ID because it is the highest among loopbacks (10.0.0.3 is higher but loopback 2 was created after OSPF started; OSPF would need to be restarted to pick it up).
Understanding the Output
The 'show ip interface brief' output displays all interfaces, including loopbacks. The 'Status' column shows 'up' for loopbacks because they are virtual and always active unless administratively shut down. 'Protocol' is also 'up' because there is no layer 1 dependency.
A loopback that is 'administratively down' indicates it was manually shut with 'shutdown'. In routing protocol outputs like 'show ip ospf', the router ID is often the highest loopback IP address. For troubleshooting, ensure loopback IPs are unique and reachable via routing.
Good values: 'up/up' for status/protocol. Bad: 'administratively down' indicates a shutdown command was issued.
Configuration Scenarios
Configure OSPF Router ID using Loopback Interface
In OSPF, the router ID is typically the highest loopback IP address. This scenario configures a loopback interface on a router to ensure a stable router ID that does not change when physical interfaces go down.
Topology
R1(Lo0: 10.0.0.1/32)---(Gi0/0: 192.168.1.1/24)---(Gi0/0: 192.168.1.2/24)R2(Lo0: 10.0.0.2/32)Steps
- 1.Step 1: Enter privileged EXEC mode: Router> enable
- 2.Step 2: Enter global configuration mode: Router# configure terminal
- 3.Step 3: Create loopback interface 0: Router(config)# interface loopback 0
- 4.Step 4: Assign IP address: Router(config-if)# ip address 10.0.0.1 255.255.255.255
- 5.Step 5: Exit interface configuration: Router(config-if)# exit
- 6.Step 6: Enable OSPF: Router(config)# router ospf 1
- 7.Step 7: Optionally set router ID explicitly: Router(config-router)# router-id 10.0.0.1
- 8.Step 8: Advertise loopback network: Router(config-router)# network 10.0.0.1 0.0.0.0 area 0
- 9.Step 9: Exit OSPF configuration: Router(config-router)# end
! Full IOS config block Router(config)# interface loopback 0 Router(config-if)# ip address 10.0.0.1 255.255.255.255 Router(config-if)# exit Router(config)# router ospf 1 Router(config-router)# router-id 10.0.0.1 Router(config-router)# network 10.0.0.1 0.0.0.0 area 0 Router(config-router)# end
Verify: Use 'show ip ospf' to verify the router ID is 10.0.0.1. Use 'show ip interface brief' to confirm loopback0 is up/up. Expected output: 'Loopback0 10.0.0.1 YES manual up up'
Watch out: If you do not explicitly set the router-id, OSPF will use the highest loopback IP. If you later add a higher loopback IP, the router ID may change, causing OSPF neighbor resets. Always set router-id explicitly to avoid instability.
Stable iBGP Peering using Loopback Interfaces
iBGP sessions require full mesh or route reflectors. Using loopback interfaces for peering ensures the BGP session remains up even if a physical link fails, as long as there is an alternate path between the routers.
Topology
R1(Lo0: 10.0.0.1/32)---(Gi0/0: 192.168.1.1/24)---(Gi0/0: 192.168.1.2/24)R2(Lo0: 10.0.0.2/32)
R1(Lo0) also reachable via 10.0.1.0/24 through another path.Steps
- 1.Step 1: Configure loopback interfaces on both routers with /32 masks.
- 2.Step 2: Enable an IGP (e.g., OSPF or EIGRP) to advertise the loopback networks.
- 3.Step 3: Configure BGP on R1: Router(config)# router bgp 65001
- 4.Step 4: Specify the BGP router ID: Router(config-router)# bgp router-id 10.0.0.1
- 5.Step 5: Define neighbor using loopback IP: Router(config-router)# neighbor 10.0.0.2 remote-as 65001
- 6.Step 6: Set update-source to loopback: Router(config-router)# neighbor 10.0.0.2 update-source loopback 0
- 7.Step 7: Ensure next-hop-self if needed: Router(config-router)# neighbor 10.0.0.2 next-hop-self
- 8.Step 8: Repeat similar configuration on R2.
! R1 configuration Router(config)# interface loopback 0 Router(config-if)# ip address 10.0.0.1 255.255.255.255 Router(config-if)# exit Router(config)# router ospf 1 Router(config-router)# network 10.0.0.1 0.0.0.0 area 0 Router(config-router)# exit Router(config)# router bgp 65001 Router(config-router)# bgp router-id 10.0.0.1 Router(config-router)# neighbor 10.0.0.2 remote-as 65001 Router(config-router)# neighbor 10.0.0.2 update-source loopback 0 Router(config-router)# neighbor 10.0.0.2 next-hop-self Router(config-router)# end
Verify: Use 'show ip bgp summary' to verify the BGP session state is established. Expected output: 'Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 10.0.0.2 4 65001 1234 1234 5 0 0 00:12:34 10'
Watch out: If the IGP does not include the loopback networks, the BGP session will fail because the neighbor IP is unreachable. Ensure the loopback networks are advertised in the IGP or use static routes.
Troubleshooting with This Command
When troubleshooting loopback interfaces, the first step is to verify the interface status using 'show ip interface brief'. A healthy loopback interface will show 'up' and 'up' in the Status and Protocol columns. If the interface is administratively down, use 'no shutdown' in interface configuration mode.
If the interface is down/down, it may indicate a software issue or that the interface was deleted. Use 'show running-config interface loopback [number]' to verify the configuration. A common symptom is that the loopback IP is not reachable from other routers.
This can be diagnosed with 'ping' from the router itself and from remote routers. If the ping fails, check routing tables with 'show ip route' to see if the loopback network is present. For OSPF, use 'show ip ospf interface loopback [number]' to verify the interface is participating in OSPF and the network type (loopback interfaces are treated as stub networks by default).
For BGP, use 'show ip bgp neighbors [ip]' to check the session state; if it's idle or active, verify that the update-source is correctly set and that the IGP is advertising the loopback. Another diagnostic flow: if a loopback interface is used for management, test telnet/SSH to the loopback IP. If it fails, check access-lists and VTY lines.
Use 'debug ip packet' cautiously to see if packets are being dropped. Correlate with 'show ip interface' to see if the interface is up and has an IP. Also check for duplicate IP addresses using 'show ip arp' or 'show ip interface brief | include [ip]'.
In summary, loopback troubleshooting focuses on interface state, IP configuration, routing protocol participation, and reachability.
CCNA Exam Tips
CCNA exam tip: Loopback interfaces are always up/up unless manually shut down, making them ideal for router IDs and management.
CCNA exam tip: OSPF and EIGRP automatically use the highest IP on a loopback as the router ID; if no loopback exists, they use the highest IP on a physical interface.
CCNA exam tip: A /32 mask is standard for loopback interfaces to conserve IP addresses and simplify routing.
CCNA exam tip: You can create up to 2^32 - 1 loopback interfaces (0 to 4294967295) on Cisco IOS.
Common Mistakes
Mistake: Forgetting to assign an IP address to the loopback, leaving it unnumbered and unusable for routing protocols.
Mistake: Using a subnet mask other than /32, which can cause routing issues because loopbacks are point-to-point virtual interfaces.
Mistake: Shutting down a loopback interface with 'shutdown' command, which makes it down/down and unusable for router ID selection.
interface loopback [number] vs show ip interface brief
These two commands are often considered together because both involve interfaces, but one is for creating a logical interface used for router identification and stability, while the other is a diagnostic command to view the operational status of all interfaces. They complement each other in network configuration and monitoring.
| Aspect | interface loopback [number] | show ip interface brief |
|---|---|---|
| Purpose | Create virtual loopback interface | Display interface status summary |
| Scope | Single interface creation | All interfaces on device |
| Configuration mode | Global configuration mode | Privileged EXEC mode |
| Persistence | Saved to running-config (persistent) | Transient output, not saved |
| Typical use | Router ID, management, testing | Quick health check, troubleshooting |
Use interface loopback [number] when you need a stable, always-up virtual interface for router ID, management reachability, or testing without physical hardware.
Use show ip interface brief when you need a quick overview of all interface IP addresses and their operational status for troubleshooting or inventory.
Platform Notes
In IOS-XE, the `interface loopback [number]` command syntax is identical to classic IOS. However, IOS-XE uses a different underlying architecture, but the CLI behavior is consistent. In NX-OS, the equivalent command is `interface loopback [number]` as well, but NX-OS uses a different configuration mode (config-if) and supports additional parameters like 'ip address' with secondary addresses.
NX-OS also allows loopback interfaces to be used for VRF. In ASA, loopback interfaces are not supported; instead, use a management interface or a subinterface. For IOS-XR, the command is `interface Loopback [number]` (capital L) and the configuration is done in XR config mode.
The loopback interface in IOS-XR also supports IPv6 and MPLS. Differences between IOS versions: in older IOS 12.x, loopback interfaces default to 'no ip redirects' and 'no ip unreachables', while newer versions may have different defaults. In IOS 15.x and 16.x, the behavior is largely the same.
Always check the specific IOS version documentation for any minor syntax changes. For example, in some versions, you may need to explicitly set 'ip ospf network point-to-point' if you want OSPF to advertise the loopback as a /32 host route, but by default it is advertised as a stub network.
Related Commands
show ip eigrp neighbors
Displays all EIGRP neighbours with their addresses, interfaces, hold time, uptime, SRTT (smooth round-trip time), RTO, queue count, and sequence numbers.
show ip interface brief
Displays a one-line summary of all interfaces showing the IP address assigned, operational status (up/down), and line protocol status. The fastest way to get a device health overview.
show ip ospf
Displays general information about OSPF routing process, including router ID, areas, and LSDB statistics, used to verify OSPF configuration and operational status.
Practice for the CCNA 200-301
Test your knowledge with practice questions covering all CCNA 200-301 exam domains.
Practice CCNA 200-301 Questions