Está en la página 1de 35

Ti: Tm Hiu V M Hnh OSPF 201

MC LC
1. Cc khi nim v OSPF n vng......................................................................5 1.1. Tng qut v OSPF..................................................................................5 1.2. Thut ng ca OSPF................................................................................6 2. OSPF vi giao thc nh tuyn theo vect khong cch...............................10 2.1. Thut ton chn ng ngn nht.......................................................12 2.2. Cc loi mng OSPF..............................................................................13 2.3. GiaothcOSPF Hello..............................................................................16 2.4. Cc bc hotngcaOSPF................................................................17 3. Cu hnh OSPF n vng.................................................................................21 3.1. Cu hnh tin trnh nh tuyn OSPF..................................................21 3.2. Cu hnh a ch loop back cho OSPF v quyn u tin cho router. 22 3.3. Thay i gi tr chi ph ca OSPF.........................................................25 3.4. Cu hnh qu trnh xc minh cho OSPF..............................................27 3.5. Cu hnh cc thong s thi gian ca OSPF..........................................28 3.6. OSPF thc hin qung b ng mc nh.........................................29 3.7. Nhng li thng gp trong cu hnh OSPF.......................................30 3.8. Kim tra cu hnh OSPF.......................................................................31 TNG KT....................................................................................................32 TI LIU THAM KHO............................................................................33

GVHD: Nguyn Minh Hi

Trang 1

Ti: Tm Hiu V M Hnh OSPF 201

2
DANH SCH CC THNH VIN NHM

TT 1 2 3 4

H v tn H nh K Phm Thanh Tng Trn Hong Cng Nguyn Ngc Khnh

MSSV 11350561 11359881 11346141 11344421

im

GVHD: Nguyn Minh Hi

Trang 2

Ti: Tm Hiu V M Hnh OSPF 201

2
LI CM N

c c bi tiu lun ny li u tin cho nhm chng em xin chn thnh cm n Ban Gim Hiu trng i Hc Cng Nghip TP. HCM to iu kin cho chng em c hc tp ti trng. V c bit Nhm chng em xin gi li cm n chn thnh nht n Thy Nguyn Minh Hi, ging vin khoa Khoa hc v My tnh, trang b cho chng em nhng kin thc chuyn mn, quan tm, to c hi cho chng em c th hin kh nng lm vic theo nhm, pht huy tinh thn on kt v tn tnh hng dn gip nhm em hon thnh mt cch tt nht bi tiu lun trong thi gian qua. Vi iu kin hc tp v thi gian c hn cng nh lng kin thc cn hn ch nn bi tiu lun s khng trnh khi nhng thiu st. Nhm chng em rt mong nhn c s ch bo, ng gp kin ca Thycng ton th cc bn Nhm c iu kin b sung, nng cao kin thc ca mnh c nhng bi tiu lun y v hay hn trong qu trnh hc tp sau ny./.

Tp. H Ch Minh, ngy 24 thng 8 nm 2012

GVHD: Nguyn Minh Hi

Trang 3

Ti: Tm Hiu V M Hnh OSPF 201

2
NHN XT CA GIO VIN HNG DN ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... ....................................................................................................................................... .......................................................................................................................................

GVHD: Nguyn Minh Hi

Trang 4

Ti: Tm Hiu V M Hnh OSPF 201

2
TM HIU V PHN TCH MT S NG DNG V M HNH OSPF
1. Cc khi nim v OSPF n vng 1.1. Tng qut v OSPF
OSPF l mt giao thc nh tuyn theo trng thi ng lin kt c trin khai da trn cc chun m. OSPF c m t trong nhiu chun ca IETF (Internet Engineering Task Force). Chun m y c ngha l OSPF hon ton m i vi cng cng, khng c tnh c quyn. Nu so snh vi RIPv1 v v2 th OSPF l mt giao thc nh tuyn ni vi IGP tt hn v kh nng m rng ca n. RIP ch gii hn trong 15 hop, hi t chm v i khi chn ng c tc chm v khi quyt nh chn ng n khng quan tm n cc yu t quan trng khc nh bng thng chng hn. OSPF khc phc c cc nhc im ca RIP v n l mt giao thc nh tuyn mnh, c kh nng m rng, ph hp vi cc h thng mng hin i. OSPF c th c cu hnh nvng s dng cho cc mng nh.

Hnh 1.1 Mng OSPF ln c thit k phn cp v chia thnh nhiu vng

V d nh hnh 1.1, mng OSPF ln cn s dng thit k phn cp v chia


GVHD: Nguyn Minh Hi Trang 5

Ti: Tm Hiu V M Hnh OSPF 201

2
thnh nhiu vng. Cc vng ny u c kt ni vo cng phn phi la vng 0 hay cn gi l vng xng sng (backbone). Kiu thit k ny cho php kim sot hot ng cp nht nh tuyn. Vic phn vng nh vy lm gim ti ca hot ng nh tuyn, tng tc hi t, gii hn s thay i ca h thng mng vo tng vng v tng hiu sut hot ng. 1.2. Thut ng ca OSPF Router nh tuyn theo trng thi ng lin kt xc nh cc router lng ging v thit lp mi quan h vi cc lng ging ny. OSPF thc hin thu thp thng tin v trng thi cc ng lin kt t cc router lng ging. Mi router OSPF qung co trng thi cc ng lin kt ca n v chuyn tip cc thng tin m n nhn c cho tt c cc lng ging khc.

