乾颐堂 发表于 2023-9-12 14:42:05

RIP OSPF动态路由协议实验文档

https://editor-material.365editor.com/style/20230220167686474063f2ece47a929material.gif
RIP动态路由协议
1 拓扑

https://editor-user.365editor.com/98/85/4933185/1694487736781242.png
2 PC1 PC2配置

https://editor-user.365editor.com/98/85/4933185/1694487767991219.png

3 AR1 AR2 AR3配置IP地址

AR1配置
int g0/0/0
ip address 10.10.10.2 24
int g0/0/1
ip address 20.20.20.2 24

AR2配置
int g0/0/0
ip address 10.10.10.1 24
int g0/0/2
ip address 192.168.1.1 24
int g0/0/1
ip address 30.30.30.1 24

AR3配置
int g0/0/0
ip address 20.20.20.1 24
int g0/0/1
ip address 30.30.30.2 24
int g0/0/2
ip address 192.168.3.1 24

4 AR1 AR2 AR3开启RIP动态路由协议,并且宣告各自相连的网段

AR1配置
rip//进入RIP
version 2//RIP版本为2
network 10.0.0.0//宣告路由器上所有的网段,宣告一整个大网段,RIP不支持掩码,掩码会自动识别
network 20.0.0.0   //宣告路由器上所有的网段,宣告一整个大网段,RIP不支持掩码,掩码会自动识别

AR2配置
rip
version 2
network 192.168.1.0
network 10.0.0.0
network 30.0.0.0

AR3配置
rip
version 2
network 192.168.3.0
network 20.0.0.0
network 30.0.0.0

5 AR2上查看路由表,有一条路由去往192.168.3.0/24网段,下一跳是30.30.30.2,华为模拟器中RIP协议优先级为100,cost开销是根据跳数计算的

dis ip routing-table Route Flags: R - relay, D - download to fib
Routing Tables: Public
Destinations : 15       Routes : 16
Destination/Mask    Proto   PreCost      Flags NextHop         Interface
10.10.10.0/24Direct0    0         D   10.10.10.1      GigabitEthernet
0/0/0
10.10.10.1/32Direct0    0         D   127.0.0.1       GigabitEthernet
0/0/0
10.10.10.255/32Direct0    0         D   127.0.0.1       GigabitEthernet
0/0/0
20.20.20.0/24RIP   1001         D   10.10.10.2      GigabitEthernet
0/0/0
RIP   1001         D   30.30.30.2      GigabitEthernet
0/0/1
30.30.30.0/24Direct0    0         D   30.30.30.1      GigabitEthernet
0/0/1
30.30.30.1/32Direct0    0         D   127.0.0.1       GigabitEthernet
0/0/1
30.30.30.255/32Direct0    0         D   127.0.0.1       GigabitEthernet
0/0/1
127.0.0.0/8   Direct0    0         D   127.0.0.1       InLoopBack0
127.0.0.1/32Direct0    0         D   127.0.0.1       InLoopBack0
127.255.255.255/32Direct0    0         D   127.0.0.1       InLoopBack0
192.168.1.0/24Direct0    0         D   192.168.1.1   GigabitEthernet
0/0/2
192.168.1.1/32Direct0    0         D   127.0.0.1       GigabitEthernet
0/0/2
192.168.1.255/32Direct0    0         D   127.0.0.1       GigabitEthernet
0/0/2
192.168.3.0/24RIP   1001         D   30.30.30.2      GigabitEthernet
0/0/1

6 PC1上使用tracert目标地址命令查看,PC1访问PC2经过的下一跳

https://editor-user.365editor.com/98/85/4933185/1694487830749677.png

PC1 ping PC2是可以ping通的

PC>ping 192.168.3.2
Ping 192.168.3.2: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.3.2: bytes=32 seq=2 ttl=126 time=31 ms
From 192.168.3.2: bytes=32 seq=3 ttl=126 time=16 ms
From 192.168.3.2: bytes=32 seq=4 ttl=126 time=15 ms
From 192.168.3.2: bytes=32 seq=5 ttl=126 time=16 ms
--- 192.168.3.2 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 0/19/31 ms
PC>

7 此时若最短的RIP路由断链,此时AR2路由表的下一跳信息发生了变化,cost2为源到目的经过两跳才到达

