OSPF接口网络类型实验
一,实验拓扑
初始拓扑:
最终拓扑:
二,实验要求及分析
要求:
1,R6为ISP只能配置IP地址,R1-R5的环回为私有网段
2,R1/R4/R5为全连的MGRE结构,R1/R2/R3为星型的拓扑结构,R1为中心站点
3,所有私有网段可以相互通讯,私有网段使用OSPF完成。
分析:
IP设置
环回接口网段:
192.168.1.0/24 -----> r1的环回192.168.1.1/24 ----> r1的环回接口地址
192.168.2.0/24 -----> r2的环回192.168.2.1/24 ----> r2的环回接口地址
192.168.3.0/24 -----> r3的环回192.168.3.1/24 ----> r3的环回接口地址
192.168.4.0/24 -----> r4的环回192.168.4.1/24 ----> r4的环回接口地址
192.168.5.0/24 -----> r5的环回192.168.5.1/24 ----> r5的环回接口地址
设备直连网段:
16.0.0.0/24 -----> r1到r6(上)
61.0.0.0/24 -----> r1到r6(下)
26.0.0.0/24 -----> r2到r6
36.0.0.0/24 -----> r3到r6
46.0.0.0/24 -----> r4到r6
56.0.0.0/24 -----> r5到r6
虚拟隧道网段:
1,R1/R4/R5为全连的MGRE结构网段:t0/0/0192.168.6.0/24192.168.6.1/24 ---> r1隧道0口地址192.168.6.2/24 ---> r4隧道0口地址192.168.6.3/24 ---> r5隧道0口地址
2,R1/R2/R3为星型的拓扑结构网段:t0/0/1192.168.7.0/24192.168.7.1/24 ---> r1隧道1口地址192.168.7.2/24 ---> r2隧道1口地址192.168.7.3/24 ---> r3隧道1口地址
三,实验配置
1,基础IP配置
R1
[r1]int g 0/0/0
[r1-GigabitEthernet0/0/0]ip add 16.0.0.1 24
[r1-GigabitEthernet0/0/0]int g 0/0/1
[r1-GigabitEthernet0/0/1]ip add 61.0.0.1 24
[r1-GigabitEthernet0/0/1]int l 0
[r1-LoopBack0]ip add 192.168.1.1 24
R2
[r2]int g 0/0/0
[r2-GigabitEthernet0/0/0]ip add 26.0.0.1 24
[r2-GigabitEthernet0/0/0]int l 0
[r2-LoopBack0]ip add 192.168.2.1 24
R3
[r3]int g 0/0/0
[r3-GigabitEthernet0/0/0]ip add 36.0.0.1 24
[r3-GigabitEthernet0/0/0]
[r3-GigabitEthernet0/0/0]int l 0
[r3-LoopBack0]ip add 192.168.3.1 24
R4
[r4]int g 0/0/0
[r4-GigabitEthernet0/0/0]ip add 46.0.0.1 24
[r4-GigabitEthernet0/0/0]int l 0
[r4-LoopBack0]ip add 192.168.4.1 24
R5
[r5]int g 0/0/0
[r5-GigabitEthernet0/0/0]ip add 56.0.0.1 24
[r5-GigabitEthernet0/0/0]int l 0
[r5-LoopBack0]ip add 192.168.5.1 24
R6:因为R6是ISP设备,所以只需用配置各个接口的IP地址即可。
[isp]int g 0/0/0
[isp-GigabitEthernet0/0/0]ip add 16.0.0.2 24
[isp-GigabitEthernet0/0/0]int g 0/0/1
[isp-GigabitEthernet0/0/1]ip add 61.0.0.2 24
[isp-GigabitEthernet0/0/1]int g 0/0/2
[isp-GigabitEthernet0/0/2]ip add 56.0.0.2 24
[isp-GigabitEthernet0/0/2]int g 1/0/0
[isp-GigabitEthernet1/0/0]ip add 26.0.0.2 24
[isp-GigabitEthernet1/0/0]int g 2/0/0
[isp-GigabitEthernet2/0/0]ip add 36.0.0.2 24
[isp-GigabitEthernet2/0/0]int g 3/0/0
[isp-GigabitEthernet3/0/0]ip add 46.0.0.2 24
2,路由配置
保证公网互通。
[r1]ip route-static 0.0.0.0 0 16.0.0.2
[r1]ip route-static 0.0.0.0 0 61.0.0.2
[r2]ip route-static 0.0.0.0 0 26.0.0.2
[r3]ip route-static 0.0.0.0 0 36.0.0.2
[r4]ip route-static 0.0.0.0 0 46.0.0.2
[r5]ip route-static 0.0.0.0 0 56.0.0.2
3,MGRE结构配置
R1
[r1]interface Tunnel 0/0/0
[r1-Tunnel0/0/0]ip add 192.168.6.1 24
[r1-Tunnel0/0/0]tunnel-protocol gre p2mp
[r1-Tunnel0/0/0]source 16.0.0.1
[r1-Tunnel0/0/0]nhrp entry 192.168.6.2 46.0.0.1 register
[r1-Tunnel0/0/0]nhrp entry 192.168.6.3 56.0.0.1 register
[r1-Tunnel0/0/0]nhrp network-id 101 ---创建nhrp域
R4
[r4]int t 0/0/0
[r4-Tunnel0/0/0]ip add 192.168.6.2 24
[r4-Tunnel0/0/0]tunnel-protocol gre p2mp
[r4-Tunnel0/0/0]source 46.0.0.1
[r4-Tunnel0/0/0]nhrp entry 192.168.6.3 56.0.0.1 register
[r4-Tunnel0/0/0]nhrp entry multicast dynamic
[r4-Tunnel0/0/0]nhrp network-id 101
R5
[r5]int t 0/0/0
[r5-Tunnel0/0/0]ip add 192.168.6.3 24
[r5-Tunnel0/0/0]tunnel-protocol gre p2mp
[r5-Tunnel0/0/0]source 56.0.0.1
[r5-Tunnel0/0/0]nhrp entry multicast dynamic
[r5-Tunnel0/0/0]nhrp network-id 101
4,星型拓扑配置
R1–中心
[r1]int t 0/0/1
[r1-Tunnel0/0/1]ip add 192.168.7.1 24
[r1-Tunnel0/0/1]tunnel-protocol gre p2mp
[r1-Tunnel0/0/1]source 61.0.0.1
[r1-Tunnel0/0/1]nhrp entry multicast dynamic
[r1-Tunnel0/0/1]nhrp network-id 100
R2–分支节点1
[r2]int t 0/0/1
[r2-Tunnel0/0/1]ip add 192.168.7.2 24
[r2-Tunnel0/0/1]tunnel-protocol gre p2mp
[r2-Tunnel0/0/1]source GigabitEthernet 0/0/0
[r2-Tunnel0/0/1]nhrp entry 192.168.7.1 61.0.0.1 register
[r2-Tunnel0/0/1]nhrp network-id 100
R3–分直节点2
[r3]int t 0/0/1
[r3-Tunnel0/0/1]ip add 192.168.7.3 24
[r3-Tunnel0/0/1]tunnel-protocol gre p2mp
[r3-Tunnel0/0/1]source GigabitEthernet 0/0/0
[r3-Tunnel0/0/1]nhrp entry 192.168.7.1 61.0.0.1 register
[r3-Tunnel0/0/1]nhrp network-id 100
补充路由配置
[r1]ip route-static 192.168.2.0 24 192.168.7.2
[r1]ip route-static 192.168.3.0 24 192.168.7.3[r2]ip route-static 192.168.1.0 24 192.168.7.1
[r2]ip route-static 192.168.3.0 24 192.168.7.1[r3]ip route-static 192.168.1.0 24 192.168.7.1
[r3]ip route-static 192.168.2.0 24 192.168.7.1
5,OSPF配置
开启OSPF路由,R1为DR,R2、R3放弃选举,修改ospf接口类型为broadcast。
[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1]area 0
[r1-ospf-1-area-0.0.0.0]network 192.168.1.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]network 192.168.6.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]network 192.168.7.1 0.0.0.0[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 192.168.2.1 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 192.168.7.2 0.0.0.0[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]network 192.168.3.1 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 192.168.7.3 0.0.0.0[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 192.168.4.1 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 192.168.6.2 0.0.0.0[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]area 0
[r5-ospf-1-area-0.0.0.0]network 192.168.5.1 0.0.0.0
[r5-ospf-1-area-0.0.0.0]network 192.168.6.3 0.0.0.0
修改ospf接口类型为broadcast:
[r1-Tunnel0/0/1]ospf network-type broadcast
[r2-Tunnel0/0/1]ospf network-type broadcast
[r3-Tunnel0/0/1]ospf network-type broadcast
[r4-Tunnel0/0/0]ospf network-type broadcast
[r5-Tunnel0/0/0]ospf network-type broadcast
R2,R3放弃选举:
[r2-Tunnel0/0/1]ospf dr-priority 0
[r3-Tunnel0/0/1]ospf dr-priority 0
查看邻居表:(命令:display ospf peer brief )
r1:OSPF Process 1 with Router ID 1.1.1.1Peer Statistic Information----------------------------------------------------------------------------Area Id Interface Neighbor id State 0.0.0.0 Tunnel0/0/0 4.4.4.4 Full 0.0.0.0 Tunnel0/0/1 2.2.2.2 Full 0.0.0.0 Tunnel0/0/1 3.3.3.3 Full ----------------------------------------------------------------------------
r2:OSPF Process 1 with Router ID 2.2.2.2Peer Statistic Information----------------------------------------------------------------------------Area Id Interface Neighbor id State 0.0.0.0 Tunnel0/0/1 1.1.1.1 Full ----------------------------------------------------------------------------
r3:OSPF Process 1 with Router ID 3.3.3.3Peer Statistic Information----------------------------------------------------------------------------Area Id Interface Neighbor id State 0.0.0.0 Tunnel0/0/1 1.1.1.1 Full ----------------------------------------------------------------------------
r4:OSPF Process 1 with Router ID 4.4.4.4Peer Statistic Information----------------------------------------------------------------------------Area Id Interface Neighbor id State 0.0.0.0 Tunnel0/0/0 1.1.1.1 Full 0.0.0.0 Tunnel0/0/0 5.5.5.5 Full ----------------------------------------------------------------------------
r5:OSPF Process 1 with Router ID 5.5.5.5Peer Statistic Information----------------------------------------------------------------------------Area Id Interface Neighbor id State 0.0.0.0 Tunnel0/0/0 1.1.1.1 Init 0.0.0.0 Tunnel0/0/0 4.4.4.4 Full ----------------------------------------------------------------------------
查看静态路由协议的路由表条目:(命令:display ip routing-table protocol static )
R1
R2
R3
R4
R5
四,测试