OSPF and BGP Basic Setup.docx
《OSPF and BGP Basic Setup.docx》由会员分享,可在线阅读,更多相关《OSPF and BGP Basic Setup.docx(17页珍藏版)》请在冰豆网上搜索。
OSPFandBGPBasicSetup
Content
∙OSPF
oSampleEnvironment
oBasicSetup
oDefaultRoute
oSecurity
oCostControl
oAdvanceControl
∙BGP
oPathSelection
oSampleEnvironment
oBasicSetup
oControlRouteAnnoucementandReceive
oPeerGroup
oPathSelection
OSPF
OSPF(OpenShortestPathFirst)isaroutingprotocolthatusuallyuseatLANenviromentorwithinonecorporate.
Reference:
∙OSPFDesignGuide
∙OSPF:
FrequentlyAskedQuestions
SampleEnvironment
IP:
core_a,f0/0:
192.168.1.1/24
access_a,f0/0:
192.168.1.2/24
BasicSetup
TouseOSPFissimple,wejustneed:
∙EnableanOSPFprocessby"routerospfXX"whereXXisprocessID
∙Assignareatoaninterfaceby"networkarea"
OSPFworksthroughbroadcast.Areaislikepartitiontoseperatedifferentbroadcastdomain.
AboveisexamplefromCisco,thereare3areasconnectedthroughArea0.Area0isreservedasbackbone.Thebackbonehastobeatthecenterofallotherareas,i.e.allareashavetobephysicallyconnectedtothebackbone.
ForsmallLANenviroment,oneareaisenough.Forourexample,wewillsetasfollowing:
core_a:
router ospf 10
network 192.168.1.1 0.0.0.0 area 100
access_a:
router ospf 10
network 192.168.1.2 0.0.0.0 area 100
Toseeifitworksornot,wecantrytoseeiftheyfoundtheirneighbour.
core_a#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
192.168.1.2 1 FULL/DR 00:
00:
29 192.168.1.2 FastEthernet0/0
core_a#
ButcurrentlyitonlyexchangeOSPFroutes.NormallywewantOSPFtoredistributeconnectedandstaticroutesforus.Soweneedtoadd:
router ospf 10
redistribute connected metric-type 1 subnets
redistribute static metric-type 1 subnets
Nowletmeaddastaticrouteataccess_a,wecanseeatcore_a
access_a(config)#ip route 1.1.1.1 255.255.255.255 null0
core_a#show ip route
Codes:
C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
O E1 1.1.1.1 [110/21] via 192.168.1.2, 00:
00:
00, FastEthernet0/0
C 192.168.1.0/24 is directly connected, FastEthernet0/0
DefaultRoute
Bydefault,itwillnotredistributeanydefaultroute.Inordertoletitredistribute,weneedtouse"default-informationoriginate"command.
core_a:
ip route 0.0.0.0 0.0.0.0 null0
!
router ospf 10
default-information originate metric 3 metric-type 1
!
Now access_a learn the default route:
access_a#show ip route
Codes:
C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is 192.168.1.1 to network 0.0.0.0
1.0.0.0/32 is subnetted, 1 subnets
S 1.1.1.1 is directly connected, Null0
C 192.168.1.0/24 is directly connected, FastEthernet0/0
O*E1 0.0.0.0/0 110/11
via 192.168.1.1, 00:
00:
07, FastEthernet0/0
access_a#
Security
AsOSPFwilllearnpeersthemselves,itisbettertoaddauthenticationkeyforsecuritypurpose.
interface XXXX
ip ospf message-digest-key md5
!
router ospf XX
area authentication message-digest
Example:
interface FastEthernet0/0
ip ospf message-digest-key 10 md5 7 096B6B273C363E21
!
router ospf 10
area 100 authentication message-digest
CostControl
OSPFcalculatethecostbyinterfacebandwidth.Defaultis(100M/interfacebandwidth).Sothecostwillincreaseby1iftheconnectionisoverFastEthernetinterface,whilethecostwillincreaseby64iftheconnectionisoveraT1link.Thecostaccumulateuntilitreachthedestination.
Intheaboveexample,thecostforAtoreachEwillbe(1+10)=11or(1+1+2)=4.OSPFwillthenchoosethepaththroughCandDwhichhaslowercost.
TherearetwobasicwaytocontrolOSPFcost:
∙Use"ipospfcostxx"underinterface.NotethisonlyaffectOSPFroutereceived.
Example:
core_a#show ip route 1.1.1.1
Routing entry for 1.1.1.1/32
Known via "ospf 10", distance 110, metric 21, type extern 1
Last update from 192.168.1.2 on FastEthernet0/0, 05:
10:
43 ago
Routing Descriptor Blocks:
* 192.168.1.2, from 192.168.1.2, 05:
10:
43 ago, via FastEthernet0/0
Route metric is 21, traffic share count is 1
Metric = (redistribution cost 20) + (100M/100M) = 21
If we apply "ip ospf cost 10" under core_a,f0/0:
core_a#show ip route 1.1.1.1
Routing entry for 1.1.1.1/32
Known via "ospf 10", distance 110, metric 30, type extern 1
Last update from 192.168.1.2 on FastEthernet0/0, 00:
00:
03 ago
Routing Descriptor Blocks:
* 192.168.1.2, from 192.168.1.2, 00:
00:
03 ago, via FastEthernet0/0
Route metric is 30, traffic share count is 1
Interface cost forced to 10. Total is (redistribution cost 20) + 10 = 30.
∙Use"metric"parameterduringtheredistribution
Continue from the above example:
core_a#show ip route 1.1.1.1
Routing entry for 1.1.1.1/32
Known via "ospf 10", distance 110, metric 30, type extern 1
Last update from 192.168.1.2 on FastEthernet0/0, 00:
00:
09 ago
Routing Descriptor Blocks:
* 192.168.1.2, from 192.168.1.2, 00:
00:
09 ago, via FastEthernet0/0
Route metric is 30, traffic share count is 1
Change static route redistribution at access_a to:
router ospf 10
redistribute static metric 50 metric-type 1 subnets
core_a#show ip route 1.1.1.1
Routing entry for 1.1.1.1/32
Known via "ospf 10", distance 110, metric 60, type extern 1
Last update from 192.168.1.2 on FastEthernet0/0, 00:
00:
02 ago
Routing Descriptor Blocks:
* 192.168.1.2, from 192.168.1.2, 00:
00:
02 ago, via FastEthernet0/0
Route metric is 60, traffic share count is 1
Metric now become (redistribution cost 50) + 10 = 60
AdvanceControl
Route-maporaccess-listcanbeusetocontrolroutereceive/redistribution.
router ospf 10
distribute-list
redistribute connected metric-type 1 subnets route-map
redistribute static metric 50 metric-type 1 subnets route-map
Example:
router ospf 10
redistribute connected metric-type 1 subnets route-map rf--OSPF-REDISTRIBUTE-CONNECTED
redistribute static metric 50 metric-type 1 subnets route-map rf--OSPF-REDISTRIBUTE-STATIC
BGP
BGP(BorderGatewayProtocol)isroutingprotocolwidelyusebetweenISPs.UnlikeOSPF,itispeertopeerbasedinsteadofbroadcast.
Reference:
BGPCaseStudies
BGP:
FrequentlyAskedQuestions
ConfiguringBGP
PathSelection
BGPuseAS(AutonomousSystems)numberstoindicatethepathtodestination.Eachparty(e.g.ISP)hastheirownASnumber.ASnumber,likeIPaddress,needtoapplyfromrelatedNIC(e.g.APNIC,CNNIC,TWNIC).AlsolikeprivateIPaddress,therearearangeofASnumberreservedforprivateuse.IANAhasreservedAS64512throughtoAS65535tobeusedasprivateASnumbers.
Whenannoucing/redistributingroutestotheirpeers,theirASnumberisprependtotheroutes.Themoretheroutesredistributeamongdifferentparties,thelongertheASpath.
Intheaboveexample,therearetwopathsforAS100tonetworkbroadcastfromAS300:
∙ASpath:
200300
∙ASpath:
400500300
TherouterwillchoosetheshorterASpathasbestroute.
SampleEnvironment
IP:
core_a,f0/0:
192.168.1.1/24
access_a,f0/0:
192.168.1.2/24
core_b,f0/0:
192.168.2.1/24
access_b,f0/0:
192.168.2.2/24
core_a,s1/0:
10.10.10.1/30
core_b,s1/0:
10.10.10.2/30
core_a&access_a,core_b&access_bhasOSPFrunning
BasicSetup
BGPusespeertopeersetupandonerouteronlyuseoneASnumber.Hereistheminimumconfiguration:
router bgp
neighbor remote-as
network xx.xx.xx.xx mask yy.yy.yy.yy
Usuallyweuse"networkxx.xx.xx.xx"commandtoannouceourIPrangetoremotepeer,insteadofredistributeconnected/static/OSPFroutes.AlsowhenworkingwithISP,theminimumIPsegmentisClassC(/24).
Example:
Assume we have two ISP A and B, which has AS100 and AS200 respectively. (Use private AS when working at client CPE if they don't have their own AS)
core_a:
router bgp 100
neighbor 10.10.10.2 remote-as 200
network 192.168.1.0 mask 255.255.255.0
core_b:
router bgp 200
neighbor 10.10.10.1 remote-as 100
network 192.168.2.0 mask 255.255.255.0
Inthisexample,core_aisusingAS100andcore_bisusingAS200.WeannouncethecorrespondingLANIPtoremotenetwork.
core_a#show ip bgp summary
BGP router identifier 192.168.1.1, local AS number 100
BGP table version is 3, main routing table version 3
2 network entries using 234 bytes of memory
2 path entries using 104 bytes of memory
3/2 BGP path/bestpath attribute entries using 372 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-lis