Hnh 1.2.a. Link l mt cng trn router. Link-state: trng thi ca mt ng lin kt gia hai router, bao gm trng thi ca mt cng trn router v mi quan h gia n vi router lng ging kt ni vo cng .

Router x l cc thng tin nhn c xy dng mt c s d liu v trng thi cc ng lin kt trong mt vng. Mi router trong cng mt vng OSPF s c cng mt c s d liu ny. Do mi router s c thng tin ging nhau v trng thi ca cc ng lin kt v lng ging ca cc router khc.

GVHD: Nguyn Minh Hi

Trang 6

Ti: Tm Hiu V M Hnh OSPF 201

Hnh 1.2.b. Link-state database (Topological database) danh sch cc thng tin v mi ng lin kt trong vng.

Hnh 1.2.c. Area - Tp hp cc mng v cc router c cng ch s danh nh vng. Mi router trong mt vng ch xy dng c s d liu v trng thi cc ng lin kt trong vng . Do , cc router trong cng mt vng s c thng tin ging nhau v trng thi cc ng lin kt. Router nm trong mt vng c gi la router ni vng.

Mi router p dng thut ton SPF v c s d liu ca n tnh ton chn ng tt nht n tng mng ch. Thut ton SPF tnh ton chi ph da trn bng thng cang truyn. ng no c chi ph nh nht s c chn a vo
GVHD: Nguyn Minh Hi Trang 7

Ti: Tm Hiu V M Hnh OSPF 201

2
bng nh tuyn.

Hnh 1.2.d. Cost gi tr chi ph t cho mt ng lin kt. Giao thc nh tuyn theo trng thi ng lin kt tnh chi ph cho mt lin kt da trn bang thng hoc tc ca ng lin kt .

Hnh 1.2.e. Routing table hay cn gi l c s d liu chuyn gi. Bng nh tuyn l kt qu chn ng ca thut ton chn ng a da trn c s d liu v trng thi cc ng lin kt.

Mi router gi mt danh sch cc lng ging thn mt, danh sch ny gi l c s d liu cc lng ging thn mt. Cc lng ging c gi l thn mt l nhng lng ging m router c thit lp mi quan h hai chiu. Mt router c th c nhiu lng ging nhng khng phi lng ging no cng c mi quan h thn mt. Do bn cn lu mi quan h lng ging khc vi mi quan h lng ging thn mt, hay gi tt l mi quan h thn mt. i vi mi router danh sch lng ging thn mt s khc nhau.
GVHD: Nguyn Minh Hi Trang 8

Ti: Tm Hiu V M Hnh OSPF 201

Hnh 1.2.f. Adjacency database danh sch cc router lng ging c mi quan h hai chiu. Mi router s c mt danh sch khc nhau.

gim bt s lng trao i thng tin nh tuyn vi nhiu roter lng ging trong cng mt mng, cc router OSPF bu ra mt router i din gi l Designated router (DR) v mt router i din d phng gi l Backup Designated (BDR) lm im tp trung cc thng tin nh tuyn.

Hnh 1.2. g. Design Router (DR) v Backup Designated Router (BDR) l router
GVHD: Nguyn Minh Hi Trang 9

Ti: Tm Hiu V M Hnh OSPF 201

2
c tt c cc router khc trong cng mt mng LAN bu ra lm i din. Mi mt mng s c mt DR va BDR ring.

2. OSPF vi giao thc nh tuyn theo vect khong cch. Trong phn ny chng ta s so snh OSPF vi mt giao thc nh tuyn theo vect khong cch l RIP. Router nh tuyn theo trng thi ng lin kt c mt s y v cu trc h thng mng. Chng ch thc hin trao i thng tin v trng thi cc ng lin kt lc khi ng v khi h thng mng c s thay i. Chng khng pht qung b bng nh tuyn theo nh k nh cc router nh tuyn theo vect khong cch. Do , cc router nh tuyn theo trng thi ng lin kt s dng t bng thng hn cho hot ng duy tr bng nh tuyn. RIP ph hp cho cc mng nh v ng tt nht i vi RIP l ng c s lng hp t nht. OSPF th ph hp vi mng ln, c kh nng m rng, ng i tt nht ca OSPF c xc nh da trn tc ca ng truyn. RIP cng nh cc giao thc nh tuyn theo vect khong cch u s dng thut ton chn ng n gin. Cn thut ton SPF th rt phc tap. Do , nu router chy giao th chi ph OSPF tng ng cng thp OSPF chn ng tt nht t cy SPF. OSPF bo m khng b nh tuyn lp vng. Cn giao thc nh tuyn theo vect khong cch vn c th b nh tuyn thc nh tuyn theo vect khong cch s cn t b nh v nng lc x l thp hn so vi khi chy OSPF. OSPF chn ng da trn chi ph c tnh t tc ca ng truyn. ng truyn c tc cng cao lp vng. Nu mt kt ni khng n nh, chp chn, vic pht lin tc cc thng tin v trang thi ca ng lin kt ny s dn n tnh trng cc thng tin qung co khng ng b lm cho kt qu chn ng ca cc router b o ln. OSPF gii quyt c cc vn sau: * Tc hi t. * H tr VLSM (Variable Length Subnet Mask). * Kch c mng
GVHD: Nguyn Minh Hi Trang 10

Ti: Tm Hiu V M Hnh OSPF 201

