1. 程式人生 > >單區域OSPF路由協議實現網路區域互通

單區域OSPF路由協議實現網路區域互通

1、什麼是OSPF協議?

OSPF協議的全程是開放式最短路徑優先協議,協議採用鏈路狀態協議演算法(LS協議)

2、OSPF vs RIP

RIP路由協議是距離向量路由選擇協議,收斂速度慢,如果在一些大型網路中使用RIP協議,要實現全區域網路互通可能需要一點時間,因此,相較於RIP而言,OSPF路由協議更適合於大型網路。

3、OSPF協議配置的過程(主要指令)

router ospf x             //開啟ospf協議(其中x代指OSPF路由程序ID)

router-id x.x.x.x        //指定路由器的Router ID

network x.x.x.x 反掩碼 area x      //宣告路由器各個介面所在網路號及區域

4、要點提示

①OSPF路由程序ID的範圍必須是在1~65535,而且只有本地含義,不同路由器的程序ID可以是不同的,但如果要想啟動OSPF路由程序,至少確保有一個介面是UP的

②Router ID(區域ID)是在0~4294967295內的十進位制數,也可以是IP地址格式x.x.x.x,當網路的區域ID為0或0.0.0.0時稱為主幹區域

確定Router ID遵循如下的原則:

         最優先的是在OSPF程序中用命令router-id指定路由器ID

         如果沒有在OSPF程序中指定路由器的ID,那麼選擇IP地址最大的環回介面(loopback)的IP定為Router ID

         如果沒有環回介面(loopback),那麼就選擇最大活動的物理介面IP地址作為Router ID(建議用命令router-id來指定路由器ID,這樣可控性比較好)

③關於反掩碼:簡言之就是255.255.255.0→0.0.0.255

實驗拓撲:

詳細配置:

R0:

enable

conf t

hostname R0

no ip domain-lookup

int loop 0

ip add 1.1.1.1 255.255.255.0

no shu

int f0/0

ip add 192.168.12.1 255.255.255.0

no shu

exit

router ospf 1

router-id 1.1.1.1

network 1.1.1.0 0.0.0.255 area 0

network 192.168.12.0 0.0.0.255 area 0

end

R1:

enable

conf t

no ip domain-lookup

hostname R1

int loop 0

ip add 2.2.2.2 255.255.255.0

no shu

int f0/0

ip add 192.168.12.2 255.255.255.0

no shu

int f0/1

ip add 192.168.23.1 255.255.255.0

no shu

exit

router ospf 1

router-id 2.2.2.2

network 2.2.2.0 0.0.0.255 area 0

network 192.168.12.0 0.0.0.255 area 0

network 192.168.23.0 0.0.0.255 area 0

end

R2:

enable

conf t

no ip domain-lookup

hostname R2

int loop 0

ip add 3.3.3.3 255.255.255.0

no shu

int f0/0

ip add 192.168.23.2 255.255.255.0

no shu

int f0/1

ip add 192.168.34.1 255.255.255.0

no shu

exit

router ospf 1

router-id 3.3.3.3

network 3.3.3.0 0.0.0.255 area 0

network 192.168.23.0 0.0.0.255 area 0

network 192.168.34.0 0.0.0.255 area 0

end

R3:

enable

conf t

no ip domain-lookup

hostname R3

int loop 0

ip add 4.4.4.4 255.255.255.0

no shu

int f0/0

ip add 192.168.34.2 255.255.255.0

no shu

exit

router ospf 1

router-id 4.4.4.4

network 192.168.34.0 0.0.0.255 area 0

network 4.4.4.0 0.0.0.255 area 0

end