Loopback interface
Redirect page
Redirect to:
Loopback interfaces are logical interfaces, which means they are not real router interfaces. They can be used for diagnostic purposes as well as OSPF configuration.
OSPF and Loopback Interfaces Configuring loopback interfaces when using the OSPF routing protocol is important, and Cisco suggests using them whenever you configure OSPF on a router. Loopback interfaces are logical interfaces, which are virtual, software-only interfaces; they are not real router interfaces. Using loopback interfaces with your OSPF configuration ensures that an interface is always active for OSPF processes. They can be used for diagnostic purposes as well as OSPF configuration. The reason you want to configure a loopback interface on a router is because if you don’t, the highest IP address on a router will become that router’s RID. The RID is used to advertise the routes as well as elect the DR and BDR.
By default, OSPF uses the highest IP address on any active interface at the moment of OSPF startup. However, this can be overridden by a logical interface. The highest IP address of any logical interface will always become a router’s RID.
In the following sections, you will see how to configure loopback interfaces and how to verify loopback addresses and RIDs.
Configuring Loopback Interfaces Configuring loopback interfaces rocks mostly because it’s the easiest part of OSPF configuration, and we all need a break about now—right? So hang on—we’re in the home stretch! First, let’s see what the RID is on the Corp router with the show ip ospf command: Corp#sh ip ospf Routing Process "ospf 132" with ID 10.1.5.1 [output cut] We can see that the RID is 10.1.5.1, or the serial 0/2/0 interface of the router. So let’s configure a loopback interface using a completely different IP addressing scheme: Corp(config)#int loopback 0
- Mar 22 01:23:14.206: %LINEPROTO-5-UPDOWN: Line protocol on Interface
Loopback0, changed state to up Corp(config-if)#ip address 172.16.10.1 255.255.255.255 The IP scheme really doesn’t matter here, but each router has to be in a separate subnet. By using the /32 mask, we can use any IP address we want as long as the addresses are never the same on any two routers. Let’s configure the other routers: R1#config t R1(config)#int loopback 0
- Mar 22 01:25:11.206: %LINEPROTO-5-UPDOWN: Line protocol on Interface
Loopback0, changed state to up R1(config-if)#ip address 172.16.10.2 255.255.255.255 Here’s the configuration of the loopback interface on R2: R2#config t R2(config)#int loopback 0
- Mar 22 02:21:59.686: %LINEPROTO-5-UPDOWN: Line protocol on Interface
Loopback0, changed state to up R2(config-if)#ip address 172.16.10.3 255.255.255.255 Here’s the configuration of the loopback interface on R3: R3#config t R3(config)#int loopback 0
- Mar 22 02:01:49.686: %LINEPROTO-5-UPDOWN: Line protocol on Interface
Loopback0, changed state to up R3(config-if)#ip address 172.16.10.4 255.255.255.255
Take a look at that—it worked! We changed the RID without reloading the router! But wait—remember, we didn’t set a loopback (logical interface) yet. So let’s try that now—let’s set a logical interface IP address, reload the router, and see if the loopback interface overrides the router-id command we just used: 871W(config-router)#int lo0 871W(config-if)#ip address 172.16.10.6 255.255.255.255 871W(config-if)#^Z 871W#reload System configuration has been modified. Save? [yes/no]: y Building configuration... 871W#sh ip ospf Routing Process "ospf 1" with ID 172.16.10.5 Well, there’s our answer. A logical (loopback) interface will not override the router-id command, and we don’t have to reboot the router to make it take effect as the RID. The only thing left now is to decide whether you want to advertise the loopback interfaces under OSPF. There are pros and cons to using an address that won’t be advertised versus using an address that will be. Using an unadvertised address saves on real IP address space, but the address won’t appear in the OSPF table, which means you can’t ping it. So basically, what you’re faced with here is a choice that equals a trade-off between the ease of debugging the network and conservation of address space—what to do? A really tight strategy is to use a private IP address scheme as I did. Do this, and all will be well! OSPF Interface Priorities Another way to configure DRs and BDRs in OSPF is to “fix” elections instead of using loopback interfaces. We can do this by configuring interfaces on our router to gain a better priority over another router when elections occur. In other words, we can use priorities instead of logical addresses to force a certain router to become the DR or BDR in a network. Let’s use Figure 7.6 as an example. Looking at Figure 7.6, what options would you use to ensure that the R2 router will be elected the designated router (DR) for the LAN (broadcast multi-access) segment? The first thing you’d need to do is determine what the RID is of each router and which router is the default DR for the 172.16.1.0 LAN. At this point, we can see that R3 will be the DR by default because it has the highest RID of 192.168.11.254. That gives us three options to ensure that R2 will be elected the DR for the LAN segment 172.16.1.0/24: � Configure the priority value of the Fa0/0 interface of the R2 router to a higher value than any other interface on the Ethernet network. � Configure a loopback interface on the R2 with an IP address higher than any IP address on the other routers. � Change the priority value of the Fa0/0 interface of R1 and R3 to zero.