2
* Chn ng * Nhm cc thnh vin.

Hnh 2. S c xy ra khi mt kt ni khng n nh lm cho vic cp nht khng ng b

Trong mt h thng mng ln, RIP phi mt vi pht mi c th hi t c v mi router ch trao i bng nh tuyn vi cc router lng ging kt ni trc tip vi mnh m thi. Cn i vi OSPF sau khi hi t vo lc khi ng, khi c thay i th vic hi t s rt nhanh v ch c thng tin v s thay i c pht ra cho mi router trong vng. OSPF c h tr VLSM nn n c xem l mt giao thc nh tuyn khng theo lp a ch. RIPv1 khng c h tr VLSM, tuy nhin RIPv2 c h tr VLSM. i vi RIP, mt mng ch cch xa hn 15 router xem nh khng n c v RIP c s lng hop gii hn l 15. iu ny lm kch thc mng ca RIP b gii hn trong phm vi nh. OSPF th khng h c gii hn v kch thc mng, OSPFhon ton ph hp cho cc mng va v ln. Khi nhn c t lng ging cc router bao co v s lng hop n mng ch, RIP s cng thm 1 vo thng s hop ny v da vo s lng hop chn ng n mng ch. ng no c khong cch ngn nht hay ni cch khc l c s lng hop t nht s l ng tt nht i vi RIP. Chng ta thy thut ton
GVHD: Nguyn Minh Hi Trang 11

Ti: Tm Hiu V M Hnh OSPF 201

2
chn ng nh vy rt n gin v khng i hi nhiu b nh v nng lng x l ca router. RIP khng h quan tm n bng thng ng truyn khi quyt nh chn ng. OSPF th chn ng da vo chi ph c tnh t bng thng ca ng truyn. Mi OSPF router u c thng tin y v cu trc ca h thng mng da vo t tnh ton chn ng tt nht. Do thut ton chn ng ny rt phc tp, i hi nhiu b nh v nng lc x l ca router cao hn so vi RIP. RIP s dng cu trc mng dng ngang hng. Thng tin nh tuyn c truyn ln lt cho mi router trong cng mt h thng RIP. OSPF s dng khi nim v phn vng. Mt mng OSPF c th chia cc router thnh nhiu nhm. Bng cch ny, OSPF c th gii hn lu thng trong tng vng. Thay i trong vng ny khng nh hng n hot ng ca cc vng khc. Cu trc phn cp nh vy cho php h thng mng c kh nng m rng mt cch hiu qu. 2.1. Thut ton chn ng ngn nht. Trong phn ny s gii thch cch OSPF s dng thut ton chn ng ngn nht nh th no. Theo thut ton ny, ng tt nht l ng c chi ph thp nht. Edsger Wybe Dijkstra, mt nh khoa hc my tnh ngi H Lan, pht minh thut ton ny nn n cn c tn l thut ton Dijkstra. Thut ton ny xem h thng mng l mt tp hp cc nodes c kt ni vi nhau bng kt ni im-n-im. Mi kt ni ny c mt chi ph. Mi node c mt ci tn. Mi node c y c s d liu v trng thi ca cc ng lin kt, do chng c y thng tin v cu trc vt l ca h thng mng. Tt c cc c s d liu ny u ging nhau cho mi router trong cng mt vng. V d nh trn hnh 2.1.a, D c cc thng tin l n kt ni ti node C bng ng lin kt c chi ph l 4 v n kt ni n node E bng ng lin kt c chi ph l 1. Thut ton chn ng ngn nht s s dng bn thn node lm im xut pht v kim tra cc thng tin m n c v cc node k cn.
GVHD: Nguyn Minh Hi Trang 12

Ti: Tm Hiu V M Hnh OSPF 201

2
Trong hnh 2.1.b, node B chn ng n D. ng tt nht n D l i bng ng ca node E c chi ph l 4. Nh vy l gi d liu i t B n D s i theo ng t B qua C qua E ri n D. Node B chn ng n node F l ng thng qua node C c chi ph l 5. Mi ng khc u c th b lp vng hoc c chi ph cao hn.

Hnh 2.1.a

GVHD: Nguyn Minh Hi

Trang 13

Ti: Tm Hiu V M Hnh OSPF 201

2
Hnh 2.1.b

2.2. Cc loi mng OSPF Cc OSPF router phi thit lp mi quan h lng ging trao i thng tin nh tuyn. Trong mi mt mng IP kt ni vao router, n u c gng t nht l tr thnh mt lng ging hoc l lng ging thn mt vi mt router khc. Router OSPF quyt nh chn router no lm lng ging thn mt l tu thuc vo mng kt ni ca n. C mt s router c th c gng tr thnh lng ging thn mt vi mi router lng ging khc. C mt s router khc li c th ch c gng tr thnh lng ging thn mt vi mt hoc hai router lng ging thi. Mt khi mi quan h lng ging thn mt c thit lp gia hai lng ging vi nhau th thng tin v trng thi ng lin kt mi c trao i. Giao tip OSPF nhn bit ba loi mng sau: Mng qung b a truy cp, v d nh mng Ethernet. Mng im-ni-im. Mng khng qung b a truy cp (NBMA Nonbroadcast multiaccess), v d nh Frame Relay. Loi mng th 4 l mng im-n-nhiu im c th c nh qun tr mng cu hnh cho mt cng ca router.

Hnh 2.2.a. Ba loi mng ca OSPF.