int g0/0/1
sh
shutdown

dis ip routing-table Route Flags: R - relay, D - download to fib
Routing Tables: Public
Destinations : 12       Routes : 12
Destination/Mask    Proto   PreCost      Flags NextHop         Interface
10.10.10.0/24Direct0    0         D   10.10.10.1      GigabitEthernet
0/0/0
10.10.10.1/32Direct0    0         D   127.0.0.1       GigabitEthernet
0/0/0
10.10.10.255/32Direct0    0         D   127.0.0.1       GigabitEthernet
0/0/0
20.20.20.0/24RIP   1001         D   10.10.10.2      GigabitEthernet
0/0/0
127.0.0.0/8   Direct0    0         D   127.0.0.1       InLoopBack0
127.0.0.1/32Direct0    0         D   127.0.0.1       InLoopBack0
127.255.255.255/32Direct0    0         D   127.0.0.1       InLoopBack0
192.168.1.0/24Direct0    0         D   192.168.1.1   GigabitEthernet
0/0/2
192.168.1.1/32Direct0    0         D   127.0.0.1       GigabitEthernet
0/0/2
192.168.1.255/32Direct0    0         D   127.0.0.1       GigabitEthernet
0/0/2
192.168.3.0/24RIP   1002         D   10.10.10.2      GigabitEthernet
0/0/0

8 PC1上使用tracert目标地址命令查看,下一跳变多了,RIP改变了数据包的转发路径

PC>tracert 192.168.3.2
traceroute to 192.168.3.2, 8 hops max
(ICMP), press Ctrl+C to stop
1192.168.1.1   15 ms16 ms16 ms
2    *10.10.10.2   15 ms16 ms
3    *20.20.20.1   31 ms16 ms
4    *192.168.3.2   16 ms31 ms
PC>

PC1 PC2 可以ping通
PC>ping 192.168.3.2
Ping 192.168.3.2: 32 data bytes, Press Ctrl_C to break
From 192.168.3.2: bytes=32 seq=1 ttl=125 time=31 ms
From 192.168.3.2: bytes=32 seq=2 ttl=125 time=16 ms
From 192.168.3.2: bytes=32 seq=3 ttl=125 time=31 ms
From 192.168.3.2: bytes=32 seq=4 ttl=125 time=16 ms
From 192.168.3.2: bytes=32 seq=5 ttl=125 time=31 ms
--- 192.168.3.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 16/25/31 ms
PC>

9 AR2上抓包,有RIP报文

https://editor-user.365editor.com/98/85/4933185/1694487872564838.png

RIP在华为模拟器中优先级为100,RIP的cost是根据跳数记录的,RIP会选择跳数少的一条路由使用并将选中的这条路由记录到路由表中,未选中的则不进行记录。

OSPF动态路由协议

1 拓扑

https://editor-user.365editor.com/98/85/4933185/1694487902996783.png

2 PC1 PC2配置

https://editor-user.365editor.com/98/85/4933185/1694487919320908.png
https://editor-user.365editor.com/98/85/4933185/169448792595728.png

3 AR1 AR2 AR3配置IP地址

AR1配置
int g0/0/0
ip address 12.1.1.1 24
int g0/0/1
ip address 23.1.1.1 24

AR2配置
int g0/0/0
ip address 12.1.1.2 24
int g0/0/1
ip address 13.1.1.2 24

AR3配置
int g0/0/0
ip address 13.1.1.3 24
int g0/0/1
ip address 23.1.1.3 24
int g0/0/2
ip address 192.168.1.1 24

4 AR1 AR2 AR3配置OSPF

AR1配置
ospf 10 router-id 1.1.1.1
area 0.0.0.0//配置区域为0
network 12.1.1.1 0.0.0.0
network 23.1.1.1 0.0.0.0

AR2配置
ospf 10 router-id 2.2.2.2
area 0.0.0.0
network 12.1.1.2 0.0.0.0
network 13.1.1.2 0.0.0.0
network 192.168.2.1 0.0.0.0

AR3配置
ospf 10 router-id 3.3.3.3
area 0.0.0.0
network 13.1.1.3 0.0.0.0
network 23.1.1.3 0.0.0.0
network 192.168.1.1 0.0.0.0

