Hello i have one doubt

1.if there are four protocols connections for instance rip,OSPF,static,and direct which routing protocol would be used , although it will take one with lowest administrative distance. what if i just want only OSPF as a routing protocol not static,rip or any other routing protocols to be used.

2.what command we can use to change administrative distance?

  • How you change the AD depends on the device model. I'm not sure I completely understand the question. If you don't want to use RIP, then you can simply disable RIP. If you don't want static routing, you can delete the static routes. – Ron Maupin Jun 22 '16 at 13:20
  • Agree with Ron - please specifiy device model for more precise answers. – waza-ari Jun 22 '16 at 13:29
  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you could provide and accept your own answer. – Ron Maupin Aug 14 '17 at 18:16

According to your first question, the answer is not as easy as you might think.

When there are multiple routing protocols configured, all of them will run and form adjacencies to their next hop routers and exchange routing information. Most if not each routing protocol has a routing protocol specific information database, containing routes exchanged by this routing protocol. On cisco gear you can view them for example with sh ip ospf database or sh ip rip database.

Now, the router has to decide which routes are placed in his actual routing information base (also called RIB or routing table). Here, the most important factor is the "precision" of a route. That is: the higher the prefix length is, the more exact is the route and the more preferred. Only if there are two identical routes, that is same subnet address and same subnet mask or prefix length, the administrative distance comes into play.

Suppose the following example (note that ADs are default values from Cisco):

  • learned by OSPF, AD is 110
  • learned by RIP, AD is 120
  • directly connected, AD is 0
  • static route, AD is 1

In this example, the first route learned by OSPF will be placed in the routing table. As the second one is more specific (25 bit prefix instead of 24) it is also added to the routing table. Note that while the second route is included in the first one, they are not equal due to the different prefix length. The third and fourth routes are identical, but the AD of directly connected routes is always 0 and hence this route is preferred.

So basically you can influence routing decision in at least three ways:

  • In each routing protocol, you can tweak metrics
  • Change the AD of routing protocols
  • Advertise more specific routes which are always preferred.

Changing the AD

For Cisco gear, you can change the AD of routing protocols like this:

! static routes - the last optional value (50) is the AD
ip route 50

! OSPF - can be changed in the OSPF routing process, is slightly more complicated
! The generic command is: distance <AD> <source addr> <wildcard-mask> <ACL>
! AD is configured per source router, and an additional ACL is required
! To change AD of all routes to 85 (instead of default 110)
access-list 10 permit any

router ospf 1
    distance 85 10

! For RIP, the command is:
! distance admin-distance [ prefix prefix-length | prefix mask ]
! The command needs to be entered inside the routing process, where the last 
! elements are not required but can be used to conditionally change the distance

router rip
    distance 50

Beware that you can never change the AD to be lower than or equal to 0, hence routing protocols cannot compete with directly connected routes using the administrative distance. If you need a routing protocol to override directly connected routes you should ask yourself why you need the direct connection. Technically however you could advertise more specific routes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.