Trong mng a truy cp khng th bit c l c bao nhiu router s c th


GVHD: Nguyn Minh Hi Trang 14

Ti: Tm Hiu V M Hnh OSPF 201

2
kt ni c kt ni vo mng. Trong mng im-n-im ch c hai router kt ni vi nhau.Trong mng qung b a truy cp c rt nhiu router kt ni vo. Nu mi router u thit lp mi quan h thn mt vi mi router khc v thc hin trao i thng tin v trng thi ng lin kt vi mi router lng ging th s qu ti. Nu c 10 router th s cn 45 mi lin h thn mt, nu c n router th s c n*(n1)/2 mi quan h lng ging thn mt cn c thit lp.Gii php cho vn qu ti trn l bu ra mt router lm i din (DR Designated Router). Router ny s thit lp mi quan h thn mt vi mi router khc trong mng qung b. Mi router cn li s ch gi thng tin v trng thi ng lin kt cho DR. Sau DR s gi cc thng tin ny cho mi router khc trong mng bng a ch mutlticast 224.0.0.5. DR ng vai tr nh mt ngi pht ngn chung.Vic bu DR rt c hiu qu nhng cng c mt s nhc im. DR tr thnh mt tm im nhy cm i vi s c. Do , cn c mt router th hai c bu ra lm router i din d phng (BDR Backup Designated Router), router ny s m trch vai tr ca DR nu DR b s c. m bo c DR v BDR u nhn c cc thng tin v trng thi ng lin kt t mi router khc trong cng mt mng, chng ta s dng a ch multicast 224.0.0.6 cho cc router i din.

Hnh 2.2.b. DR v BDR nhn cc gi LSAs

Trong mng im-ni-im ch c 2 router kt ni vi nhau nn khng cn bu ra DR v BDR. Hai router ny s thit lp mi quan h lng ging thn mt vi nhau .
GVHD: Nguyn Minh Hi Trang 15

Ti: Tm Hiu V M Hnh OSPF 201

Hnh 2.2.c

2.3. Giao thc OSPF Hello Khi router bt u khi ng tin trnh nh tuyn OSPF trn mt cng no th n s gi mt gi hello ra cng v tip tc gi hello theo nh k. Giao thc Hello a ra cc nguyn tc qun l vic trao i cc gi OSPF Hello. Lp 3 ca m hnh OSI, gi hello mang a ch multicast 224.0.0.5. a ch ny ch n tt c cc OSPF router. OSPF router s dng gi hello thit lp mt quan h lng ging thn mt mi xc nh l router lng ging c cn hot ng hay khng. Mc nh, hello c gi i 10 giy 1 ln trong mng qung b a truy cp v mng im-ni-im. Trn cng ni vo mng NBMA, v d nh Frame Relay, chu k mc nh ca hello l 30 giy.Trong mng a truy cp, giao thc hello tin hnh bu DR v BDR.Mc d gi hello rt nh nhng n cng bao gm c phn header ca gi OSPF. Cu trc ca phn header trong gi OS c th hin trn hnh 2.3.a. Nu l gi hello th trng Type s c gi tr l 1.

GVHD: Nguyn Minh Hi

Trang 16

Ti: Tm Hiu V M Hnh OSPF 201

2
Hnh 2.3.a. Phn header ca gi OSPF Gi hello mang nhng thng tin thng nht gia mi lng ging vi nhau trc khi c th thit lp mi quan h lng ging thn mt v trao i thng tin v trng thi cc ng lin kt.

Hnh 2.3.b. Phn header ca gi OSPF Hello. Cc thng tin trong phn Hello Interval, ea Interval v Router ID phi ng nht th cc router mi c th thit lp mi quan h lng ging thn mt.

2.4. Cc bc hot ng ca OSPF Khi bt u khi ng tin trnh nh tuyn OSPF trn mt cng no , n s gi gi Hello ra cng v tip tc gi hello theo nh k. Giao thc Hello l mt tp hp cc nguyn tc qun l vic trao i gi Hello. Gi Hello mang cc thng tin cn thng nht gia mi router lng ging trc khi c th thit lp mi quan h thn mt v trao i thng tin v trng thi cc ng lin kt. Trong mng a truy cp, giao thc Hello s bu ra mt DR v BDR. DR v BDR duy tr mi quan h thn mt vi mi router OSPF cn li trong cng mt mng.

GVHD: Nguyn Minh Hi

Trang 17

Ti: Tm Hiu V M Hnh OSPF 201

Hnh 2.4.a. Bc 1: pht hin cc router lng ging. Trong tng mng IP kt ni vo router, router c gng thit lp mi quan h thn mt vi t nht mt lng ging.

Hnh 2.4.b. Bc 2: bu ra DR v BDR. Qu trnh ny ch c thc hin trong mng a truy cp.

Cc router c mi quan h thn mt ln lt thc hin cc bc trao i thng tin v trng thi cc ng lin kt. Sau khi hon tt qu trnh ny cc trng thi gi la full state. Mi router gi thng tin qung co v trng thi cc ng lin kt trong gi LSAs (Link-State Advertisements) v gi thng tin cp nht cc trng thi ny trong gi LSUs (Link-State Updates). Mi router nhn cc gi LSAs ny t lng ging ri ghi nhn thng tin vo c s dl iu ca n. Tin trnh ny c lp li trn mi router trong mng OSPF. Khi c s d liu v trng thi cc ng lin kt y , mi router p dng thut ton SPF t tnh ton
GVHD: Nguyn Minh Hi Trang 18

