ospf 動態路由協議 Cisco

拓撲圖:

配置代碼:

R1
enable
config terminal
host r1
no ip domain-lookup
int g0/0
ip address 192.168.1.1 255.255.255.0
no shut
exit
router ospf 100 
!進程號,1-65535中任意數,且這個是路由器本地進程號,即其它路由器也可以設置一樣的進程號
!OSPF路由協議的進程號爲100,一個路由器上可啓用多個OSPF進程,以進程號作爲區別標誌
network 192.168.1.0 0.0.0.255 area 1
router-id 192.168.1.1  
!這個路由器有多個接口,誰代表本區域跟別的交換鏈路狀態數據報呢?就是路由id是誰呢?指定路由id,不指定也會進行選舉(優先級一樣時,誰的ip地址大,就做)
exit

R2
enable
config terminal
host r2
no ip domain-lookup
int g0/0
ip address 192.168.1.2 255.255.255.0
no shut
exit
int g0/1
ip address 192.168.2.1 255.255.255.0
no shut
exit
router ospf 100
log-adjacency-changes
!當一個OSPF域的鄰接關係改變時,用日誌記錄
network 192.168.1.0 0.0.0.255 area 1
network 192.168.2.0 0.0.0.255 area 0
router-id 192.168.2.1
!強制指定router-id爲192.168.2.1。router-id(RID)的作用是在一個OSPF域(area)的路由器羣中作爲選舉DR(指定路由器)及BDR(備份指定路由器)的重要指標,當各個路由器的優先級(priority)相同時,RID最高者爲DR。注:在一個OSPF域內的路由器交換OSPF路由信息時,不是兩兩交互的,而是由DR收集併發布
exit

R3
enable
config terminal
host r3
no ip domain-lookup
!下面設置接口的IP參數
int g0/0
ip address 192.168.2.2 255.255.255.0
no shut
exit
int g0/1
ip address 192.168.3.1 255.255.255.0
no shut
exit
int loopback 0
!環回口,一般常用環回口來做router-id
ip address 3.3.3.3 255.255.255.255
no shut
exit
router ospf 100
network 192.168.2.0 0.0.0.255 area 0
network 192.168.3.0 0.0.0.255 area 2
router-id 3.3.3.3
!一般常用環回口來做router-id
!area 2 virtual-link 4.4.4.4
exit

R4
enable
config terminal
host r4
no ip domain-lookup
int g0/0
ip address 192.168.3.2 255.255.255.0
no shut
exit
int g0/1
ip address 192.168.4.1 255.255.255.0
no shut
exit
int loopback 0
ip address 4.4.4.4 255.255.255.255
no shut
exit
router ospf 100
network 192.168.3.0 0.0.0.255 area 2
network 192.168.4.0 0.0.0.255 area 3
router-id 4.4.4.4
!area 2 virtual-link 3.3.3.3
exit

R5
enable
config terminal
host r5
no ip domain-lookup
int g0/0
ip address 192.168.4.2 255.255.255.0
no shut
exit
int loopback 0
ip address 5.5.5.5 255.255.255.255
no shut
exit
router ospf 100
network 192.168.4.0 0.0.0.255 area 3
router-id 5.5.5.5
Exit

R1:

R2:

R3:

R4:

R5:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章