OSPF基础介绍

   

 

 

 

一.RIP的缺陷

1.以跳数评估的路由并非最优路径

OSPF基础介绍

 

2.最大跳数16导致网络尺度小

OSPF基础介绍

3.收敛速度慢

OSPF基础介绍

4.更新发送全部路由表浪费网络资源

OSPF基础介绍

二.OSPF基本原理

1.什么是OSPF

  a>.OSPF(Open Shortest Path First,开放最短路径有限)是IETF开发的基于链路状态的自治系统内部路由协议;

  b>.OSPF仅传播对端设备不具备的路由信息,网络收敛迅速,并有效避免了网络资源浪费;

  c>.OSPF直接工作于IP层之上,IP协议号为89;

  d>.OSPF以组播地址发送协议包;

2. OSPF协议工作过程概述

OSPF基础介绍

 

  a>.寻找邻居;

OSPF基础介绍

 

  b>.建立邻接关系;

OSPF基础介绍 

  注意:上图中的DR和BDR是用来管理一个单区域的,上图中邻接关系数是10,如果都让OSPF来管理是会有很大的负载的,这个时候选举出DR和BDR(DR是管理者,当DR坏掉是有BDR路由器来取得所有权进行管理)来管理这些单区域,多条链路是的话需要选举出来DR和BDR,单挑链路是没有必要选举的,因为没有那么大的负载。  

  DR和BDR选举

OSPF基础介绍

 

DR,BDR选举规则总结:
  1>.选举接口优先级,优先级越大越优先,被选DR,优先级第二,被选BDR.
  2>.如果优先级一样,选route-id,越大优先.
  3>.如果路由器没有设置route-id,那么选接口的ip地址,越大越优先。

注意:一个单区域中可以没有BDR,但是必须有DR!

 

 c>.链路状态信息传递;

OSPF基础介绍

OSPF基础介绍

  d.路由计算

OSPF基础介绍

3.OSPF协议分区域管理

OSPF基础介绍

4.OSPF协议区域LSA发布

OSPF基础介绍

三.配置OSPF

 配置下图实验,让公司总部这太电脑能够访问各个机房的主机!

OSPF基础介绍

配置过程如下:

"兆维机房"配置如下:

 1 "兆维机房"配置如下:
 2 [Huawei]sysname zhaowei
 3 [zhaowei]interface LoopBack 1
 4 [zhaowei-LoopBack1]ip address 172.16.1.1 24
 5 [zhaowei-LoopBack1]quit 
 6 [zhaowei]interface Ethernet 0/0/0
 7 [zhaowei-Ethernet0/0/0]ip address 192.168.1.1 24
 8 [zhaowei-Ethernet0/0/0]undo shutdown 
 9 [zhaowei-Ethernet0/0/0]quit
