网络路由的原理和常见协议的工作机制.docx
《网络路由的原理和常见协议的工作机制.docx》由会员分享,可在线阅读,更多相关《网络路由的原理和常见协议的工作机制.docx(6页珍藏版)》请在冰豆网上搜索。
![网络路由的原理和常见协议的工作机制.docx](https://file1.bdocx.com/fileroot1/2023-2/22/1697a3a4-427d-494f-9236-ff72d0514b24/1697a3a4-427d-494f-9236-ff72d0514b241.gif)
网络路由的原理和常见协议的工作机制
网络路由的原理和常见协议的工作机制
RoutingPage1of9WhatistheRoleoftheRouter?
Routersinterconnectworksinordertoallowmunicationandresourcesharingamongstthoseworks.Connectionsaremadebetweenroutersusingcablesorawirelessmedium.Variousroutingprotocolsenabletherouterstoexchangedata,andcanbeusedtocontroltheflowofthatdata.Someroutershaveswitchesbuiltintothem,andsomerequireaseparateswitch.Apictureofasmallroutercanbefoundbelow:
BEFOREMOVINGFORWARD,ITISIMPORATANTTOKNOWTHATAROUTERISNOTAFIREWALLANDAFIREWALLISNOTAROUTER.THATSAID,SOMEROUTERSHAVEBUILTINFIREWALLCAPABILITIESRoutingPage2of9HowdoesaRouteruseRoutingTables?
Todetermihedestinationofapacket,therouterwillexamihepacketandsendthepackettotheproperdestination.Toexamihepacket,therouterstripsoffthelayer-2informationandputstheresultingpacketintoaqueue–thisprocessourswhenthepacketarrivesattherouter.TherouterwilltheninspectthedestinationIPaddressofthepacketandsendittothecorrectport.Toperformthis,therouterwillusearoutingtable.Theroutingtabletellstherouterexactlywheretosendthepacketsforthegivendestination.Anexampleofaroutingtablecanbefoundbelow:
DestinationNetworkSubMaskGatewayInterface10.12.14.0255.255.255.00.0.0.0LAN76.30.4.0255.255.254.00.0.0.0WAN0.0.0.00.0.0.076.30.4.1WANTheponentsoftheroutingtablearefurtherdescribedbelow:
1)DestinationLANIP–ThedefinedworkID.EveryworkIDdirectlyconnectedtooneoftherouter’sportsisalwayslistedhere.2)SubMask–IdentifiestheworkIDfromanIPaddress.3)Gateway–TheIPaddressforthehoprouter(i.e.wherethepacketshouldgo).IfthepacketisdestinedforaworkIDthatisnotdirectlyconnectedtotherouter,thegatewaycolumntellsroutertheIPaddressofaroutertosendthepacketto;thenextrouterhandlesthepacketandtheoriginalrouterisrelievedofitsresponsibilityforthatpacket.IftheworkIDisdirectlyconnected,thenagatewayisn’tneeded.4)Interface–TheInterfacefieldidentifieswhichofitsphysicalportstouse.Theprovidedexampleshows“LAN”and“WAN”butsomeroutersmayshowaport’sIPaddressoranothertypeofabbreviation(likef0/0,f0/1asfoundonCiscorouters).***Whenlookingattheroutingtable,a0represents“anything.”AnexampleofthiscanbefoundintheprovidedroutingtablewiththeDestinationLANIPof10.12.14.0andthesubmaskof255.255.255.0.Thismeansthatanyvaluebetween1and254isaeptable.Exercise:
Usetheroutingtableabovetoanswerthefollowingquestions.1)WhatinterfacewouldapacketreceivedwithaDestinationLANIPof76.30.4.27besentto?
________2)IfapacketisreceivedforaDestinationLANIPof69.36.252.61,whatGatewayshouldthepacketbesentto?
____________________________________________________________________________RoutingPage3of9HowtoIdentifytheDefaultRouteintheRoutingTableMostroutershaveadefaultroute.Adefaultroutetellstherouterwheretoforwardpacketswhennootherroutecanbedeterminedbyusingtheroutingtable.Intheroutingtablebelow,thedefaultrouteisrepresentedinthethirdline:
DestinationLANIPSubMaskGatewayInterface10.12.14.0255.255.255.00.0.0.0LAN76.30.4.0255.255.254.00.0.0.0WAN0.0.0.00.0.0.076.30.4.1WANIsaRoutertheOnlyThingthathasaRoutingTable?
No,everynodeonaworkshouldhavearoutingtable.Takethetimetoopenamandpromptorterminalwindowandtypethemandstat–r.YoumayalsousethemandrouteprintintheWindowsmandpromptasanalternativeoptionorrouteinlinux.Thedefaultroute.Thisroutingtableshowsroutesfor10.12.14.0and76.30.4.0;thethirdlineintheroutingtablehas0.0.0.0forthedestinationandsubmask,representinganyotherdestination.Essentially,thisruleintheroutingtablesays(anydestinationaddress)(withanysubmask)(forwarditto76.30.4.1)(usingtheWANport).RoutingPage4of9WhatisNetworkAddressTranslation(NAT)?
NetworkAddressTranslation(NAT)istheprocessofmodifyingIPaddressinformationinIPv4headerswileittransitsthrougharoutingdevice.Thismodificationisdoneforsecuritypurposes,andtohidetheIPaddressesofputersontheLANwhileallowingtheputertoaesstotheInter.NATessentiallyextendsthelifeofIPv4addressesontheInter.ItmustbenotedthatNATisnotrouting,itisaseparatetechnologythatmanyroutersofferasafeature.WhatdoesthebasicsetupofNATlooklike?
Inthisscenario,youareaworkadministrator.YouhaveaLANwitheightputersonitthatneedaesstotheInter.YoucalltheInterServiceProviderandpurchaseaworkID(example:
1.2.3.136/29).YouthenassignanIPaddresstoeachputerandtotheLANconnectionontherouter,andthenassigntheIPaddressfortheISP’sroutertotheWANconnectiononthelocalrouter(example1.2.3.4).Theputersontheworkthenusetherouterastheirdefaultgateway(aesspointtotheInter).AnexampleofNATcanbefoundbelow:
InNATsmostbasicstructure,whentherouterreceivestherequestfromtheputerontheLANitwillreplacethesourceIPaddresswiththeIPaddressoftheWANonoutgoingpackets.Therouterwillthentrackthebasicdataabouttheactiveconnection(destinationaddressandport).Whenthereplyreturnstotherouter,therouterwillusetheconnectiontrackinginformationthatitstoredduringfromtheoutboundrequesttodetermiheprivateaddressontheLANandtherouterwillforwardthereplytotheappropriateputer.RoutingPage5of9WhatisPAT?
TherearemanymethodsusedtoNAT.ThemostmonmethodisPortAddressTranslation(PAT).PATusesportnumberstomaptrafficfromspecificputersontheLAN.WhenaputerontheLANmakesarequest,likeusingawebbrowsertoaessawebsite,therouterwillrecordthesourceIP,destinationIP,andtheportnumber.TheprivateIPaddressisthenswappedoutforthepublicIPaddressandauniqueportnumberoneachpacket–thisinformationisalsorecordedbytherouter.Anexampleofthisinteractioncanbeseenbelow:
Whenthetrafficisreturned,therouterwillparetheiningdestinationportandsourceIPaddresstotheentryintheNATtranslationtabletodetermineinternalIPaddressandmodifythepacketwiththeinternalsourceIPaddress.ThepacketwillthenbesenttotheoriginalputerwiththeoriginatingsourceIPaddress.Thisprocesswillevenworkwhenmorethan1puterontheworkareaessingthesameserveroutsideoftheworkbecausethoughtsofportsareavailableforPAT.Onethingtobeawareofisthatthisprocessonlyworksfortrafficleavingthework,notinboundtraffic.Noticehowthesource(Src:
)IPandporthavebeenchangedinthepacket.OriginalIPis10.0.0.2AfterPATIPis157.55.1.10Originalport3123AfterPATportis4135TheNATtranslationtable.Therouterhasstoredtheinformationsothatthereturnedpacketscanbesenttocorrecthost.RoutingPage6of9Then,WhatisPortForwarding?
Portforwardingtakescareofthelimitationsassociatedwithinboundrequests,likeaputeringfromoutsideoftheworkattemptingtoaessawebserverinsidethework.Portforwardingallowsaworkadministratortodesignateaspecificlocaladdressfordifferentworkservices.AputeroutsideoftheworkcanmakearequestforservicesusingthepublicIPaddressoftheworkandtheportnumberofthedesiredservice.Therouterwillexamihepacket,reviewthelistofservicesmappedtolocaladdresses,thesendthepackettotheproperhost.Anexampleofportforwardingcanbefoundbelow:
WhatistheDifferenceBetweenDynamicandStaticNATs?
BothstaticanddynamicNATrequirestheworktohaveenoughpublicaddressestosatisfythetotalnumberofsimultaneoususersessions.Fundamentally,staticNATsareusedforinboundtrafficanddynamicNATsareusedforoutboundtrafficbutbotherarefurtherexplainedbelow:
StaticNAT:
AstaticNAT(AKAinboundmapping)istheprocessofmappinganunregisteredIPaddresstoaregisteredIPaddress.Thismappingisdoneonaone-to-onebasis.Theunregistered(ormapped)IPaddressisassignedwiththesameregisteredIPaddresseachtimetherequestismade.Amonapplicationofthisisforwebserversorhoststhatmusthaveaconsistentaddressthatcanbeaessedfromoutsideofthework.AnexampleofstaticNATingcanbefoundbelow:
RoutingPage7of9DynamicNAT:
AdynamicNATprovidesapermanentmappingbetweenspecificinternalIPaddressesandaspecificpublicIPaddress.Toachievethis,dynamicNATusesapoolofpublicIPaddressesandassignstheIPaddressesonafirstefirstservebasiswhenthehostmakesarequestforaserviceoutsideofthework.AnexampleofdynamicNATingcanbefoundbelow:
WhatisDynamicRouting?
Thisjobsheethasshownmanyexamplesoftablesthatlookingliketheyarestatic.Don’tletthatfoolyouthough;mostroutershavetheabilitytoupdatetheirroutesdynamically,providedtheyareabletousedynamicroutingprotocols.Whilemanyroutingprotocolshavebeendefinedovertheyears,routingprotocolsaretypicallydividedintothreedistinctgroups:
1)distancevector;2)linkstate,and3)hybrid.Tounderstandthesegroups,youmustunderstandmetricsbeforeunderstandingthedifferentroutingprotocols.RoutingMetricsAmetricissimplyarelativevaluethatrouterswillusewhentheyhavemorethanoneroutetogettoanotherwork.Thesemetricsidentifythe“cost”ofusingagivenroute.Alowermetricnumberidentifiesthefirstpaththattheroutershouldtake;iftheroutercan’ttakethatpathitwilluseahighermetriumberifitisavailable.Anexampleofaroutingtablewithmetricscanbeseenbelow.Theroutingmetricandinterfacehasbeenoutlinedandidentifiestheinterfacetosendpacketstoforworkdestinationsof224.0.0.0withasubmaskof240.0.0.0.Inthisinstance,5pathsareavailableforthatdestinationbut4oftheinterfacescarrythesamemetric–meaningthatall4interfacescanbeused;ifthesamemetriumberisused,thenthewidestsubmaskwilltakeprecedence.Ifthereisaproblemwiththoseinterfaces,theroutershouldusetheinterfacewiththenexthighestmetric.RoutingPage8of9Dynamicroutingprotocolsallowaroutertofindalternativeroutesifaconnectionislostorunavailable.Therolethatthemetricplaysinthisprocessallowstheroutertofindthenextroute–therouterwillalwayschoseroutewiththelowestmetric.Itisimportanttoknowthatthereisnomonstandardusedtodetermihemetricvaluebutvarioustypesofdynamicprotocolsusedifferentcriteria.Youwillfindsomeofthemostmoncriteriafordete