5 查看路由表,OSPF已经自动学习了全网路由

dis ip routing-table Route Flags: R - relay, D - download to fib
Routing Tables: Public
Destinations : 12       Routes : 13
Destination/Mask    Proto   PreCost      Flags NextHop         Interface
12.1.1.0/24Direct0    0         D   12.1.1.2      GigabitEthernet
0/0/0
12.1.1.2/32Direct0    0         D   127.0.0.1       GigabitEthernet
0/0/0
12.1.1.255/32Direct0    0         D   127.0.0.1       GigabitEthernet
0/0/0
13.1.1.0/24Direct0    0         D   13.1.1.2      GigabitEthernet
0/0/1
13.1.1.2/32Direct0    0         D   127.0.0.1       GigabitEthernet
0/0/1
13.1.1.255/32Direct0    0         D   127.0.0.1       GigabitEthernet
0/0/1
23.1.1.0/24OSPF    10   2         D   12.1.1.1      GigabitEthernet
0/0/0
OSPF    10   2         D   13.1.1.3      GigabitEthernet
0/0/1
127.0.0.0/8   Direct0    0         D   127.0.0.1       InLoopBack0
127.0.0.1/32Direct0    0         D   127.0.0.1       InLoopBack0
127.255.255.255/32Direct0    0         D   127.0.0.1       InLoopBack0
192.168.1.0/24OSPF    10   2         D   13.1.1.3      GigabitEthernet
0/0/1
255.255.255.255/32Direct0    0         D   127.0.0.1       InLoopBack0

6 查看AR1 AR2 AR3 邻接关系

dis ospf peer brief
OSPF Process 10 with Router ID 2.2.2.2
Peer Statistic Information

https://editor-user.365editor.com/98/85/4933185/1694487983399977.pnghttps://editor-user.365editor.com/98/85/4933185/1694487995636100.pnghttps://editor-user.365editor.com/98/85/4933185/1694488004274688.png

7 PC2可以ping通PC1

https://editor-user.365editor.com/98/85/4933185/1694488037153079.png

8 PC2上tracert 192.168.1.100查看数据包传输路路径

PC>tracert 192.168.1.100
traceroute to 192.168.1.100, 8 hops max
(ICMP), press Ctrl+C to stop
1192.168.2.1   16 ms<1 ms15 ms
213.1.1.3   16 ms16 ms31 ms
3192.168.1.100   16 ms15 ms16 ms
PC>

9 断开AR2的1口,OSPF自动调整了转发路径

int g0/0/1
shutdown

PC>tracert 192.168.1.100
traceroute to 192.168.1.100, 8 hops max
(ICMP), press Ctrl+C to stop
1192.168.2.1   16 ms16 ms<1 ms
212.1.1.1   31 ms<1 ms15 ms
323.1.1.3   16 ms31 ms16 ms
4    *192.168.1.100   31 ms16 ms

10 PC1 PC2 可以ping通

PC>ping 192.168.1.100
Ping 192.168.1.100: 32 data bytes, Press Ctrl_C to break
From 192.168.1.100: bytes=32 seq=1 ttl=128 time<1 ms
From 192.168.1.100: bytes=32 seq=2 ttl=128 time<1 ms
From 192.168.1.100: bytes=32 seq=3 ttl=128 time<1 ms
From 192.168.1.100: bytes=32 seq=4 ttl=128 time<1 ms
From 192.168.1.100: bytes=32 seq=5 ttl=128 time<1 ms
--- 192.168.1.100 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 0/0/0 ms

抓包

https://editor-user.365editor.com/98/85/4933185/1694488210601142.png

总结

运行OSPF协议的路由器中,所有接口都处于同一个area区域中才能建立邻居/邻接关系

从邻居到邻接关系,需要40秒

一个邻居若超过40秒没有回应关系确认报文HELLO,此时OSOF会认为该关系建立失败

2WAY 邻居阶段

FULL 邻接阶段

https://editor-material.365editor.com/style/20230220167686474063f2ece49a3d3material.gif

https://editor-material.365editor.com/style/20230220167686474063f2ece4b7c43material.gif
页: [1]
查看完整版本: RIP OSPF动态路由协议实验文档