10 [zhaowei]interface  Ethernet 0/0/0
11 [zhaowei-Ethernet0/0/0]ospf dr-priority 100  #设置优先级为100,这样使得其优先级最高,成为DR路由器
12 [zhaowei-Ethernet0/0/0]quit 
13 [zhaowei]router id 1.1.1.1
14 [zhaowei]ospf 100  #配置进程号,这个可以自定义
15 [zhaowei-ospf-100]area 0 #定义区域
16 [zhaowei-ospf-100-area-0.0.0.0]network 192.168.1.0 0.0.0.255  #这个掩码(0.0.0.255)=广播地址(255.255.255.0)-这个
17 
18 网段的子网掩码(255.255.255.019 [zhaowei-ospf-100-area-0.0.0.0]network 172.16.1.1 0.0.0.0  #向外面宣告这个地址


"鲁谷机房"配置如下:

 1 [Huawei]sysname lugu
 2 [lugu]interface LoopBack 1
 3 [lugu-LoopBack1]ip address 172.16.1.2 24
 4 [lugu-LoopBack1]quit 
 5 [lugu]interface Ethernet 0/0/0
 6 [lugu-Ethernet0/0/0]ip address 192.168.1.2 24
 7 [lugu-Ethernet0/0/0]undo shutdown 
 8 [lugu-Ethernet0/0/0]quit 
 9 [lugu]router id 2.2.2.2 #配置路由的ID
10 [lugu]ospf 100
11 [lugu-ospf-100]area 0
12 [lugu-ospf-100-area-0.0.0.0]network 192.168.1.0 0.0.0.255
13 [lugu-ospf-100-area-0.0.0.0]network 172.16.1.2 0.0.0.0


"清华园机房"配置如下:

 1 [Huawei]sysname qinghuayuan
 2 [qinghuayuan]interface Ethernet 0/0/1
 3 [qinghuayuan-Ethernet0/0/1]ip address 172.30.1.254 24
 4 [qinghuayuan-Ethernet0/0/1]undo shutdown 
 5 [qinghuayuan-Ethernet0/0/1]quit 
 6 [qinghuayuan]interface Ethernet 0/0/0
 7 [qinghuayuan-Ethernet0/0/0]ip address 192.168.1.3 24
 8 [qinghuayuan-Ethernet0/0/0]undo shutdown 
 9 [qinghuayuan-Ethernet0/0/0]quit 
10 [qinghuayuan]router id 3.3.3.3
11 [qinghuayuan]ospf 100
12 [qinghuayuan-ospf-100]area 0
13 [qinghuayuan-ospf-100-area-0.0.0.0]network 192.168.1.0 0.0.0.255
14 [qinghuayuan-ospf-100-area-0.0.0.0]network 172.30.1.0 0.0.0.255


"廊坊机房"配置如下:

 1 [Huawei]sysname langfang
 2 [langfang]interface LoopBack 1
 3 [langfang-LoopBack1]ip address 172.16.1.4 24
 4 [langfang-LoopBack1]quit 
 5 [langfang]interface Ethernet 0/0/0
 6 [langfang-Ethernet0/0/0]ip address 192.168.1.4 24
 7 [langfang-Ethernet0/0/0]undo shutdown 
 8 [langfang-Ethernet0/0/0]quit 
 9 [langfang]router id 4.4.4.4
10 [langfang]ospf 100
11 [langfang-ospf-100]area 0
12 [langfang-ospf-100-area-0.0.0.0]network 192.168.1.0 0.0.0.255
13 [langfang-ospf-100-area-0.0.0.0]network 172.16.1.4 0.0.0.0


"高碑店机房"配置如下:

 1 [Huawei]sysname gaobeidian
 2 [gaobeidian]interface LoopBack 1
 3 [gaobeidian-LoopBack1]ip address 172.16.1.5 24
 4 [gaobeidian-LoopBack1]quit 
 5 [gaobeidian]interface Ethernet 0/0/0
 6 [gaobeidian-Ethernet0/0/0]ip address 192.168.1.5 24
 7 [gaobeidian-Ethernet0/0/0]undo shutdown 
 8 [gaobeidian-Ethernet0/0/0]quit 
 9 [gaobeidian]router id 5.5.5.5
10 [gaobeidian]ospf 100
11 [gaobeidian-ospf-100]area 0
12 [gaobeidian-ospf-100-area-0.0.0.0]network 192.168.1.0 0.0.0.255
13 [gaobeidian-ospf-100-area-0.0.0.0]network 172.16.1.5 0.0.0.0


"双桥机房"配置如下:

 1 [Huawei]sysname shuangqiao
 2 [shuangqiao]interface LoopBack 1
 3 [shuangqiao-LoopBack1]ip address 172.16.1.6 24
 4 [shuangqiao-LoopBack1]quit 
 5 [shuangqiao]interface Ethernet 0/0/0
 6 [shuangqiao-Ethernet0/0/0]ip address 192.168.1.6 24
 7 [shuangqiao-Ethernet0/0/0]undo shutdown 
 8 [shuangqiao-Ethernet0/0/0]quit 
 9 [shuangqiao]interface Ethernet 0/0/0
10 [shuangqiao-Ethernet0/0/0]ospf dr-priority 50
11 [shuangqiao-Ethernet0/0/0]quit 
12 [shuangqiao]router id 6.6.6.6
13 [shuangqiao]ospf 100
14 [shuangqiao-ospf-100]area 0
15 [shuangqiao-ospf-100-area-0.0.0.0]network 192.168.1.0 0.0.0.255
16 [shuangqiao-ospf-100-area-0.0.0.0]network 172.16.1.6 0.0.0.0

 

公司总部电脑测试结果如下:

 1 PC>ipconfig
 2 
 3 Link local IPv6 address...........: fe80::5689:98ff:fe86:12b
 4 IPv6 address......................: :: / 128
 5 IPv6 gateway......................: ::
 6 IPv4 address......................: 172.30.1.3
 7 Subnet mask.......................: 255.255.255.0
 8 Gateway...........................: 172.30.1.254
 9 Physical address..................: 54-89-98-86-01-2B
10 DNS server........................:
11 
12 PC>ping 192.168.1.1
13 
14 Ping 192.168.1.1: 32 data bytes, Press Ctrl_C to break
15 From 192.168.1.1: bytes=32 seq=1 ttl=254 time=32 ms
16 From 192.168.1.1: bytes=32 seq=2 ttl=254 time=46 ms
17 From 192.168.1.1: bytes=32 seq=3 ttl=254 time=47 ms
18 From 192.168.1.1: bytes=32 seq=4 ttl=254 time=31 ms
19 From 192.168.1.1: bytes=32 seq=5 ttl=254 time=47 ms
20 
21 --- 192.168.1.1 ping statistics ---
22   5 packet(s) transmitted
23   5 packet(s) received
24   0.00% packet loss
25   round-trip min/avg/max = 31/40/47 ms
26 
27 PC>ping 172.16.1.1
28 
29 Ping 172.16.1.1: 32 data bytes, Press Ctrl_C to break
30 From 172.16.1.1: bytes=32 seq=1 ttl=254 time=47 ms
31 From 172.16.1.1: bytes=32 seq=2 ttl=254 time=63 ms
32 From 172.16.1.1: bytes=32 seq=3 ttl=254 time=78 ms
33 From 172.16.1.1: bytes=32 seq=4 ttl=254 time=47 ms
34 From 172.16.1.1: bytes=32 seq=5 ttl=254 time=47 ms
35 
36 --- 172.16.1.1 ping statistics ---
37   5 packet(s) transmitted
38   5 packet(s) received
39   0.00% packet loss
40   round-trip min/avg/max = 47/56/78 ms
41 
42 PC>ping 172.16.1.2
43 
44 Ping 172.16.1.2: 32 data bytes, Press Ctrl_C to break
45 From 172.16.1.2: bytes=32 seq=1 ttl=254 time=63 ms
46 From 172.16.1.2: bytes=32 seq=2 ttl=254 time=62 ms
47 From 172.16.1.2: bytes=32 seq=3 ttl=254 time=47 ms
48 From 172.16.1.2: bytes=32 seq=4 ttl=254 time=47 ms
49 From 172.16.1.2: bytes=32 seq=5 ttl=254 time=63 ms
50 
51 --- 172.16.1.2 ping statistics ---
52   5 packet(s) transmitted
53   5 packet(s) received
54   0.00% packet loss
55   round-trip min/avg/max = 47/56/63 ms
56 
57 PC>ping 172.16.1.4
58 
59 Ping 172.16.1.4: 32 data bytes, Press Ctrl_C to break
60 From 172.16.1.4: bytes=32 seq=1 ttl=254 time=93 ms
61 From 172.16.1.4: bytes=32 seq=2 ttl=254 time=46 ms
62 From 172.16.1.4: bytes=32 seq=3 ttl=254 time=62 ms
63 From 172.16.1.4: bytes=32 seq=4 ttl=254 time=46 ms
64 From 172.16.1.4: bytes=32 seq=5 ttl=254 time=47 ms
65 
66 --- 172.16.1.4 ping statistics ---
67   5 packet(s) transmitted
68   5 packet(s) received
69   0.00% packet loss
70   round-trip min/avg/max = 46/58/93 ms
71 
72 PC>ping 172.16.1.5
73 
74 Ping 172.16.1.5: 32 data bytes, Press Ctrl_C to break
75 From 172.16.1.5: bytes=32 seq=1 ttl=254 time=94 ms
76 From 172.16.1.5: bytes=32 seq=2 ttl=254 time=47 ms
77 From 172.16.1.5: bytes=32 seq=3 ttl=254 time=47 ms
78 From 172.16.1.5: bytes=32 seq=4 ttl=254 time=47 ms
79 From 172.16.1.5: bytes=32 seq=5 ttl=254 time=47 ms
80 
81 --- 172.16.1.5 ping statistics ---
82   5 packet(s) transmitted
83   5 packet(s) received
84   0.00% packet loss
85   round-trip min/avg/max = 47/56/94 ms
86 
87 PC>

 

四.OSPF常用的调试命令

1.查看OSPF摘要信息

 1 <qinghuayuan>display ospf brief 
 2 
 3      OSPF Process 100 with Router ID 3.3.3.3
 4          OSPF Protocol Information
 5 
 6  RouterID: 3.3.3.3          Border Router: 
 7  Multi-VPN-Instance is not enabled
 8  Global DS-TE Mode: Non-Standard IETF Mode
 9  Spf-schedule-interval: max 10000ms, start 500ms, hold 1000ms
10  Default ASE parameters: Metric: 1 Tag: 1 Type: 2
11  Route Preference: 10 
12  ASE Route Preference: 150 
13  SPF Computation Count: 7     
14  RFC 1583 Compatible
15  Retransmission limitation is disabled
16  Area Count: 1   Nssa Area Count: 0 
17  ExChange/Loading Neighbors: 0
18  
19  Area: 0.0.0.0          (MPLS TE not enabled)
20  Authtype: None   Area flag: Normal
21  SPF scheduled Count: 7     
22  ExChange/Loading Neighbors: 0
23  Router ID conflict state: Normal
24 
25  Interface: 172.30.1.254 (Ethernet0/0/1)
26  Cost: 1       State: DR        Type: Broadcast    MTU: 1500  
27  Priority: 1
28  Designated Router: 172.30.1.254
29  Backup Designated Router: 0.0.0.0
30  Timers: Hello 10 , Dead 40 , Poll  120 , Retransmit 5 , Transmit Delay 1 
31 
32  Interface: 192.168.1.3 (Ethernet0/0/0)
33  Cost: 1       State: DROther    Type: Broadcast    MTU: 1500  
34  Priority: 1
35  Designated Router: 192.168.1.1
36  Backup Designated Router: 192.168.1.2
37  Timers: Hello 10 , Dead 40 , Poll  120 , Retransmit 5 , Transmit Delay 1 
38 <qinghuayuan> 
display ospf brief

相关文章: