0% found this document useful (0 votes)
122 views

Understanding The IP Routing Table

All computers running any version of Windows and the supplied TCP/IP protocol use an IP routing table. The IP routing table stores information about destinations and how they can be reached. There are a series of default entries based on the configuration of the node. You can add entries with TCP/IP utilities or entries can be added dynamically through interaction with routers.

Uploaded by

Ty Whalin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
0% found this document useful (0 votes)
122 views

Understanding The IP Routing Table

All computers running any version of Windows and the supplied TCP/IP protocol use an IP routing table. The IP routing table stores information about destinations and how they can be reached. There are a series of default entries based on the configuration of the node. You can add entries with TCP/IP utilities or entries can be added dynamically through interaction with routers.

Uploaded by

Ty Whalin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
You are on page 1/ 5

TheCableGuyDecember2001

UnderstandingtheIPRoutingTable

ByTheCableGuy
Foralistandadditionalinformationonall
TheCableGuy
columns,
clickhere
.

TopicsonthisPage

ContentsofanIPRoutingTable
RouteDeterminationProcess

NextHopAddressandInterfaceDetermination

Process
ForMoreInformation

AllcomputersrunninganyversionofWindowsandthesuppliedTCP/IPprotocoluseanIProutingtable.TheIP
routingtablestoresinformationaboutdestinationsandhowtheycanbereached.Thereareaseriesofdefault
entriesbasedontheconfigurationofthenode.YoucanaddentrieswithTCP/IPutilitiesorentriescanbe
addeddynamicallythroughinteractionwithrouters.
WhenanIPpacketisforwarded,theIProutingtableisusedtodetermine:

1.

ThenexthopIPaddress
Foradirectdelivery(thedestinationisaneighboringnode),thenexthopIPaddressisthedestination
addressinthepacket.Foranindirectdelivery(thedestinationisnotaneighboringnode),thenexthop
addressistheaddressofarouter.

2.

Thenexthopinterface
Thenexthopinterfaceidentifieseitheraphysicalinterface(forexample,anetworkadapter)oralogical
interface(forexample,atunnelinginterface)thatisusedtoforwardthepacket.

Afterthenexthopaddressandinterfacearedetermined,thepacketispassedtotheAddressResolution
Protocol(ARP).ForLANtechnologiessuchasEthernetandTokenRing,ARPattemptstoresolvethelinklayer
address(alsoknownasthemediaaccesscontrol[MAC]address)forthenexthopaddress,andforwardthe
packetbyusingthenexthopinterface.

ContentsofanIPRoutingTable

ThefollowingarethefieldsofatypicalIProutingtableentry:

Destination
ThedestinationcanbeeitheranIPaddressoraclassbased,subnetted,orsupernettednetworkID.In
theWindows2000IProutingtable,thiscolumnisnamedNetworkDestination.

NetworkMask
ThebitmaskthatisusedtomatchadestinationIPaddresstothevalueintheDestinationfield.Inthe
Windows2000IProutingtable,thiscolumnisnamedNetmask.

NextHop
TheIPaddresstowhichthepacketisforwarded.IntheWindows2000IProutingtable,thiscolumnis
namedGateway.

Interface
ThenetworkinterfacethatisusedtoforwardtheIPpacket.

Metric
Anumberusedtoindicatethecostoftheroutesothatthebestroute,amongpotentiallymultipleroutes
tothesamedestination,canbeselected.Acommonuseofthemetricistoindicatethenumberofhops
(thenumberoflinksorrouterstocross)enroutetothedestination.

Routingtableentriescanbeusedtostorethefollowingtypesofroutes:

Directlyattachednetworkroutes
Routesforsubnetstowhichthenodeisdirectlyattached.Fordirectlyattachednetworkroutes,the
NextHopfieldcaneitherbeblankorcontaintheIPaddressoftheinterfaceonthatsubnet.

Remotenetworkroutes
Routesforsubnetsthatareavailableacrossroutersandarenotdirectlyattachedtothenode.Forremote
networkroutes,theNextHopfieldistheIPaddressofalocalrouter.

Hostroutes
AroutetoaspecificIPaddress.HostroutesallowroutingtooccuronaperIPaddressbasis.Forhost
routes,thenetworkIDisaspecificIPaddressandthenetworkmaskis255.255.255.255.

Defaultroute
Thedefaultrouteisusedwhenamorespecificnetworkorhostrouteisnotfound.Thedefaultroute
destinationis0.0.0.0withthenetworkmaskof0.0.0.0.Thenexthopaddressofthedefaultrouteis
typicallythedefaultgatewayofthenode.

RouteDeterminationProcess

Todeterminewhichroutingtableentryisusedforforwarding,IPusesthefollowingprocess:

Foreachentryintheroutingtable,abitwiselogicalANDoperationisperformedbetweenthedestination
IPaddressandtheNetworkMaskfield.TheresultiscomparedwiththeDestinationfieldoftheentryfora
match.
ToperformabitwiselogicalANDbetweenthedestinationIPaddressandthenetworkmaskoftheroute,
IPcompareseachbitinthedestinationIPaddresstothecorrespondingbitinthesubnetmask.Ifboth
bitsare1's,theresultingbitis1otherwise,theresultis0.Becauseofthewayinwhichthesubnetmask
isdefined,theresultofthebitwiselogicalANDoperationis:

Foreachbitinthesubnetmaskthatissetto1,thecorrespondingbitintheresultiscopiedfromthe
destinationIPaddress.

Foreachbitinthesubnetmaskthatissetto0,thecorrespondingbitintheresultissetto0.

AgoodexampleofperformingabitwiselogicalANDisindeterminingtheIPnetworkIDforanIPaddress
configuration.TodeterminetheIPnetworkID,abitwiselogicalANDoftheassignedIPaddresswithits
subnetmaskisperformed.TheresultistheIPnetworkID.
Forexample,fortheIPaddress192.168.98.112withthesubnetmask255.255.255.0,theresultofthe
bitwiselogicalANDis:

Forthefirst24bits,whichcorrespondtothe"255.255.255"portionofthesubnetmask,the
correspondingbitfromthedestinationIPaddressiscopied,resultingin192.168.98forthefirstthree
octets.

Forthelast8bits,whichcorrespondtothe"0"portionofthesubnetmask,thecorrespondingbitis
setto0,resultingin0forthelastoctet.

Therefore,192.168.98.112AND255.255.255.0is192.168.98.0.

Thelistofmatchingroutesiscompiled.Theroutethathasthelongestmatch(thatis,theroutewiththe
highestnumberofbitssetto1inthesubnetmask)isselected.Thelongestmatchingrouteisthemost
specificroutetothedestinationIPaddress.Iftherearemultiplelongestmatchroutes(forexample,
multipleroutestothesamenetworkID),therouterusesthelowestmetrictoselectthebestroute.If
therearemultiplelongestmatchingrouteswiththelowestmetric,thenoderandomlyselectswhich
routingtableentrytouse.

Theresultoftheroutedeterminationprocessistheselectionofasinglerouteintheroutingtable.Ifthis
processfailstoselectaroute,IPindicatesaroutingerror.Forasendinghost,anIProutingerrorisindicated
internallytoanupperlayerprotocol,suchasTCPorUDP.Forarouter,anICMPDestinationUnreachableHost
Unreachablemessageissenttothesendinghostandthepacketisdiscarded.

NextHopAddressandInterfaceDeterminationProcess

Afterdeterminingthesinglerouteintheroutingtablewithwhichtoforwardthepacket,thenexthopaddress
andinterfacearedeterminedbythefollowingprocess:

IftheaddressintheNextHopfieldiseitherblankorisanaddressthatisassignedtoaninterfaceonthe
forwardingnode:
ThenexthopaddressissettothedestinationIPaddressoftheIPpacket.
ThenexthopinterfaceissettotheinterfacethatisspecifiedintheInterfacefield.

IftheaddressintheNextHopfieldisnotanaddressthatisassignedtoaninterfaceontheforwarding
node:
ThenexthopaddressissettotheaddressintheNextHopfieldfortheroute.

ThenexthopinterfaceissettotheinterfacethatisspecifiedintheInterfacefield.

ExampleIPRoutingTableforWindows2000
ThefollowingtableliststhedefaultroutingtableforaWindows2000basedhost(thatis,notarouter).The
hosthasasinglenetworkadapterandisconfiguredwiththeIPaddress157.60.136.41,subnetmask
255.255.252.0(/22),andadefaultgatewayof157.60.136.1.ToviewtheIProutingtableonacomputer
runningWindows2000,type
routeprint
or
netstatr
atacommandprompt.

===========================================================================
InterfaceList
0x1...........................MSTCPLoopbackinterface
0x1000003...00b0d0e94143......3ComEtherLinkPCI
===========================================================================
===========================================================================
ActiveRoutes:
NetworkDestination
Netmask
0.0.0.0
0.0.0.0
127.0.0.0
255.0.0.0
157.60.136.0 255.255.252.0
157.60.136.41 255.255.255.255
157.60.255.255 255.255.255.255
224.0.0.0
224.0.0.0
255.255.255.255 255.255.255.255

Gateway
157.60.136.1
127.0.0.1
157.60.136.41
127.0.0.1
157.60.136.41
157.60.136.41
157.60.136.41

Interface
15.60.136.41
127.0.0.1
157.60.136.41
127.0.0.1
157.60.136.41
157.60.136.41
157.60.136.41

Metric
1
1
1
1
1
1
1

DefaultGateway:157.60.136.1
===========================================================================
PersistentRoutes:
None
Notethattwointerfacesarelisted.Oneinterfacecorrespondstoaninstallednetworkadapter(3ComEtherLink
PCI)andtheotherisaninternalloopbackinterface(MSTCPLoopbackInterface).
TheWindows2000IProutingtableusesanIPaddresstoidentifyaninterfaceintheInterfacefieldforthe
route.Therefore,thefollowingprocessdeterminesthenexthopaddressandinterface:

IftheaddressintheGatewayfieldisanaddressthatisassignedtoaninterfaceontheforwardingnode:
ThenexthopaddressissettothedestinationIPaddressoftheIPpacket.
ThenexthopinterfaceissettotheinterfacetowhichtheaddressintheInterfacefieldisassigned.

IftheaddressintheGatewayfieldisnotanaddressthatisassignedtoaninterfaceontheforwarding
node:
ThenexthopaddressissettotheaddressintheGatewayfield.
ThenexthopinterfaceissettotheinterfacetowhichtheaddressintheInterfacefieldisassigned.

ThisWindows2000IProutingtablecontainsthefollowingentries:

Thefirstentry,networkdestinationof0.0.0.0andnetworkmask(netmask)of0.0.0.0(/0),isthedefault
route.AnydestinationIPaddressthatisbitwiselogicallyANDedwith0.0.0.0,resultsin0.0.0.0.
Therefore,thedefaultrouteisamatchforanyIPaddress.Ifthedefaultrouteisthelongestmatching
route,thenexthopaddressis157.60.136.1andthenexthopinterfaceisthenetworkadapterthatis
assignedtheIPaddress157.60.136.41.

Thesecondentry,networkdestinationof127.0.0.0andnetmaskof255.0.0.0(/8),istheloopback
networkroute.Forallpacketsthataresenttoanaddressoftheform127.
x.y.z
,thenexthopaddressis

setto127.0.0.1(theloopbackaddress)andthenexthopinterfaceistheinterfacethatisassignedthe
address127.0.0.1(theloopbackinterface).

Thethirdentry,networkdestinationof157.60.136.0andnetmaskof255.255.252.0(/22),isa
directlyattachednetworkroute.Ifthisrouteisthelongestmatchingroute,thenexthopaddressissetto
thedestinationaddressinthepacketandthenexthopinterfaceissettothenetworkadapterthatis
assignedtheIPaddress157.60.136.41.

Thefourthentry,networkdestinationof157.60.136.41andnetmaskof255.255.255.255(/32),isahost
routefortheIPaddressofthehost.ForallIPpacketssentto157.60.136.41,thenexthopaddressisset
to127.0.0.1andthenexthopinterfaceistheloopbackinterface.

Thefifthentry,networkdestinationof157.60.255.255andnetmaskof255.255.255.255(/32),isahost
routethatcorrespondstotheallsubnetsdirectedbroadcastaddressfortheclassBnetworkID
157.60.0.0/16.ForallIPpacketssentto157.60.255.255,thenexthopaddressissetto157.60.255.255
andthenexthopinterfaceisthenetworkadapterthatisassignedtheIPaddress157.60.136.41.

Thesixthentry,networkdestinationof224.0.0.0andnetmaskof224.0.0.0(/3),isarouteformulticast
trafficthatissentbythishost.Forallmulticastpackets,thenexthopaddressissettothedestination
addressandthenexthopinterfaceissettothenetworkadapterthatisassignedtheIPaddress
157.60.136.41.

Theseventhentry,networkdestinationof255.255.255.255andnetmaskof255.255.255.255(/32),isa
hostroutethatcorrespondstothelimitedbroadcastaddress.ForallIPpacketssentto255.255.255.255,
thenexthopaddressissetto255.255.255.255andthenexthopinterfaceisthenetworkadapterthatis
assignedtheIPaddress157.60.136.41.

ThefollowingareexamplesofhowthisroutingtableisusedtodeterminethenexthopIPaddressand
interfaceforseveraldifferentdestinations:

Unicastdestination157.60.136.48
Thelongestmatchingrouteistherouteforthedirectlyattachednetwork(157.60.136.0/22).The
nexthopIPaddressissettothedestinationIPaddress(157.60.136.48)andthenexthopinterfaceisset
tothenetworkadapterthatisassignedtheIPaddress157.60.136.41.

Unicastdestination192.168.0.79
Thelongestmatchingrouteisthedefaultroute(0.0.0.0/0).ThenexthopIPaddressissettothedefault
gatewayaddress(157.60.136.1)andthenexthopinterfaceisthenetworkadapterthatisassignedtheIP
address157.60.136.41.

Multicastdestination224.0.0.1
Thelongestmatchingrouteisthe224.0.0.0/3route.ThenexthopIPaddressissettothedestinationIP
address(224.0.0.1)andthenexthopinterfaceisthenetworkadapterthatisassignedtheIPaddress
157.60.136.41.

Subnetbroadcastdestination157.60.139.255
Thelongestmatchingrouteistherouteforthedirectlyattachednetwork(157.60.136.0/22).The
nexthopIPaddressissettothedestinationIPaddress(157.60.139.255)andthenexthopinterfaceis
settothenetworkadapterthatisassignedtheIPaddress157.60.136.41.

Unicastdestination157.60.136.41
ThelongestmatchingrouteisthehostrouteforthelocallyassignedIPaddress(157.60.136.41/32).The
nexthopIPaddressissettothedestinationaddress(157.60.136.41)andthenexthopinterfaceissetto
theloopbackadapter.

You might also like