Ti: Tm Hiu V M Hnh OSPF 201

2
chn ng tt nht da trn c s d liu m n c. ng ngn nht l ng c chi ph thp nht n mng ch.

Hnh 2.4.c. Bc 3: p dng thut ton SPF vo c s d liu v trng thi cc ng lin kt chn ng tt nht a ln bng nh tuyn.

Sau cc thng tin nh tuyn cn phi c bo tr. Khi c mt s thay i no v trng thi ca ng lin kt, router lp tc pht thng bo cho mi router khc trong mng. Thi gian Dead interval trong giao thc Hello l mt thng s n gin xc nh mt router lng ging thn mt cn hot ng hay khng.

GVHD: Nguyn Minh Hi

Trang 19

Ti: Tm Hiu V M Hnh OSPF 201

Hnh 2.4.d. R1 pht hin mt lin kt b t v gi LSU cho DR bng a ch multicast 224.0.0.6. DR gi bo nhn cho R1.

GVHD: Nguyn Minh Hi

Trang 20

Ti: Tm Hiu V M Hnh OSPF 201

Hnh 2.4.e. Tip theo DR gi LSU mi nhn cho tt c cc router cn li trong cng mt mng bng a ch multicast 224.0.0.5. Sau khi nhn c LSU, cc router gi bo nhn li cho DR.

Hnh 2.4.f. Nu router OSPF no cn c kt ni n mng khc th n s


GVHD: Nguyn Minh Hi Trang 21

Ti: Tm Hiu V M Hnh OSPF 201

2
chuyn tip LSU ra mng .

Hnh 2.4.g. Sau khi nhn c LSU vi thng tin mi, router OSPF s cp nht vo c s d liu ca n ri p dng thut ton SPF vi thng tin mi ny tnh ton li bng nh tuyn.

3. Cu hnh OSPF n vng 3.1. Cu hnh tin trnh nh tuyn OSPF nh tuyn OSPF s dng khi nim v vng. Mi router xy dng mt c s d liu y v trng thi cc ng lin kt trong mt vng. Mt vng trong mng OSPF c cp s t 0 n 65.535. Nu OSPF n vng th l vng 0. Trong mng OSPF a vng, tt c cc vng u phi kt ni vo vng 0. Do vng c gi l vng xng sng.Trc tin, bn cn khi ng tin trnh nh tuyn OSPF trn router, khai bo a ch mng v ch s vng. a ch mng c khai bo km theo wilcard mask ch khng phi l subnet mask. Ch s danh nh (ID) ca vng c vit di dng s hoc di dng s thp phn c du chm tng t nh IP. khi ng nh tuyn OSPF bn dng lnh sau trong ch cu hnh ton cc: Router (config)#router ospf process-id Process-id l ch s xc nh tin trnh ng tuyn OSPF trn router. Bn c th khi ng nhiu tin trnh OSPF trn cng mt router. Ch s ny c th l bt k gi tr no trong khong t 1 n 65.535. a s cc nh qun tr mng thng gi ch s process-id ny ging nhau trong cng mt h t qun, nhng iu ny l khng bt buc. Rt him khi no bn
GVHD: Nguyn Minh Hi Trang 22

Ti: Tm Hiu V M Hnh OSPF 201

2
cn chy nhiu hn mt tin trnh OSPF trn mt router. Bn khai bo a ch mng cho OSPF nh sau: Router(config-router)#network address wildcard-mask area area-id. Mi mng c quy c thuc v mt vng. Adress c th l a ch ca ton mng, hoc l mt subnet hoc l a ch ca mt cng giao tip. Wildcard-mask s xc nh chui a ch host nm trong mng m bn cn khai bo.

Hnh 3.1. Cu hnh OSPF c bn

3.2. Cu hnh a ch loopback cho OSPF v quyn u tin cho router Khi tin trnh OSPF bt u hot ng, Cisco IOS s dng a ch IP ln nht ang hot ng trn router lm router ID. Nu khng c cng no ang hot ng th tin trnh OSPF khng th bt u c. Khi router chn a ch IP ca mt cng lm router ID v sau cng ny b s c th tin trnh s b mt router ID.Khi tin trnh OSPF s bi ngng hot ng cho n khi cng hot ng tr li. m bo cho OSPF hot ng n nh chng ta cn phi c mt cng lun lun tn ti cho tin trnh OSPF. Chnh v vy cn cu hnh mt cng loopback l mt cng lun l ch khng phi cng vt l. Nu c mt cng loopback c cu hnh th OSPF s s dng a ch ca cng loopback lm router ID m khng quan tm n gi tr ca a ch nyNu trn router c nhiu hn mt cng loopback th OSPF s chn a ch IP ln nht trong cc a ch IP ca cc cng loopback lm
GVHD: Nguyn Minh Hi Trang 23

Ti: Tm Hiu V M Hnh OSPF 201

2
router ID. to cng loopback v t a ch IP cho n bn s dng cc lnh sau: Router (config)#interface loopback numberRouter (config-if)#ip address ipaddress subnet-mask Bn nn s dng cng loopback cho mi router chy OSPF. Cng loopback ny nn c cu hnh vi a ch c subnet mask l 255.255.255.255. a ch 32-bit subnet mask nh vy gi l host mask v subnet mask ny xc nh mt a ch mng ch c mt host. Khi OSPF pht qung co v mng loopback, OSPF s lun lun qung co loopback nh l mt host vi 32-bit mask.

