You are on page 1of 6

10/18/2015

RouteSelectioninCiscoRoutersCisco

RouteSelectioninCiscoRouters
DocumentID: 8651 Updated: Jan02,2008

Contents
Introduction
Prerequisites
Requirements
ComponentsUsed
Conventions

ProcessesInvolved
BuildingtheRoutingTable
BackupRoutes
AdjustingtheAdministrativeDistance
HowMetricsDeterminetheRouteSelectionProcess
PrefixLengths

MakingForwardingDecisions
IPClassless

Summary
RelatedInformation

Introduction
OneoftheintriguingaspectsofCiscorouters,especiallyforthosenewtorouting,ishowtherouterchooses
whichrouteisthebestamongthosepresentedbyroutingprotocols,manualconfiguration,andvariousother
means.Whilerouteselectionismuchsimplerthanyoumightimagine,tounderstanditcompletelyrequiressome
knowledgeaboutthewayCiscorouterswork.

Prerequisites
Requirements
Therearenospecificprerequisitesforthisdocument.

ComponentsUsed
Thisdocumentisnotrestrictedtospecificsoftwareandhardwareversions.

Conventions
Formoreinformationondocumentconventions,seetheCiscoTechnicalTipsConventions.

http://www.cisco.com/c/en/us/support/docs/ip/enhancedinteriorgatewayroutingprotocoleigrp/865121.html

1/6

10/18/2015

RouteSelectioninCiscoRoutersCisco

ProcessesInvolved
TherearethreeprocessesinvolvedinbuildingandmaintainingtheroutingtableinaCiscorouter:
Variousroutingprocesses,whichactuallyrunanetwork(orrouting)protocol,suchasEnhancedInterior
GatewayRoutingProtocol(EIGRP),BorderGatewayProtocol(BGP),IntermediateSystemtoIntermediate
System(ISIS),andOpenShortestPathFirst(OSPF).
Theroutingtableitself,whichacceptsinformationfromtheroutingprocessesandalsorepliestorequestsfor
informationfromtheforwardingprocess.
Theforwardingprocess,whichrequestsinformationfromtheroutingtabletomakeapacketforwarding
decision.
Let'sexaminetheinteractionbetweentheroutingprotocolsandtheroutingtabletounderstandhowtherouting
tableisbuilt.

BuildingtheRoutingTable
Themainconsiderationswhilebuildingtheroutingtableare:
AdministrativedistanceThisisthemeasureoftrustworthinessofthesourceoftheroute.Ifarouterlearns
aboutadestinationfrommorethanoneroutingprotocol,administrativedistanceiscomparedandthe
preferenceisgiventotherouteswithloweradministrativedistance.Inotherwords,itisthebelievabilityofthe
sourceoftheroute.
MetricsThisisameasureusedbytheroutingprotocoltocalculatethebestpathtoagivendestination,ifit
learnsmultiplepathstothesamedestination.Eachroutingprotocolusesadifferentmetric.
Prefixlength
Aseachroutingprocessreceivesupdatesandotherinformation,itchoosesthebestpathtoanygivendestination
andattemptstoinstallthispathintotheroutingtable.Forinstance,ifEIGRPlearnsofapathtoward10.1.1.0/24,
anddecidesthisparticularpathisthebestEIGRPpathtothisdestination,ittriestoinstallthepathithaslearned
intotheroutingtable.
Therouterdecideswhetherornottoinstalltheroutespresentedbytheroutingprocessesbasedonthe
administrativedistanceoftherouteinquestion.Ifthispathhasthelowestadministrativedistancetothis
destination(whencomparedtotheotherroutesinthetable),it'sinstalledintheroutingtable.Ifthisrouteisn'tthe
routewiththebestadministrativedistance,thentherouteisrejected.
Tounderstandthisbetter,let'slookatanexample.Assumearouterhasfourroutingprocessesrunning:EIGRP,
OSPF,RIP,andIGRP.Now,allfouroftheseprocesseshavelearnedofvariousroutestothe192.168.24.0/24
network,andeachhaschosenitsbestpathtothatnetworkthroughitsinternalmetricsandprocesses.
Eachofthesefourprocessesattemptstoinstalltheirroutetoward192.168.24.0/24intotheroutingtable.The
routingprocessesareeachassignedanadministrativedistance,whichisusedtodecidewhichroutetoinstall.

DefaultAdministrativeDistances
Connected

Static

eBGP

20

EIGRP(internal)

90

IGRP

100

OSPF

110

ISIS

115

RIP

120

EIGRP(external)

170

iBGP
200
http://www.cisco.com/c/en/us/support/docs/ip/enhancedinteriorgatewayroutingprotocoleigrp/865121.html

2/6

10/18/2015

RouteSelectioninCiscoRoutersCisco

iBGP

200

EIGRPsummaryroute

SincetheinternalEIGRProutehasthebestadministrativedistance(thesmallertheadministrativedistance,the
higherthepreference),it'sinstalledintheroutingtable.

BackupRoutes
Whatdotheotherprotocols,RIP,IGRP,andOSPF,dowiththeroutesthatweren'tinstalled?Whatifthemost
preferredroute,learnedfromEIGRP,fails?CiscoIOSSoftwareusestwoapproachestosolvethisproblem:The
firstistohaveeachroutingprocessattempttoinstallitsbestroutesperiodically.Ifthemostpreferredroutefails,
thenextbestroute(accordingtoadministrativedistance)succeedsonthenextattempt.Theothersolutionisfor
theroutingprotocolthatfailedtoinstallitsrouteinthetabletohangontotheroute,andtelltheroutingtable
processtoreportifthebestpathfails.
Forprotocolsthatdon'thavetheirownroutinginformationtables,suchasIGRP,thefirstmethodisused.Every
timeIGRPreceivesanupdateaboutaroute,itattemptstoinstalltheupdatedinformationintheroutingtable.If
there'salreadyaroutetothissamedestinationintheroutingtable,theinstallationattemptfails.
Forprotocolsthathavetheirowndatabaseofroutinginformation,suchasEIGRP,ISIS,OSPF,BGP,andRIP,a
backuprouteisregisteredwhentheinitialattempttoinstalltheroutefails.Iftherouteinstalledintheroutingtable
failsforsomereason,theroutingtablemaintenanceprocesscallseachroutingprotocolprocessthathas
registeredabackuproute,andasksthemtoreinstalltherouteintheroutingtable.Iftherearemultipleprotocols
withregisteredbackuproutes,thepreferredrouteischosenbasedonadministrativedistance.

AdjustingtheAdministrativeDistance
Thedefaultadministrativedistancemightnotalwaysberightforyournetworkyoumaywanttoadjustthemso
thatRIProutesarepreferredoverIGRProutes,forinstance.Beforeexplaininghowtoadjusttheadministrative
distances,weneedtolookattheimplicationsofchangingtheadministrativedistance.
Changingtheadministrativedistanceonroutingprotocolscanbeverydangerous!Changingthedefaultdistances
canactuallyleadtoroutingloopsandotherodditiesinyournetwork.Werecommendyouchangeadministrative
distancewithcaution,andonlyafteryouhavethoughtthroughwhatyouwanttoachieve,andallthe
consequencesofyouractions.
Forentireprotocols,changingthedistanceisrelativelyeasysimplyconfigurethedistanceusingthedistance
commandintheroutingprocesssubconfigurationmode.Youcanalsochangethedistanceforrouteslearned
fromonesourceonlyinsomeprotocols,andyoucanchangethedistanceonjustsomeroutes.Formore
information,refertoAdjustAdministrativeDistanceforRouteSelectioninCiscoIOSRoutersConfiguration
Example.
Forstaticroutes,youcanchangethedistanceofeachroutebyenteringadistanceaftertheiproutecommand:
iproutenetworksubnetmasknexthopdistance
Youcan'tchangetheadministrativedistanceforallthestaticroutesatonce.

