Cisco Loopback Interfaces Tutorial

YouTube Cisco Loopback Interfaces

In this Cisco CCNA training tutorial, you’ll learn about loopback interfaces. A loopback interface is a logical interface and it allows you to assign an IP address to a router or a Layer 3 switch, which is not tied to a physical interface. Scroll down for the video and text tutorial.

Cisco Loopback Interfaces Video Tutorial

YouTube video

Abdulelah Fareed Alem

Abdulelah Fareed Alem

I passed my exam yesterday and now I’m officially CCNA certified. I couldn’t have achieved that without your amazing courses. I can’t thank you enough, the wealth of material and hands on lab exercises of each section in your courses is fantastic, it really helps solidify what has been learnt.

It was long journey and you were there with me Neil, I wouldn’t have done it without you.

Abdulelah Fareed Alem

Loopback interfaces don’t have any physical attributes that can fail, they never go down. Loopbacks are logical so it's impossible for them to physically be in the same subnet as other devices, so they're usually assigned /32 subnet mask as a standard to avoid wasting IP addresses.

YouTube Cisco Loopback Interfaces

Loopback Interface Uses

It's best practice to assign a loopback interface on all of your routers and Layer 3 switches. The loopback is commonly used for traffic that terminates on the router itself such as management traffic and also for other things like Voice Over IP, BGP, peering, et cetera.

 

Loopback provides redundancy if there are multiple paths to the router and it is also used to identify the router in OSPF because the loopback address is used as the router ID. In the OSPF section, you'll see routers being identified by their router ID which is the highest loopback address on that router.

The same loopback interface is usually used for multiple tasks. For example, if you need to send traffic to the router for management and BGP, one loopback interface and the same IP address is going to be used for everything.

 

Multiple loopbacks can also be configured. Though it's not common and not normally done, it can be configured in special use cases where an additional loopback is required.

Below, you'll see an example of why we're using a loopback. Let's say there’s a PC behind router R4 and it has an IP address of 10.1.2.10. We would want to connect to the router R1 in order to manage it.

There are two paths that we can use to get to R1 via R4:

  • Top path – if this goes down, we can't connect to the 10.0.0.1 IP address
  • Bottom path – if this goes down, we can't connect to the 10.0.0.3 IP address

 

Therefore, we're going to use a loopback so that we would still get a single IP address that we can use to connect to R1, even if one of those paths goes down.

 

We add an interface loopback 0 and we give it an IP address of 192.168.1.1/32. You can use any IP address you want for the loopback, and then advertise it in the routing protocol.

 

R4 will then learn the two paths that it can use to get to 192.168.1.1 and it will use whichever one has got the lowest costs or both if they've got equal costs. R4 will still be able to connect to 192.168.1.1 even if either path goes down.

This is useful for management and it is critical for other things like BGP and IP telephony. Let's say that we're sending IP telephony traffic from behind R4 to R1.

 

We want to make sure that it will always get there even if one of the paths goes down. Therefore, we won't direct it at a physical address in R1, which can go down. We will direct it at the logical address instead.

 

Even if one path goes down, the traffic is still going to get to the destination across the other path and that’s what loopback is for.

 

In the following lab activity, I'm going to put the loopback interface 192.168.1.1/32 on R1 and we'll see how R4 got the two paths to get there.

In this lab, EIGRP is running everywhere. On R4, I'll do a show ip route command and see that I've got an EIGRP route going out FastEthernet 2/0 which is via R5. I've also got other EIGRP routes going out FastEthernet 0/0, which is via R3.

 

I want to have two different paths available with one IP address so that I can use those two different paths to get to R1. On R1, I’ll do a show ip interface brief command and see that I've got my physical interfaces configured there right now.

 

I'll go to the global configuration mode in R1 and configure the loopback interface. The command in creating loopback interface is:

interface loopback 0

The number can be anything that you want to use, in this lab, I used zero. That creates the interface and it takes you to the configuration mode for the interface as well.

 

Notice that the interface goes up immediately because it is a loopback. There is NO need to perform a no shutdown command.

 

The IP address must be configured on the interface. So, I’ll use:

ip address 192.168.1.1 255.255.255.255

Following the best practice, I used the /32 as the subnet mask. I also need to make sure that it's being advertised in my routing protocol so I'll execute the command:

do show run | sec eigrp

This is to check the current EIGRP configuration. I can see that I'm using EIGRP 100 and it's just network 10.0.0.0 that is included in there right now. Therefore, to include the loopback address, I will enter the commands:

router eigrp 100

network 192.168.1.1 0.0.0.0

The 0.0.0.0 is the wildcard mask which is the inverse of the subnet mask.

 

Going back to R4, EIGRP converges pretty quickly. Let's see if the route is there using the show ip route command. So, we’ve got a route going to 192.168.1.1. There are two paths, but one of them has got a better cost. That's why only the FastEthernet 0/0 path is in the routing table right now.

 

I can ping 192.168.1.1 and if I enter the command trace 192.168.1.1, I can see that it's passing along the top path with the next hop of 10.1.1.2 which was out interface FastEthernet 0/0. Let's check that I can failover and could use the loopback. On R4, I’ll go to interface FastEthernet 0/0 then I'm going to shut down that interface. The first path is not going to be available anymore.

 

If I do a show ip route now, I can see the 192.168.1.1 in the routing table from EIGRP. However, it failed over to the other path, so it uses the FastEthernet 2/0. I can still ping 192.168.1.1 and if I traceroute to it, I'm going to see it going down the bottom path via R5.

 

That's the way we want to use loopbacks. We can get to our routers no matter what path we've got available and still using the same IP address.

Cisco Loopback Interfaces Configuration Example

This configuration example is taken from my free ‘Cisco CCNA Lab Guide’ which includes over 350 pages of lab exercises and full instructions to set up the lab for free on your laptop.

Click here to download your free Cisco CCNA Lab Guide.

  1. Configure loopback interface 0 on each router. Assign the IP address 192.168.0.x/32, where ‘x’ is the router number (for example 192.168.0.3/32 on R3.)

R1(config)#interface loopback0

R1(config-if)#ip address 192.168.0.1 255.255.255.255

R2(config)#interface loopback0

R2(config-if)#ip address 192.168.0.2 255.255.255.255

R3(config)#interface loopback0

R3(config-if)#ip address 192.168.0.3 255.255.255.255

R4(config)#interface loopback0

R4(config-if)#ip address 192.168.0.4 255.255.255.255

R5(config)#interface loopback0

R5(config-if)#ip address 192.168.0.5 255.255.255.255

2. Is there connectivity to the loopback interfaces from the PCs? Why or why not?

There is no connectivity from the PCs to the loopback interfaces because they are not in the routing tables of the routers (apart from the local loopback interface on each router). The loopback interfaces are not in the routing tables because they are in the 192.168.0.0/24 range which has not been included in the routing protocol.

R1#sh ip route

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP

D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

E1 - OSPF external type 1, E2 - OSPF external type 2

i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

ia - IS-IS inter area, * - candidate default, U - per-user static route

o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP

+ - replicated route, % - next hop override

Gateway of last resort is not set

10.0.0.0/8 is variably subnetted, 13 subnets, 3 masks

C 10.0.0.0/24 is directly connected, FastEthernet0/0

L 10.0.0.1/32 is directly connected, FastEthernet0/0

C 10.0.1.0/24 is directly connected, FastEthernet0/1

L 10.0.1.1/32 is directly connected, FastEthernet0/1

C 10.0.2.0/24 is directly connected, FastEthernet1/0

L 10.0.2.1/32 is directly connected, FastEthernet1/0

C 10.0.3.0/24 is directly connected, FastEthernet1/1

L 10.0.3.1/32 is directly connected, FastEthernet1/1

S 10.1.0.0/16 [95/0] via 10.0.3.2

D 10.1.0.0/24 [90/30720] via 10.0.0.2, 00:03:01, FastEthernet0/0

D 10.1.1.0/24 [90/33280] via 10.0.0.2, 00:03:01, FastEthernet0/0

D 10.1.2.0/24 [90/35840] via 10.0.0.2, 00:03:01, FastEthernet0/0