Hnh 3.2.a. Cng loopback ch l mt cng phn mm. xo cng loopback bn dng dng no ca cu lnh to cng.

Trong mng qung b a truy cp c th c nhiu hn hai router. Do , OSPF bu ra mt router i din (DR Designated Router) lm im tp trung tt c cc thng tin qung co v cp nht v trng thi ca cc ng lin kt. V vai tr ca DR rt quan trng nn mt router i din d phng (BDR Backup Designated Router) cng c bu ra thay th khi DR b s c. i vi cng kt ni vo mng qung b, gi tr u tin mc nh ca OSPF trn cng l 1. Khi gi tr OSPF u tin ca cc router u bng nhau th OSPF s bu DR da trn router ID. Router ID no ln nht s c chn.Bn c th quyt nh kt qu bu chn DR bng cch t gi tr u tin cho cng cua router kt ni vo mng . Cng ca router no c gi tr u tin cao nht th router chc chn l DR. Gi tr u tin c th t bt k gi tr no nm trong khong t 0 n 255. Gi tr 0 s lm
GVHD: Nguyn Minh Hi Trang 24

Ti: Tm Hiu V M Hnh OSPF 201

2
cho router khng bao gi c bu chn. Router no c gi tr u tin. OSPF cao nht s c chn lm DR. Router no c v tr u tin th 2 s l BDR. Sau khi bu chn xong, DR v BDR s gi lun vai tr ca n cho d chng ta c t thm router mi vo mng vi gi tr u tin OSPF cao hn. thay i gi tr u tin OSPF, bn dng lnh ip ospf priority trn cng no cn thay i. Bn dng lnh showip ospf interface c th xem c gi tr u tin ca cng v nhiu thng tin quan trng khc. Router(config-if)#ip ospf priority number Router#show ip ospf interfacetype number.

Hnh 3.2.b. Trong gi hello pht ra cng Fast Ethernet 0/0, trng Router Priority s c gi tr l 50

GVHD: Nguyn Minh Hi

Trang 25

Ti: Tm Hiu V M Hnh OSPF 201

Hnh 3.2.c. Gi OSPF Hello.

Hnh 3.2.d

Hnh 3.2.e. Bu DR v BDR trong mng qung b a truy cp


GVHD: Nguyn Minh Hi Trang 26

Ti: Tm Hiu V M Hnh OSPF 201

2
Ta xt v d trong hnh 3.2.d. RTA va RTB s thc hin bu DR v BDR trong hai mng Ethernet qung b a truy cp. Cn mng PPP gia RTB v RTC l mng im-ni-im nn khng thc hin bu DR v BDR. Trong mng Ethernet 10.4.0.0/16 kt ni gia RTA v RTB gi s gi tr u tin trn 2 cng Ethernet ca RTA v RTB u bng nhau v bng gi tr mc nh l 1. Khi router no c router ID ln nht trong mng ny s c bu lm DR. Router ID ca RTA l 10.5.0.1, router ID ca RTB l 10.6.0.1. Vy RTB lm DR v RTA lm BDR. 3.3. Thay i gi tr chi ph ca OSPF OSPF s dng chi ph lm thng s chn ng tt nht. Gi tr chi ph ny lin quan n ng truyn v d liu nhn vo ca mt cng trn router. Ni tm li, chi ph ca mt kt ni c tnh theo cng thc 108/bng thng, trong bng thng c tnh theo n v bit/s. Ngi qun tr mng c th cu hnh gi tr chi ph bng nhiu cch. Cng no c chi ph thp th cng s c chn chuyn d liu. Cisco IOS t ng tnh chi ph da trn bng thng ca cng tng ng.Do , OSPF hot ng ng bn cn cu hnh bng thng ng cho cng ca router. Router(config)#interface serial 0/0 Router(config-if)#bandwidth 64 Gi tr bng thng mc nh ca cng Serial Cisco l 1,544Mbps hay 1544kbs

Hnh 3.3.a. Gi tr chi ph OSPF mc nh ca Cisco IOS

Gi tr chi ph thay i s nh hng n kt qu tnh ton ca OSPF. Trong mi trng nh tuyn c nhiu hng khc nhau, bn s phi thay i gi tr chi ph gi tr chi ph ca hng ny tng thch vi gi tr chi ph ca hng kia. Mt
GVHD: Nguyn Minh Hi Trang 27

Ti: Tm Hiu V M Hnh OSPF 201

2
trng hp khc bn cn thay i gi tr chi ph khi s dng Gigabit Ethernet. Gi tr chi ph mc nh thp nht, gi tr 1, l tng ng vi kt ni 100Mbs. Do , khi trong mng va co 100Mbs va Gigabit Ethernet th gi tr chi ph mc nh s lm cho vic nh tuyn c th khng ti u. Gi tr chi phi nm trong khong t 1 n 65.535.Bn s dng cu lnh sau trong ch cu hnh cng tng ng ci t gi tr chi ph cho cng : Router (config-if)#ip ospf cost number

Hnh 3.3.b. Cu hnh gi tr chi ph cho mt cng ca router