HowMetricsDeterminetheRouteSelectionProcess
Routesarechosenandbuiltintheroutingtablebasedontheroutingprotocol'sadministrativedistance.The
routeslearnedfromtheroutingprotocolwiththelowestadministrativedistanceareinstalledintheroutingtable.If
therearemultiplepathstothesamedestinationfromasingleroutingprotocol,thenthemultiplepathswouldhave
thesameadministrativedistanceandthebestpathisselectedbasedonthemetrics.Metricsarevalues
associatedwithspecificroutes,rankingthemfrommostpreferredtoleastpreferred.Theparametersusedto
determinethemetricsdifferfordifferentroutingprotocols.Thepathwiththelowestmetricisselectedasthe
optimalpathandinstalledintheroutingtable.Iftherearemultiplepathstothesamedestinationwithequal
metrics,loadbalancingisdoneontheseequalcostpaths.FormoreinformationonloadbalancingseeHowDoes
LoadBalancingWork?

PrefixLengths
http://www.cisco.com/c/en/us/support/docs/ip/enhancedinteriorgatewayroutingprotocoleigrp/865121.html

3/6

10/18/2015

RouteSelectioninCiscoRoutersCisco

Let'slookatanotherscenariotoseehowtherouterhandlesanothercommonsituation:varyingprefixlengths.
Assume,again,thatarouterhasfourroutingprocessesrunningonit,andeachprocesshasreceivedthese
routes:
EIGRP(internal):192.168.32.0/26
RIP:192.168.32.0/24
OSPF:192.168.32.0/19
Whichoftheserouteswillbeinstalledintheroutingtable?SinceEIGRPinternalrouteshavethebest
administrativedistance,it'stemptingtoassumethefirstonewillbeinstalled.However,sinceeachofthese
routeshasadifferentprefixlength(subnetmask),they'reconsidereddifferentdestinations,andtheywillallbe
installedintheroutingtable.
Let'sseehowtheforwardingengineusestheinformationfromtheroutingtabletomakeforwardingdecisions.

MakingForwardingDecisions
Let'slookatthethreerouteswejustinstalledintheroutingtable,andseehowtheylookontherouter.
router#showiproute
....
D192.168.32.0/26[90/25789217]via10.1.1.1
R192.168.32.0/24[120/4]via10.1.1.2
O192.168.32.0/19[110/229840]via10.1.1.3
....

Ifapacketarrivesonarouterinterfacedestinedfor192.168.32.1,whichroutewouldtherouterchoose?It
dependsontheprefixlength,orthenumberofbitssetinthesubnetmask.Longerprefixesarealwayspreferred
overshorteroneswhenforwardingapacket.
Inthiscase,apacketdestinedto192.168.32.1isdirectedtoward10.1.1.1,because192.168.32.1fallswithinthe
192.168.32.0/26network(192.168.32.0to192.168.32.63).Italsofallswithintheothertworoutesavailable,but
the192.168.32.0/26hasthelongestprefixwithintheroutingtable(26bitsverses24or19bits).
Likewise,ifapacketdestinedfor192.168.32.100arrivesononeoftherouter'sinterfaces,it'sforwardedto
10.1.1.2,because192.168.32.100doesn'tfallwithin192.168.32.0/26(192.168.32.0through192.168.32.63),butit
doesfallwithinthe192.168.32.0/24destination(192.168.32.0through192.168.32.255).Again,italsofallsintothe
rangecoveredby192.168.32.0/19,but192.168.32.0/24hasalongerprefixlength.

IPClassless
Wheretheipclasslessconfigurationcommandfallswithintheroutingandforwardingprocessesisoften
confusing.Inreality,IPclasslessonlyaffectstheoperationoftheforwardingprocessesinIOSitdoesn'taffect
thewaytheroutingtableisbuilt.IfIPclasslessisn'tconfigured(usingthenoipclasslesscommand),therouter
won'tforwardpacketstosupernets.Asanexample,let'sagainplacethreeroutesintheroutingtableandroute
packetsthroughtherouter.
Note:IfthesupernetordefaultrouteislearnedviaISISorOSPF,thenoipclasslessconfigurationcommandis
ignored.Inthiscase,packetswitchingbehaviorworksasthoughipclasslesswereconfigured.
router#showiproute
....
172.30.0.0/16isvariablysubnetted,2subnets,2masks
D172.30.32.0/20[90/4879540]via10.1.1.2
D172.30.32.0/24[90/25789217]via10.1.1.1
S*0.0.0.0/0[1/0]via10.1.1.3

