Lab_2 OSPF
Lab_2 OSPF
一.OSPF鄰接關系的建立流程... 2
二.NBMA下的OSPF. 20
三.虛鏈路... 28
四.認證... 31
五.外部匯總/ospf與rip的重發(fā)布... 36
?
?
?
一. OSPF鄰接關系的建立流程
1.Down: 初始化狀態(tài).
2.Attempt: 只適于NBMA網(wǎng)絡,在NBMA網(wǎng)絡中鄰居是手動指定的,在該狀態(tài)下,路由器將使用HelloInterval取代PollInterval來發(fā) 送Hello包.
3.Init: 表明在DeadInterval里收到了Hello包,但是2-Way通信仍然沒有建立起來.
4.two-way: 雙向會話建立.
5.ExStart: 信息交換初始狀態(tài),在這個狀態(tài)下,本地路由器和鄰居將建立Master/Slave關系,并確定DD Sequence Number,接口等級高的的成為Master。
.
6.Exchange: 信息交換狀態(tài),本地路由器向鄰居發(fā)送數(shù)據(jù)庫描述包,并且會發(fā)送LSR用于請求新的LSA
.
7.Loading: 信息加載狀態(tài),本地路由器向鄰居發(fā)送LSR用于請求新的LSA
.
8.Full: 完全鄰接狀態(tài),這種鄰接出現(xiàn)在Router LSA和Network LSA中
Debug ip ospf packet
Debug ip ospf events
Debug ip ospf adj
Debug ip packet
狀態(tài)
1.down 停止狀態(tài)
2.init 初始狀態(tài) 收到一個hello包后進入(形成鄰居表)
3.two-way 雙向狀態(tài) hello包中包含已知鄰居列表 ,發(fā)現(xiàn)自己在hellow包中時,選舉DR,BDR
4.exstart 準啟動狀態(tài) 掙選優(yōu)先級(誰先說話/DR先發(fā)包)
5.exchange 交換狀態(tài) 交換DBD(鏈路狀態(tài)描述)分組僚屬鏈路狀態(tài)數(shù)據(jù)庫(并返回ACK,進入下一個狀態(tài))
6.loading 加載狀態(tài) 請求完整信息條目,發(fā)送LSU/返回LSUAck,進入下一個狀態(tài)
7.full adjacency 全鄰接狀態(tài) 拓撲表同步(運行SPF/形成路由表/--轉發(fā)數(shù)據(jù)庫)
04:25:18: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
//打開S0/0接口
04:25:18: OSPF: Interface Serial0/0 going Up
//OSPF進程啟動
04:25:18: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 64, sending broad/multicast
//發(fā)送hello包組播 由于debug ip ospf packet 無法捕獲到發(fā)送的hello包內容,所以這里無顯示
04:25:18: OSPF: Build router LSA for area 0, router ID 1.1.1.1, seq 0x8000000F
//構建LAS
04:25:19: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R1#
04:25:25: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 68, rcvd 0
04:25:25: OSPF: rcv. v:2 t:1 l:48 rid:2.2.2.2
aid:0.0.0.0 chk:F694 aut:0 auk: from Serial0/0
04:25:25: OSPF: Rcv hello from 2.2.2.2 area 0 from Serial0/0 12.1.1.2
//在S0/0收到來自12.1.1.2 的hello包,版本:2/類型:hello包/routerID:2.2.2.2/區(qū)域號:0/校驗:F694/無驗證/
04:25:25: OSPF: 2 Way Communication to 2.2.2.2 on Serial0/0, state 2WAY
//進入2way狀態(tài)
04:25:25: OSPF: Send DBD to 2.2.2.2 on Serial0/0 seq 0x15C2 opt 0x42 flag 0x7 len 32
//通過S0/0發(fā)送DBD到2.2.2.2 ,序列號:0x15C2 flag 0x7,這是第一個DBD包,以后還會繼續(xù)發(fā),我為主
04:25:25: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 52, sending broad/multicast
04:25:25: OSPF: End of hello processing
04:25:25: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 52, rcvd 0
04:25:25: OSPF: rcv. v:2 t:2 l:32 rid:2.2.2.2
aid:0.0.0.0 chk:A337 aut:0 auk: from Serial0/0
04:25:25: OSPF: Rcv DBD from 2.2.2.2 on Serial0/0 seq 0xEBF opt 0x42 flag 0x7 len 32 mtu 1500 state EXSTART
//在S0/0上收到到來自2.2.2.2的DBD包 序列號:0xEBF flag 0x7,這是第一個DBD包,以后還會繼續(xù)發(fā),我為主,并進入準啟動狀態(tài)
04:25:25: OSPF: NBR Negotiation Done. We are the SLAVE
//經(jīng)過一輪協(xié)商,發(fā)現(xiàn)我的routerid小于2.2.2.2所我為從
04:25:25: OSPF: Send DBD to 2.2.2.2 on Serial0/0 seq 0xEBF opt 0x42 flag 0x2 len 72
//給2.2.2.2發(fā)送一個DBD包確認,告訴他,我為從
04:25:25: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 92, sending broad/multicast
04:25:25: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 92, rcvd 0
04:25:25: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 56, rcvd 0
04:25:25: OSPF: rcv. v:2 t:2 l:72 rid:2.2.2.2
aid:0.0.0.0 chk:2B5E aut:0 auk: from Serial0/0
04:25:25: OSPF: rcv. v:2 t:3 l:36 rid:2.2.2.2
aid:0.0.0.0 chk:F5CF aut:0 auk: from Serial0/0
04:25:25: OSPF: Rcv DBD from 2.2.2.2 on Serial0/0 seq 0xEC0 opt 0x42 flag 0x3 len 72 mtu 1500 state EXCHANGE
04:25:25: OSPF: Send DBD to 2.2.2.2 on Serial0/0 seq 0xEC0 opt 0x42 flag 0x0 len 32
04:25:25: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 52, sending broad/multicast
04:25:25: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 56, sending broad/multicast
04:25:25: OSPF: Database request to 2.2.2.2
04:25:25: OSPF: sent LS REQ packet to 12.1.1.2, length 12
//
04:25:25: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 96, sending broad/multicast
04:25:25: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 52, rcvd 0
04:25:25: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 96, rcvd 0
04:25:25: OSPF: rcv. v:2 t:2 l:32 rid:2.2.2.2
aid:0.0.0.0 chk:A33B aut:0 auk: from Serial0/0
04:25:25: OSPF: rcv. v:2 t:4 l:76 rid:2.2.2.2
aid:0.0.0.0 chk:1373 aut:0 auk: from Serial0/0
04:25:25: OSPF: Rcv DBD from 2.2.2.2 on Serial0/0 seq 0xEC1 opt 0x42 flag 0x1 len 32 mtu 1500 state EXCHANGE
//雙方交換DBD包,并確認,進入到EXCHANGE狀態(tài),向12.1.1.2放松鏈路狀態(tài)請求(LS REQ),收到2.2.2.2來的LSU
04:25:25: OSPF: Exchange Done with 2.2.2.2 on Serial0/0
04:25:25: OSPF: Send DBD to 2.2.2.2 on Serial0/0 seq 0xEC1 opt 0x42 flag 0x0 len 32
//回復給2.2.2.2一個DBD包,確認雙方數(shù)據(jù)庫是否同步
04:25:25: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 52, sending broad/multicast
04:25:25: OSPF: Synchronized with 2.2.2.2 on Serial0/0, state FULL
04:25:25: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Serial0/0 from LOADING to FULL, Loading Done
//進入全鄰接狀態(tài)
04:25:26: OSPF: Build router LSA for area 0, router ID 1.1.1.1, seq 0x80000010
04:25:26: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 108, sending broad/multicast
04:25:26: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 108, rcvd 0
04:25:26: OSPF: rcv. v:2 t:4 l:88 rid:2.2.2.2
aid:0.0.0.0 chk:3067 aut:0 auk: from Serial0/0
04:25:28: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 64, rcvd 0
04:25:28: OSPF: rcv. v:2 t:5 l:44 rid:2.2.2.2
aid:0.0.0.0 chk:1EF9 aut:0 auk: from Serial0/0
04:25:28: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 64, sending broad/multicast
04:25:28: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 68, sending broad/multicast
R1#
04:25:30: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial0/0), len 108, sending broad/multicast
04:25:30: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 108, rcvd 0
04:25:30: OSPF: rcv. v:2 t:4 l:88 rid:2.2.2.2
aid:0.0.0.0 chk:3063 aut:0 auk: from Serial0/0
R1#
04:25:33: IP: s=12.1.1.2 (Serial0/0), d=224.0.0.5, len 64, rcvd 0
04:25:33: OSPF: rcv. v:2 t:5 l:44 rid:2.2.2.2
aid:0.0.0.0 chk:5C17 aut:0 auk: from Serial0/0
//同步數(shù)據(jù)庫,并發(fā)送LSA確認
1.1.點到點網(wǎng)絡, 比如T1線路,是連接單獨的一對路由器的網(wǎng)絡,點到點網(wǎng)絡上的有效鄰居總是可以形成鄰接關系的,在這種網(wǎng)絡上,OSPF包的目標地址使用的是224.0.0.5,這個組播地址稱為AllSPFRouters.
2.1.廣播型網(wǎng)絡,比如以太網(wǎng),Token Ring和FDDI,這樣的網(wǎng)絡上會選舉一個DR和BDR,DR/BDR的發(fā)送的OSPF包的目標地址為224.0.0.5,運載這些OSPF包的幀的目標MAC地址為0100.5E00.0005;而除了DR/BDR以外的OSPF包的目標地址為224.0.0.6,這個地址叫AllDRouters.
3.1.NBMA網(wǎng)絡, 比如X.25,Frame Relay,和ATM,不具備廣播的能力,因此鄰居要人工來指定,在這樣的網(wǎng)絡上要選舉DR和BDR,OSPF包采用unicast的方式
4.1.點到多點網(wǎng)絡 是NBMA網(wǎng)絡的一個特殊配置,可以看成是點到點鏈路的集合. 在這樣的網(wǎng)絡上不選舉DR和BDR.
5.1.虛鏈接: OSPF包是以unicast的方式發(fā)送
在P-P網(wǎng)絡,路由器是以組播方式將更新報文發(fā)送到組播地址224.0.0.5.
在P-MP和虛鏈路網(wǎng)絡,路由器以單播方式將更新報文發(fā)送至鄰接鄰居的接口地址.
在廣播型網(wǎng)絡,DRother路由器只能和DR&BDR形成鄰接關系,所以更新報文將發(fā)送到224.0.0.6,相應的DR以224.0.0.5泛洪LSA并且BDR只接收LSA,不會確認和泛洪這些更新,除非DR失效 在NBMA型網(wǎng)絡,LSA以單播方式發(fā)送到DR BDR,并且DR以單播方式發(fā)送這些更新.
二.NBMA下的OSPF
R1=center
R2=ISP
R3=Branch1
R4=Branch2
-----------------------------------------------------------------------------------
step1:
frame-relay switching
int s1/0
ISP(config-if)#encaps frame-relay
ISP(config-if)#no arp frame-relay
ISP(config-if)#no frame-relay inverse-arp
ISP(config-if)#frame-relay intf-type dce
ISP(config-if)#clo ra 64000
ISP(config-if)#frame-relay lmi-type ansi
ISP(config-if)#frame-relay route 102 int s1/1 201
ISP(config-if)#frame-relay route 103 int s1/2 301
ISP(config-if)#no shut
int s1/1
ISP(config-if)#encaps frame-relay
ISP(config-if)#no arp frame-relay
ISP(config-if)#no frame-relay inverse-arp
ISP(config-if)#frame-relay intf-type dce
ISP(config-if)#clo ra 64000
ISP(config-if)#frame-relay lmi-type ansi
ISP(config-if)#frame-relay route 201 int s1/0 102
ISP(config-if)#no shut
int s1/2
ISP(config-if)#encaps frame-relay
ISP(config-if)#no arp frame-relay
ISP(config-if)#no frame-relay inverse-arp
ISP(config-if)#frame-relay intf-type dce
ISP(config-if)#clo ra 64000
ISP(config-if)#frame-relay lmi-type ansi
ISP(config-if)#frame-relay route 301 int s1/0 103
ISP(config-if)#no shut
-----------------------------------------------------------------
#Central
step1:
Central(config)#int lo 0
Central(config-if)#ip add 1.1.1.1 255.255.255.0
Central(config-if)#ip ospf network point-to-point
Central(config)#int s1/1
Central(config-if)#encapsulation frame-relay
Central(config-if)#no arp frame-relay
Central(config-if)#no frame-relay inverse-arp
Central(config-if)#frame-relay lmi-type ansi
Central(config-if)#ip add 123.1.1.1 255.255.255.0
Central(config-if)#frame-relay map ip 123.1.1.2 102 broadcast
Central(config-if)#frame-relay map ip 123.1.1.3 103 broadcast
Central(config-if)#no shut
step2:
router ospf 1
Central(config-router)#route-id 1.1.1.1
Central(config-router)#network 123.1.1.1 0.0.0.0 a 0
Central(config-router)#network 1.1.1.1 0.0.0.0 a0
step3:
Central(config)#router ospf 1
Central(config-router)#neighbor 123.1.1.2
Central(config-router)#neighbor 123.1.1.3
---------------------------------------------------------------
#Branch1
step1:
Branch1(config)#int lo 0
Branch1(config-if)#ip add 2.2.2.2 255.255.255.0
Branch1(config-if)#ip ospf network point-to-point
Branch1l(config)#int s1/0
Branch1l(config-if)#encapsulation frame-relay
Branch1l(config-if)#no arp frame-relay
Branch1(config-if)#no frame-relay inverse-arp
Branch1(config-if)#frame-relay lmi-type ansi
Branch1(config-if)#ip add 123.1.1.2 255.255.255.0
Branch1(config-if)#frame-relay map ip 123.1.1.1 201 broadcast
Branch1(config-if)#frame-relay map ip 123.1.1.3 201 broadcast
Branch1(config-if)#no shut
step2:
router ospf 1
Branch1(config-router)#route-id 2.2.2.2
Branch1(config-router)#network 123.1.1.2 0.0.0.0 a 0
Branch1(config-router)#network 2.2.2.2 0.0.0.0 a0
step3:
Branch1(config)#int s1/0
Branch1(config)#ip ospf priority 0
----------------------------------------------------------------
#Branch2
setp1:
Branch2(config)#int lo 0
Branch2(config-if)#ip add 3.3.3.3 255.255.255.0
Branch2(config-if)#ip ospf network point-to-point
Branch2(config)#int s1/2
Branch2(config-if)#encapsulation frame-relay
Branch2(config-if)#no arp frame-relay
Branch2(config-if)#no frame-relay inverse-arp
Branch2(config-if)#frame-relay lmi-type ansi
Branch2(config-if)#ip add 123.1.1.3 255.255.255.0
Branch2(config-if)#frame-relay map ip 123.1.1.1 301 broadcast
Branch2(config-if)#frame-relay map ip 123.1.1.2 301 broadcast
Branch2(config-if)#no shut
step2:
router ospf 1
Branch1(config-router)#route-id 3.3.3.3
Branch1(config-router)#network 123.1.1.3 0.0.0.0 a 0
Branch1(config-router)#network 3.3.3.3 0.0.0.0 a0
step3:
Branch2(config)#int s1/2
Branch2(config)#ip ospf priority 0
此時如果no掉
branch1的 frame-relay map ip 123.1.1.3 201 broadcast
branch2的 frame-relay map ip 123.1.1.2 301 broadcast
就會出現(xiàn)有路由但無法PING通的現(xiàn)象,鏈路層封裝失敗
解決方案1
在Central上NO掉鄰居
然后在S1/1上輸入 ip ospf network point-to-mulitpoint
最好是在branch上也輸入,不輸入也行
解決方案2
子接口
為什么在NBMA上central沒有指鄰居為什么 還能收到Hello包
三.虛鏈路
| R2(config)#router ospf 1 R2(config-router)#area 1 virtual-link 3.3.3.3 R2(config-router)#exit R2(config)#exit |
| R3(config)#router ospf 1 R3(config-router)#area 1 virtual-link 2.2.2.2 R3(config-router)#exit R3(config)#exit |
命令中的area 2 指出有一條虛鏈路存在于區(qū)域2中。
virtual-link 172.16.255.9指出創(chuàng)建虛鏈路的對端R3路由器的router id。
注意:使用router id,而不是接口ip.
四.認證
查看R1和R2的路由表
明文認證
在R1上啟用OSPF的明文認證
在R2上啟用OSPF的認證
R2(config-if)#s0/0
R2(config-if)#ip ospf authentication-key cisco
R2(config-if)#ip ospf authentication-
基于MD5的密碼接口認證
首先在R1和R2上關閉明文認證
R1(config-if)#ip ospf authentication message-digest
R1(config-if)#ip ospf message-digest-key 1 md5 cisco
R2(config-if)#ip ospf authentication message-digest
R2(config-if)#ip ospf message-digest-key 1 md5 cisco
區(qū)域認證
在R1上啟用區(qū)域的明文認證
在R2上啟用區(qū)域明文認證
MD5
| R1(config)#router ospf 1 R1(config-router)#area 1 authentication message-digest R1(config-router)#interface serial 0/0 R1(config-if)#ip ospf message-digest-key 1 md5 cisco R2(config-if)#exit R2(config)# |
| R2(config)#router ospf 1 R2(config-router)#area 1 authentication message-digest R2(config-router)#exit R2(config)#int s0/0 R2(config-if)#ip ospf message-digest-key 1 md5 cisco R2(config-if)#exit R2(config)# |
當在接口出現(xiàn)兩條md5的密碼配置命令時,R2路由會發(fā)送兩份不同的分組數(shù)據(jù)包。分別使用1和2的密碼。
一旦新的密碼2可以使用了,原的密碼1就可以使用no命令取消。完成舊密碼到新密碼的遷移。
五.外部匯總/ospf與rip的重發(fā)布
查看路由表
在R3上配置重發(fā)布
查看路由表
在R3上進行外網(wǎng)的路由匯總
轉載于:https://blog.51cto.com/netpro/265988
《新程序員》:云原生和全面數(shù)字化實踐50位技術專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的Lab_2 OSPF的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 偏方使用不当担心被毁容! - 生活至上,
- 下一篇: 如何停止java线程