Pedro sent me a question,
Thanks Pedro for the question.
Pedro asked, what is the purpose of the loopback interfaces?
Now if you do a search in google you'll find all kinds of answers including that the loopback interface
allows you to test connectivity to the 127 001 IP address.
Now that may be true on a PC but on a Cisco device a loopback interface has an entirely different
meaning. In this topology
I've got three routers, router 1, router 2 and router 3 configured with this IP addresses.
On router 2, show IP interface brief shows us that the router has IP addresses configured on the gigabit
interfaces. So gigabit 00 01 and 02 have IP addresses.
Now in this example, these are virtual routers but if they were physical routers and a cable got disconnected
or got cut or broken in some way the interface would go down.
The difference between a physical interface and a loopback interface, is a loopback interface is a logical
interface on a router and you can create many of these.
So notice as soon as I create that logical interface the interfaces come up.
I can then give that interface an IP address such as this.
Notice it's a slash 32 IP address.
In other words, this is the only IP address on that interface.
A loopback interface is a logical interface on a router that won't go down unless you manually shut
the interface down.
It typically only has one IP address but you could configure multiple IP addresses on that interface
if you wanted to.
The first advantage of a loopback interface is the interface doesn't go down unless you explicitly
shut it down.
So it's not like there's a cable that can be unplugged and then interface goes down.
Now, why is that important when you telnet to a router, so let's say I'll telnet from router 1 to router
2.
I could telnet to one of the gigabit interfaces on the router so telnet 10.1.1.2, notice
I can log in.
So I'm now connected to router 2, I'll go back to router 1
and then I'll telnet to the second IP address 10 122.
Now that's fine,
but firstly you need to remember which IP address is configured on which router
and secondly if for some reason an interface went down so let's say the cable was disconnected rather
than me shutting it down manually here you would have a problem telnetting back to that IP address 10
112 because the interface has gone down.
However, if you have the loopback IP address configured on the router and you advertise that loopback
through a routing protocol such as OSPF, you can telnet to that loopback using this network or
this network.
So if one of the interfaces goes down it's not a problem because you can still reach the loopback interface.
So at the moment on router 1, we can't ping the loopback of router 2 because it's not advertised
in a routing protocol.
So what I'll do here is enable EIGRP
and I'll do something similar here
so
enable EIGRP in all interfaces and let's do the same thing
on router 3.
Now once the neighbor relationships have been established which I have done in this example, so show
IP EIGRP neighbors, there's our neighbor relationship, router 1 can ping the loopback of router 2.
So now I can telnet to the loopback of router 2 even though the WAN interface is down, notice gigabit 00
is currently down.
So by the same token, if we brought up that gigabit 00 interface but then shut gigabit 02
my telnet session still continues.
So I notice the telnet session stayed up that won't always happen in the real world.
It depends how long the connection takes to establish but notice show IP interface brief.
I'm still able to telnet to the loopback of router 2 from router 1 because the telnet traffic is
using the alternate route. So it doesn't matter if interfaces go down or come up as long as I've got
one route between router 1 and router 2.
I can connect to the loopback and manage the router through the loopback interface.
It's also a lot easier if you use a separate subnet for your management network.
In this example, I'm just gonna keep it simple and create loopbacks with IP addresses,
Quadruple 1, Quadruple 2 and Quadruple 3.
So I'll simply create an IP address on router 1 with the loopback address and I'll do the same on router 3
on router 1 show IP route.
We have two routes to get to the loop of router
2 and two routes to get to the loopback of router 3.
So ping quadruple 3, telnet quadruple 3, telnet is not working.
Let's have a look.
So show run pipe begin VTY.
Notice I've got transport input none, line VTY 04, transport input and I'll just say all, telnet
again.
We can log in to router 3.
So from a management point of view, it's a lot easier to use loopbacks.
Now you might not wanna do it the way I've done it here in the real world.
You might have a separate network that you use for management.
So in this example I'll just use 192 network
and actually what I'll do is I'll create a separate loopback.
So I'll put this back to quadruple 2 and create a additional loopback for 192 168 1.2.
So I could do something like this to make it consistent.
So use interface loopback 192 it's always good practice to keep it simple.
So use the same loopback number.
Don't do what I've done here.
Try and keep them consistent.
So let's change that
no interface.
Loopback 1, interface loopback 192. Notice however it's very easy to create loopback interfaces
just create as many as you like
there are normally some kind of limitation on the router.
But notice the numbers that we could use here
you could use really long numbers if you wanted to but in this example I'll just keep it simple and
use 192.
So show IP route,
we've now learnt the routes of the loopbacks and now all I need to remember is that when I telnet to
router 2 it's 192 168 1 dot and the router which is dot 2. When I wanna telnet to router 3
it's 192 168 1 dot router 3, so telnet 192 168 1.3
and I can log in.
So that's the first reason Pedro for using loopback interfaces. I'll cover another reason in a separate
blog.