3.4. Cu hnh qu trnh xc minh cho OSPF. Cc router mc nhin tin rng nhng thng tin nh tuyn m n nhn c l dong router tin cy pht ra v nhng thng tin ny khng b can thip dc ng i m bo iu ny, cc router trong mt vng cn c cu hnh thc hin xc minh v nhau.Mi mt cng OSPF trn router cn c mt cha kho xc minh s dng khi gi cc thng tin OSPF cho cc router khc cng kt ni vi cng . Cha kha xc minh, hay cn gi l mt m, c chia s gia hai router. Cha kho ny s dng to ra d liu xc minh (trng Authentication data) t trong phn header ca gi OSPF. Mt m ny c th di n 8 k t. Bn s dng cu lnh sau cu hnh mt m xc minh cho mt cng OSPF: Router (config-if)#ip ospf authentication-keypassword Sau khi cu hnh mt m xong, bn cn bt ch xc minh cho OSPF: Router(config-router)#areaarea-number authentication

GVHD: Nguyn Minh Hi

Trang 28

Ti: Tm Hiu V M Hnh OSPF 201

Hnh 3.4.a. Phn header ca gi OSPF

Vi c ch xc minh n gin trn, mt m c gi i di dn vn bn. Do n d dng c gii m nu gi OSPF b nhng k tn cng bt c. Chnh v vy cc thng tin xc minh nn c mt m li. m bo an ton hn v thc hin mt m thng tin xc minh, bn nn cu hnh mt m message-digest bng cu lnh sau trn cng tng ng ca router: Router( config-)#ip ospf message-digest-key MD5 l mt thut ton mt m thng ip message-digist. Nu bn t tham s encryption-type gi tr 0 c ngha l khng th hin mt m, cn gi tr 7 c ngha l thc hin mt m theo cch c quyn ca Cisco. Tham s key-id l mt con s danh nh c gi tr t 1 n 255. Tham s key l phn cho bn khai bo mt m, c th di n 16 k t. Cc router lng ging bt buc phi c cng s key-id c cng gi tr key. Sau khi cu hnh mt m MD5 xong bn cn bt ch xc minh message-digest trong OSPF: Router (config-router)#areaarea-id authentication message-digest

Hnh 3.4.b. Cu hnh c ch xc minh MD5 cho OSPF

T mt m v ni dung ca gi d liu, thut ton mt m MD5 s to ra mt thng ip gn thm vo gi d liu. Router nhn gi d liu s dng mt m
GVHD: Nguyn Minh Hi Trang 29

Ti: Tm Hiu V M Hnh OSPF 201

2
mbn thn router c kt hp vi gi d liu nhn c to ra mt thng ip. Nu kt qu hai thng ip ny ging nhau th c ngha l l router nhn c gi d liu t ng ngun v ni dung gi d liu khng b can thip. Cu trc phn header ca gi OSPF nh trn hnh 3.4.a. Trng authentication type cho bit c ch xc minh l c ch no. Nu c ch xc minh l message-digest th trng authentication data s c cha key-id v thng s cho bit chiu di ca phn thng ip gn thm vo gi d liu. Phn thng ip ny ging nh mt con du khng th lm gi c. 3.5. Cu hnh cc thng s thi gian ca OSPF. Cc router OSPF bt buc phi c khong thi gian hello v khong thi gian bt ng vi nhau mi c th thc hin trao i thng tin vi nhau. Mc nh, khong thi gian bt ng bng bn ln khong thi gian hello. iu ny c ngha l mt router c n 4 c hi gi gi hello trc khi n xc nh l cht Trong mng OSPF qung b, khong thi gian hello mc nh l 10 giy, khong thi gian bt ng mc nh l 40 giy. Trong mng khng qung b, khong thi gian hello mc nh l 30 giy v khong thi gian bt ng mc nh l 120 giy. Cc gi tr mc nh ny c nh hng n hiu qu hot ng ca OSPF v i khi bn cn phi thay i chng. Ngi qun tr mng c php la chn gi tr cho hai khong thi gian ny. tng hiu qu hot ng ca mng bn cn u tin thay i gi tr ca hai khong thi gian ny. Tuy nhin, cc gi tr ny phi c cu hnh ging nhau cho mi router lng ging kt ni vi nhau. cu hnh khong thi gian hello v khong thi gian bt ng trn mt cng ca router, bn s dng cu lnh sau: Router (config-if)#ip ospf hello-interval seconds Router (config-if)#ip ospf dead-interval seconds

GVHD: Nguyn Minh Hi

Trang 30

Ti: Tm Hiu V M Hnh OSPF 201

Hnh 3.5

3.6. OSPF thc hin qung b ng mc nh nh tuyn OSPF m bo cc con ng n tt c cc mng ch trong h thng khng b lp vng. n c cc mng nm ngoi h thng th OSPF cn phi bit v mng hoc l phi c ng mc nh. Tt nht l s dng ng mc nh v nu router phi lu li tng ng i cho mi mng ch trn th gii th s tn mt lng ti nguyn khng l .Trn thc t, chng ta khai bo ng mc nh cho router OSPF no kt ni ra ngoi. Sau thng tin v ng mc nh ny c phn phi vo cho cc router khc trong h t qun (AS autonomous system) thng qua hot ng cp nht bnh thng ca OSPF. Trn router c cng kt ni ra ngoi, bn cu hnh mc nh bng cu lnh sau: Router (config)#ip route 0.0.0.0 0.0.0.0 [interface | next-hop address ] Mng tm s 0 nh vy tng ng vi bt k a ch mng no. Sau khi cu hnh ng mc nh xong, bn cu hnh cho OSPF chuyn thng tin v ng mc nh cho mi router khc trong vng OSPF: Router (config-router) #default information originate Mi router trong h thng OSPF s nhn bit c l c ng mc nh trn router bin gii kt ni ra ngoi.

GVHD: Nguyn Minh Hi

Trang 31

Ti: Tm Hiu V M Hnh OSPF 201

Hnh 3.6. ng mc nh ch c s dng khi khng tm thy ng no khc trong bng nh tuyn.

3.7. Nhng li thng gp trong cu hnh OSPF OSPF router phi thit lp mi quan h lng ging hoc thn mt vi OSPF router khc trao i thng tin nh tuyn. Mi quan h ny khng thit lp c c th do nhng nguyn nhn sau: C hai bn lng ging vi nhau u khng gi Hello. Khong thi gian Hello v khong thi gian bt ng khng ging nhau gia cc router lng ging. Loi cng giao tip khc nhau gia cc router lng ging. Mt m xc minh v cha kho khc nhau gia cc router lng ging. Trong cu hnh nh tuyn OSPF vic m bo tnh chnh xc ca cc thng tin sau cng v cng quan trng. Tt c cc cng giao tip phi c a ch v subnet mask chnh xc. Cu lnh network area phi c wildcard mask chnh xc. Cu lnh network area phi khai bo ng area m network thuc v. 3.8. Kim tra cu hnh OSPF kim tra cu hnh OSPF bn c th dng cc lnh show c lit k trong bng. 2.3.8.a. Bng 2.3.8.b lit k cc lnh show hu dng cho bn khi tm s c OSPF. ca
Bng 3.8.a. Cc lnh show dng kim tra cu hnh OSPF
GVHD: Nguyn Minh Hi Trang 32

Ti: Tm Hiu V M Hnh OSPF 201

2
Lnh protocol Gii thch Show ip Hin th cc thng tin v thng s thi gian, thng s nhtuyn, mng nh tuyn v nhiu thng tin khc ca tt ccc giao thc nh tuyn ang hot ng trn router. Show ip Hin th bng nh tuyn ca router, trong l danh schcc ng tt nht n cc mng ch ca bn thn router v cho bit router hc c cc ng i ny bng cch no. Show ip ospf Lnh ny cho bit cng ca router c cu hnh ngvi vng m n thuc v hay khng. Nu cng loopback khng c cu hnh th ghi a ch IP ca cng vt l no cgi tr ln nht s c chn lm router ID. Lnh ny cng hin th cc thng s ca khong thi gian hello v khongthi gian bt ng trn cng , ng thi cho bit cc router lng ging thn mt kt ni vo cng. Show ospf Lnh ny cho bit s ln s dng thut ton SPF, ngthi cho bit khong thi gian cp nht khi mng khng c g thay i . Show ip ospf Lit k chi tit cc lng ging, gi tr u tin ca chng v trng thi ca chng Show ip ospf Hin th ni dung ca c s d liu v cu trc h thng mng trn router, ng thi cho bit router ID, ID ca tintrnh OSPF.

route

interface

ip Neighbordetail database

Bng 3.8.b. Cc lnh clear v debug dng kim tra hot ng OSPF Lnh
Clear ip route * Clear ip route a.b.c.d Debug ip ospf events Debug ip ospf adj

Gii thch Xo ton b bng nh tuyn. Xo ng a.b.c.d trong bng nh tuyn. Bo co mi s kin ca OSPF Bo co mi s kin v hot ng quan h thn mt ca OSPF.

TNG KT

Sau y l cc im quan trng bn cm nm c trong chng ny: Cc c im ca nh tuyn theo trng thi ng lin kt. Thng tin nh tuyn theo trng thi ng lin kt c xy dng v bo tr nh th no. Thut ton nh tuyn theo trng thi ng lin kt.
GVHD: Nguyn Minh Hi Trang 33

Ti: Tm Hiu V M Hnh OSPF 201

2
u v nhc im ca nh tuyn theo trng thi ng lin kt. So snh nh tuyn theo trng thi ng lin kt vi nh tuyn theo vecto khong cch. Cc thut ng OSPF. Cc loi mng OSPF. Hot ng ca thut ton chn ng ngn nht SPF. Giao thc OSPF Hello. Cc bc c bn trong hot ng ca OSPF. Khi ng OSPF trn router. Cu hnh cng loopback t quyn u tin cho router. Thay i quyt nh chn ng ca OSPF bng cch thay i thng s chi ph. Cu hnh qu trnh xc minh cho OSPF. Thay i cc thng s thi gian ca OSPF. To v qung b ng mc nh. S dng cc lnh show kim tra hot ng ca OSPF.

GVHD: Nguyn Minh Hi

Trang 34

Ti: Tm Hiu V M Hnh OSPF 201

TI LIU THAM KHO


[1] Ivan Pepelnjak and Jim Guichard,MPLS and VPN ARCHITECTURES, Cisco Press. [2] Clare Gough, Cisco CCNP Routing ExamCertification Guide, Cisco Press. [3] Cc ti liu v Mng Vit Nam do VTN cung cp. [4] Cisco-OSPF Design Guide -2005. [5] http://www.Cisco.com [6] http://www.quantrimang.com.vn [7] http://www.vnpro.com

GVHD: Nguyn Minh Hi

Trang 35