Rememberingthatthe172.30.32.0/24networkincludestheaddresses172.30.32.0through172.30.32.255,and
the172.30.32.0/20networkincludestheaddresses172.30.32.0through172.30.47.255,wecanthentryswitching
threepacketsthroughthisroutingtableandseewhattheresultsare.
Apacketdestinedto172.30.32.1isforwardedto10.1.1.1,sincethisisthelongestprefixmatch.
http://www.cisco.com/c/en/us/support/docs/ip/enhancedinteriorgatewayroutingprotocoleigrp/865121.html

4/6

10/18/2015

RouteSelectioninCiscoRoutersCisco

Apacketdestinedto172.30.33.1isforwardedto10.1.1.2,sincethisisthelongestprefixmatch.
Apacketdestinedto192.168.10.1isforwardedto10.1.1.3sincethisnetworkdoesn'texistintheroutingtable,
thispacketisforwardedtothedefaultroute.
Apacketdestinedto172.30.254.1isdropped.
Thesurprisingansweroutofthesefouristhelastpacket,whichisdropped.It'sdroppedbecauseitsdestination,
172.30.254.1,iswithinaknownmajornetwork,172.30.0.0/16,buttherouterdoesn'tknowaboutthisparticular
subnetwithinthatmajornetwork.
Thisistheessenceofclassfulrouting:Ifonepartofamajornetworkisknown,butthesubnettowardwhichthe
packetisdestinedwithinthatmajornetworkisunknown,thepacketisdropped.
Themostconfusingaspectofthisruleisthattherouteronlyusesthedefaultrouteifthedestinationmajor
networkdoesn'texistintheroutingtableatall.
Thiscancauseproblemsinanetworkwherearemotesite,withoneconnectionbacktotherestofthenetwork,is
runningnoroutingprotocols,asillustrated.

Theremotesiterouterisconfiguredlikethis:
interfaceSerial0
ipaddress10.1.2.2255.255.255.0
!
interfaceEthernet0
ipaddress10.1.1.1255.255.255.0
!
iproute0.0.0.00.0.0.010.1.2.1
!
noipclassless

Withthisconfiguration,thehostsattheremotesitecanreachdestinationsontheInternet(throughthe10.x.x.x
cloud),butnotdestinationswithinthe10.x.x.xcloud,whichisthecorporatenetwork.Becausetheremoterouter
knowsaboutsomepartofthe10.0.0.0/8network,thetwodirectlyconnectedsubnets,andnoothersubnetof
10.x.x.x,itassumestheseothersubnetsdon'texistanddropsanypacketsdestinedforthem.Trafficdestinedto
theInternet,however,doesn'teverhaveadestinationinthe10.x.x.xrangeofaddresses,andistherefore
correctlyroutedthroughthedefaultroute.
Configuringipclasslessontheremoterouterresolvesthisproblembyallowingtheroutertoignoretheclassful
boundariesofthenetworksinitsroutingtableandsimplyroutetothelongestprefixmatchitcanfind.

Summary
Insummary,makingaforwardingdecisionactuallyconsistsofthreesetsofprocesses:theroutingprotocols,the
routingtable,andtheactualprocesswhichmakesaforwardingdecisionandswitchespackets.Thesethreesets
ofprocessesareillustrated,alongwiththeirrelationship,below.

http://www.cisco.com/c/en/us/support/docs/ip/enhancedinteriorgatewayroutingprotocoleigrp/865121.html

5/6

10/18/2015

RouteSelectioninCiscoRoutersCisco

Thelongestprefixmatchalwayswinsamongtheroutesactuallyinstalledintheroutingtable,whiletherouting
protocolwiththelowestadministrativedistancealwayswinswheninstallingroutesintotheroutingtable.

RelatedInformation
HowDoesLoadBalancingWork?
WhatisAdministrativeDistance?
EIGRPSupportPage
BGPSupportPage
IGRPSupportPage
IPRoutedProtocolsSupportPage
IPRoutingSupportPage
ISISSupportPage
OSPFSupportPage
RIPSupportPage
TechnicalSupportCiscoSystems

2015Ciscoand/oritsaffiliates.Allrightsreserved.

http://www.cisco.com/c/en/us/support/docs/ip/enhancedinteriorgatewayroutingprotocoleigrp/865121.html

6/6