Home Technique Static routing

Static routing



Advantages

Anotheradvantageofusingstaticroutingisthehighnetworksecurityandconfidentiality.Dynamicroutingrequiresrouterstofrequentlyexchangetheirrespectiveroutingtables,andtheanalysisoftheroutingtablecanrevealinformationsuchasthenetworktopologyandnetworkaddresses.Therefore,thenetworkcanalsousestaticroutingforsecurityconsiderations.Doesnotoccupynetworkbandwidth,becausestaticroutingdoesnotgenerateupdatetraffic.Staticroutingissuitableforsmallandmedium-sizednetworks.

Disadvantages

Staticroutingisusuallynotsuitableforlargeandcomplexnetworkenvironments.Ontheonehand,itisdifficultfornetworkadministratorstofullyunderstandthetopologyoftheentirenetwork;ontheotherhand,whenthetopologyandlinkstatusofthenetworkchange,thestaticroutinginformationintherouterneedstobeadjustedonalargescale,whichisdifficult.Andthecomplexityisveryhigh.Whenthenetworkchangesorthenetworkfails,theroutecannotbereselected,whichmaycausetheroutetofail.

Configurationcommands

(TakeFigure1asanexample)

Therearetwowaystoconfigurestaticrouting:staticroutingwithanext-hoprouter,andSendoutthestaticrouteoftheinterface

router(config)#hostnameA(changerouterhostname)A(config)#interfacef0/0(enterinterfacef0/0)

A(config-if)#ipaddress192.168.1.1255.255.255.0(Settheinterfaceipaddressandsubnetmask)

A(config-if)#noshutdown(Enabletheinterface)

A(config)#interfacef0/1

A(config-if)#ipaddress192.168.2.1255.255.255.0

A(config-if)#noshutdown

×××Chooseoneofthefollowingtwo:

A(config)#iproute192.168.3.0255.255.255.0f0/1(targetnetworksegmentIPaddresstargetsubnetmasksendinginterface(routerA))

or

A(config)#iproute192.168.3.0255.255.255.0192.168.2.2(targetnetworksegmentIPaddresstargetsubnetmasknextrouterinterfaceipAddress)

×××

router(config)#hostnameB

B(config)#interfacef0/0

B(config-if)#ipaddress192.168.3.1255.255.255.0

B(config-if)#noshutdown

B(config)#interfacef0/1

B(config-if)#ipaddress192.168.2.2255.255.255.0

B(config-if)#noshutdown

×××Chooseoneofthefollowing:

B(config)#iproute192.168.1.0255.255.255.0192.168.2.1

Or:

B(config)#iproute192.168.1.0255.255.255.0f0/1(targetnetworksegmentIPaddresstargetsubnetmaskoutputinterface(routerB))

×××

Note1:ThisnetworklinkisanEthernetlinkIfitisaseriallink,thesendinginterfaceisalsotheserialinterfaceofthelocalrouter.

Conciseexplanation:iproute192.168.3.0255.255.255.0192.168.2.2

Thissentencemeans:OnHOSTA,therouterseesthatthedestinationnetworksegmentis192.168.3.0Datapacket,sendthedatapacketto192.168.2.2

Note2:iproutecanpointtoone,ifbothareconfigured,itmeansthatthedatapacketissentoutfromfa0/1,Andtheothersaidthatdatapacketsweresenttothisip(forexample,192.168.2.2).Tworepetitions.GenerallywesetittopointtotheIP.

Whentherearetwoormorestaticroutespointingtothesamedestinationaddressbutdifferentegressesonthesameroutingorswitchingdevice,thetrafficsenttothedestinationaddresswillbeloadbalancedfromtheseegresses.

Example

ThebasicstaticroutingexampleisshowninFigure2.ItconsistsoftworoutersR1andR2(theinterfacenumberandIPaddressaregiveninFigure2),whicharerespectivelyConnectedtotheirrespectivenetworks:R1isconnectedtothesubnet192.168.0.0/24,andR2isconnectedtothesubnet192.168.2.0/24.

Withoutconfiguringstaticrouting,computersAandBinthesetwosubnetscannotcommunicate.TheIPpacketsentfromcomputerAtocomputerB,afterreachingR1,R1doesnotknowhowtoreachthenetworksegment192.168.2.0/24wherecomputerBislocated(thatis,thereisnoroutingtableto192.168.2.0/24onR1),thesameR2alsodoesnotknowhowtoreachthenetworksegment192.168.0.0/24wherecomputerAislocated,sothecommunicationfails.

Atthistime,theadministratorisrequiredtoconfigurestaticroutesonR1andR2toenablecomputersAandBtocommunicatesuccessfully.

  • Executethecommandtoaddstaticrouteiproute192.168.2.0255.255.255.0192.168.1.1onR1.ItmeanstotellR1thatifthereisanIPpacketthatwantstoreachthenetworksegment192.168.2.0/24,thenpleasesendthisIPpacketto192.168.1.1(thatis,theoppositeendconnectedtoport2ofR1).

  • Atthesametime,executethecommandtoaddstaticroutesonR2iproute192.168.0.0255.255.255.0192.168.1.2.ItmeanstotellR2thatifthereisanIPpacketthatwantstoreachthenetworksegment192.168.0.0/24,thenpleasesendthisIPpacketto192.168.1.2(thatis,theoppositeendconnectedtoport3ofR2).

Throughtheabovetwoconfigurations,theIPpacketsentfromcomputerAtocomputerBcanbeforwardedtoR2byR1throughport2,andthenR2tocomputerB.Similarly,theIPpacketreturnedfromcomputerBtocomputerAcanbeforwardedtoR1byR2throughport3,andthenR1isforwardedtocomputerA,completingacompletecommunicationprocess.

FrequentlyAskedQuestions

1)Whyisthereadefaultroute

Theroutehastolookattheroutingtabletodeterminehowtoforwardthedatapacket,useTheconfigurationofstaticroutesonebyoneistediousanderror-prone.Iftherouterhasaneighborwhoknowshowtogettoalldestinations,itcandelegatethetaskofroutingtablematchingtoit,whichsavesalotofwork.

Forexample,thegatewaywillknowalltheroutes.Ifarouterisconnectedtothegateway,youcanconfigurethedefaultroutetoforwardalldatapacketstothegateway.

2)Whythedefaultrouteis0.0.0.0

WhenmatchinganIPaddress,0meanswildcard,anyvalueisfine.Therefore,thematchbetween0.0.0.0andanydestinationaddresswillsucceed,resultingintheeffectofthedefaultrouterequirement.

This article is from the network, does not represent the position of this station. Please indicate the origin of reprint
TOP