D 10.1.3.0/24 [90/261120] via 10.0.3.2, 00:02:32, FastEthernet1/1

192.168.0.0/32 is subnetted, 1 subnets

C 192.168.0.1/32 is directly connected, Loopback0

3. Enter the commands below on each router to include the loopback interfaces in EIGRP.

R1(config)#router eigrp 100

R1(config-router)#network 192.168.0.0 0.0.0.255

4. Verify the loopback interfaces are in the routing table on R1.

R1#sh ip route

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP

D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

E1 - OSPF external type 1, E2 - OSPF external type 2

i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

ia - IS-IS inter area, * - candidate default, U - per-user static route

o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP

+ - replicated route, % - next hop override

Gateway of last resort is not set

10.0.0.0/8 is variably subnetted, 13 subnets, 3 masks

C 10.0.0.0/24 is directly connected, FastEthernet0/0

L 10.0.0.1/32 is directly connected, FastEthernet0/0

C 10.0.1.0/24 is directly connected, FastEthernet0/1

L 10.0.1.1/32 is directly connected, FastEthernet0/1

C 10.0.2.0/24 is directly connected, FastEthernet1/0

L 10.0.2.1/32 is directly connected, FastEthernet1/0

C 10.0.3.0/24 is directly connected, FastEthernet1/1

L 10.0.3.1/32 is directly connected, FastEthernet1/1

S 10.1.0.0/16 [95/0] via 10.0.3.2

D 10.1.0.0/24 [90/30720] via 10.0.0.2, 00:04:53, FastEthernet0/0

D 10.1.1.0/24 [90/33280] via 10.0.0.2, 00:04:53, FastEthernet0/0

D 10.1.2.0/24 [90/35840] via 10.0.0.2, 00:04:53, FastEthernet0/0

D 10.1.3.0/24 [90/261120] via 10.0.3.2, 00:04:24, FastEthernet1/1

192.168.0.0/32 is subnetted, 5 subnets

C 192.168.0.1/32 is directly connected, Loopback0

D 192.168.0.2/32 [90/156160] via 10.0.0.2, 00:00:26, FastEthernet0/0

D 192.168.0.3/32 [90/158720] via 10.0.0.2, 00:00:23, FastEthernet0/0

D 192.168.0.4/32 [90/161280] via 10.0.0.2, 00:00:20, FastEthernet0/0

D 192.168.0.5/32 [90/386560] via 10.0.3.2, 00:00:17, FastEthernet1/1

5. Verify connectivity from PC1 to the loopback interface on R5.

C:\>ping 192.168.0.5

Pinging 192.168.0.5 with 32 bytes of data:

Reply from 192.168.0.5: bytes=32 time<1ms TTL=254

Reply from 192.168.0.5: bytes=32 time=1ms TTL=254

Reply from 192.168.0.5: bytes=32 time<1ms TTL=254

Reply from 192.168.0.5: bytes=32 time=4ms TTL=254

Ping statistics for 192.168.0.5:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 0ms, Maximum = 4ms, Average = 1ms

Additional Resources

Interface Loopback: https://www.cisco.com/c/m/en_us/techdoc/dc/reference/cli/nxos/commands/l2/interface-loopback.html

What is Loopback Interface in Cisco Router and How to Configure: http://www.certiology.com/tutorials/ccna-tutorial/what-is-loopback-interface-in-cisco-router-and-how-to-configure.html

Understanding the Loopback Interface: https://www.juniper.net/documentation/en_US/junos/topics/concept/interface-security-loopback-understanding.html

Want to practice Cisco CCNA technologies on your laptop? Download my complete 350-page Cisco CCNA Lab Guide for free.

 

Click Here to get my Cisco CCNA Gold Bootcamp, the highest rated CCNA course online with a 4.8 star rating from over 20,000 public reviews.

 

Libby Teofilo

Text by Libby Teofilo, Technical Writer at www.flackbox.com

With a mission to spread network awareness through writing, Libby consistently immerses herself into the unrelenting process of knowledge acquisition and dissemination. If not engrossed in technology, you might see her with a book in one hand and a coffee in the other.