OSPF综合实验(gns模拟器)
注意点:
Ospf实验推荐用gns制作
//图中的交换机可以视觉忽略或缩小成一个点。(^ v^)
Ospf
实验拓扑图
目录
OSPF综合实验...
Ospf实验拓扑图...
1.Ospf
2.环回口改成点到点网络...
3.改优先级...
4.ospf的手动汇总...
5.ospf认证...
6.ospf发布缺省路由更新...
7.孤岛区域和区域分割...
8.STUB
1.Ospf
基础配置
R1:
R1#conf t
R1(config)#inte0/0
R1(config-if)#ipadd 14.14.14.1 255.255.255.0
R1(config-if)#noshut
R1(config-if)#intlo0
R1(config-if)#ipadd 10.1.1.1 255.255.255.0
R1(config-if)#end
R1#conf t
R1(config)#routerospf 1
R1(config-router)#router-id1.1.1.1
R1(config-router)#net10.1.1.0 0.0.0.255 a 1
R1(config-router)#net14.14.14.0 0.0.0.255 a 1
R2:
R2#conf t
R2(config)#inte0/1
R2(config-if)#ipadd
R2(config-if)#noshut
R2(config-if)#intlo0
R2(config-if)#ipadd 20.2.2.2 255.255.255.0
R2(config-if)#noshut
R2(config-if)#end
R2#conf t
R2(config)#routerospf 1
R2(config-router)#router-id2.2.2.2
R2(config-router)#net123.123.123.2 0.0.0.0 a 0
R2(config-router)#net20.2.2.2 0.0.0.0 a 0
R2(config-router)#end
R3:
R3#conf t
R3(config)#inte0/1
R3(config-if)#ipadd 123.123.123.3 255.255.255.0
R3(config-if)#noshut
R3(config-if)#exit
R3(config)#routerospf 1
R3(config-router)#router-id3.3.3.3
R3(config-router)#net123.123.123.3 0.0.0.0 a 0
R3(config-router)#end
R4:
R4#conf t
R4(config)#inte0/0
R4(config-if)#ipadd 14.14.14.4 255.255.255.0
R4(config-if)#noshut
R4(config-if)#inte0/1
R4(config-if)#ipadd 123.123.123.4 255.255.255.0
R4(config-if)#noshut
R4(config)#intlo0
R4(config-if)#ipadd 90.9.9.9 255.255.255.0
R4(config-if)#end
R4#conf t
R4(config)#routerospf 1
R4(config-router)#router
R4(config-router)#router-id4.4.4.4
R4(config-router)#net14.14.14.0 0.0.0.255 a 1
R4(config-router)#net123.123.123.4 0.0.0.0 a 0
R4(config-router)#end
R5:
R5#conf t
R5(config)#inte0/0
R5(config-if)#ipadd 56.56.56.5 255.255.255.0
R5(config-if)#noshut
R5(config-if)#inte0/1
R5(config-if)#ipadd 123.123.123.5 255.255.255.0
R5(config-if)#noshut
R5(config-if)#end
R5#conf t
R5(config)#routerospf 1
R5(config-router)#router-id5.5.5.5
R5(config-router)#net123.123.123.5 0.0.0.0 a 0
R5(config-router)#net56.56.56.0 0.0.0.255 a 2
R5(config-router)#end
R6:
R6#conf t
R6(config)#inte0/0
R6(config-if)#ipadd 56.56.56.6 255.255.255.0
R6(config-if)#noshut
R6(config-if)#inte0/1
R6(config-if)#ipadd 67.67.67.6 255.255.255.0
R6(config-if)#noshut
R6(config-if)#intlo0
R6(config-if)#ipadd 60.6.6.6 255.255.255.0
R6(config-if)#end
R6#conf t
R6(config)#routerospf 1
R6(config-router)#router-id6.6.6.6
R6(config-router)#net60.6.6.0 0.0.0.255 a 2
R6(config-router)#net56.56.56.0 0.0.0.255 a 2
R6(config-router)#net67.67.67.0 0.0.0.255 a 3
R6(config-router)#end
R7:
R7#conf t
R7(config)#inte0/1
R7(config-if)#ipadd 67.67.67.7 255.255.255.0
R7(config-if)#noshut
R7(config-if)#intlo 0
R7(config-if)#ipadd 70.7.7.7 255.255.255.0
R1(config-if)#intlo 1
R1(config-if)#ipadd 80.8.8.8 255.255.255.0
R7(config-if)#end
R7#conf t
R7(config)#routerospf 1
R7(config-router)#router-id7.7.7.7
R7(config-router)#net70.7.7.0 0.0.0.255 a 3
R7(config-router)#net67.67.67.0 0.0.0.255 a 3
R7(config-router)#end
检验邻居关系
R4#show ip ospf neighbor
NeighborID
2.2.2.2
3.3.3.3
5.5.5.5
1.1.1.1
R4#show ip routeospf
O
O
O IA
O IA
2.
环回口改成点到点网络
由于环回口被视为主机,环回口网络总被当作主机路由学习
10.0.0.0/32 is subnetted, 1 subnets
O
现在将R1
R1#show ip ospf interface loopback 0
Loopback0is up, line protocol is up
Loopbackinterface is treated as a stub Host
R1:
R1#CONF T
R1(config)#intlo 0
R1(config-if)#ipospf network point-to-point
检验:
R1#show ip ospf interface loopback 0
Loopback0is up, line protocol is up
Suppresshello for 0 neighbor(s)
R4#show ip route ospf
O
O
O IA
O IA
3.
改优先级
由于ospf配置后,先配置的就变为DR,BDR。因此如果先配置R2,R3则R2,R3是DR,BDR
现在要将R5变成DR,R4变为BDR。那么就是将R2,R3,R4的优先级变为0,放弃DR,BDR竞选,然后再将其R4,R3,R2优先级恢复为1.
R2,R3,R4的优先级变为0,放弃DR,BDR竞选
R2:
R2(config)#INTE0/1
R2(config-if)#IPOSPF PRI
R2(config-if)#IPOSPF PRIority 0
R3:
R3#conf t
R3(config)#inte0/1
R3(config-if)#ipospf priority 0
R4:
R4#conf t
R4(config)#inte0/1
R4(config-if)#ipospf priority 0
R4,R3,R2优先级恢复为1.
R4:
R4#conf t
R4(config)#inte0/1
R4(config-if)#ipospf priority 1
R3:
R3#conf t
R3(config)#inte0/1
R3(config-if)#ipospf priority 1
R2:
R2#conf t
R2(config)#inte0/1
R2(config-if)#ipospf priority 1
检验:
R2#show ip ospf nei
NeighborID
3.3.3.3
4.4.4.4
5.5.5.5
4.ospf
的手动汇总
4.1)区域间手动汇总(只能在ABR上做)
R4#conf t
R4(config)#routerospf 1
R4(config-router)#area1
验证:
R5#show ip route ospf
O
O IA 10.0.0.0/8 [110/21]via 123.123.123.4, 00:01:19, Ethernet0/1
O IA
O
R6#show ip route ospf
O
O IA
O IA 10.0.0.0/8[110/31] via 56.56.56.5, 00:02:57, Ethernet0/0
O IA
O IA
5.ospf
认证
链路认证:ABR
明文:
R1:
R1#conf t
R1(config)#inte0/0
R1(config-if)#ipospf authentication
R1(config-if)#ipospf authentication-key abc123
R4:
R4#conf t
R4(config)#inte0/0
R4(config-if)#ipospf authentication
R4(config-if)#ipospf authentication-key abc123
密文:
R6#conf t
R6(config)#inte0/0
R6(config-if)#ipospf authentication message-digest
R6(config-if)#ipospf message-digest-key 1 md5 abc
R5#conf t
R5(config)#inte0/0
R5(config-if)#ipospf authentication message-digest
R5(config-if)#ipospf message-digest-key 1 md5 abc
区域认证:骨干
密文:
R2#conf t
R2(config)#routerospf 1
R2(config-router)#area0 authentication message-digest
R2(config-router)#exit
R2(config)#inte0/1
R2(config-if)#ipospf message-digest-key 2 md5 CHINA
R3#conf t
R3(config)#routerospf 1
R3(config-router)#area0 authentication message-digest
R3(config-router)#ipospf message
R3(config-router)#exit
R3(config)#inte0/1
R3(config-if)#ipospf message-digest-key 2 md5 CHINA
R4#conf t
R4(config)#routerospf 1
R4(config-router)#area0 authentication message-digest
R4(config-router)#exit
R4(config)#inte0/1
R4(config-if)#ipospf message-digest-key 2 md5 CHINA
R5#conf t
R5(config)#routerospf 1
R5(config-router)#area0 authentication message-digest
R5(config-router)#exit
R5(config)#inte0/1
R5(config-if)#ipospf message-digest-key 2 md5 CHINA
区域所有设备接口参与,除环回口
6.ospf
发布缺省路由更新
R2#conf t
R2(config)#router ospf 1
R2(config-router)#default-informationoriginate always metric 2
现象:
R5#showip route ospf
O
O IA10.0.0.0/8 [110/21] via 123.123.123.4, 00:00:33, Ethernet0/1
O IA
O
O*E2 0.0.0.0/0 [110/2] via 123.123.123.2, 00:00:33,Ethernet0/1
7.
孤岛区域和区域分割
孤岛区域就是没有通过ABR和骨干区域相连的常规区域(图中的area 3)
解决方案:虚电路virtual-link
骨干区域做链路认证,虚电路必须启动认证
R6#conf t
R6(config)#routerospf 1
R6(config-router)#area2 virtual-link 5.5.5.5
R6(config-router)#AREA2 virtual-link 5.5.5.5 authentication message-digest
R6(config-router)#area2 virtual-link 5.5.5.5 message-digest-key 2 md5 CHINA
R6(config-router)#end
R5#conf t
R5(config)#routerospf 1
R5(config-router)#area2 virtual-link 6.6.6.6
R5(config-router)#AREA2 virtual-link 6.6.6.6 authentication message-digest
R5(config-router)#area2 virtual-link 6.6.6.6 message-digest-key 2 md5 CHINA
R5(config-router)#end
测试:
1.R7#ping 10.1.1.1 so 70.7.7.7
2.
R6#showip ospf neighbor
NeighborID
5.5.5.5
5.5.5.5
7.7.7.7
3.路由表对比
虚拟链路前:
R2#show ip route
Codes: C- connected, S - static, R - RIP, M - mobile, B - BGP
Gatewayof last resort is not set
C
O IA10.0.0.0/8 [110/21] via 123.123.123.4, 00:38:57, Ethernet0/1
O IA
C
O IA
O IA
虚拟链路后:
R2#show ip route
Codes: C- connected, S - static, R - RIP, M - mobile, B - BGP
Gatewayof last resort is not set
O IA
C
O IA
O IA10.0.0.0/8 [110/21] via 123.123.123.4, 00:00:02, Ethernet0/1
O IA
C
O IA
O IA
8.STUB
和 NSSA的配置
8.1)将外部路由嵌套入ospf
R7#conf t
R7(config)#routerrip
R7(config-router)#version2
R7(config-router)#noauto-summary
R7(config-router)#net80.8.8.0
R7(config-router)#exit
R7(config)#routerospf 1
R7(config-router)#redistributerip
R7(config-router)#end
R4#conf t
R4(config)#routereigrp 1
R4(config-router)#noauto-summary
R4(config-router)#eigrp router-id 40.4.4.4
R4(config-router)#net90.9.9.0 0.0.0.255
R4(config-router)#exit
R4(config)#routerospf 1
R4(config-router)#redistributeeigrp 1 subnets
R4(config-router)#end
测试:
R2#show ip rout ospf
O IA
O E2
O IA
O IA10.0.0.0/8 [110/21] via 123.123.123.4, 00:06:45, Ethernet0/1
O IA
O IA
O E2
O IA
8.2)T-STUB:
R4:
R4#conf t
R4(config)#routerospf 1
R4(config-router)#area1 stub no-summary
R1:
R1#conf t
R1(config)#routerospf 1
R1(config-router)#area1 stub
检验:
建立前:
R1#showip
O IA
O E2
O IA
O IA
O IA
O IA
O E2
O IA
O*E2 0.0.0.0/0 [110/2] via 14.14.14.4, 00:10:18,Ethernet0/0
建立后:
R1#show ip route ospf
O*IA 0.0.0.0/0 [110/11] via 14.14.14.4, 00:00:34,Ethernet0/0
8.3)T-NSSA
R5#conf t
R5(config)#routerospf 1
R5(config-router)#area3 nssa no-summary
R7#conf t
R7(config)#routerospf 1
R7(config-router)#area2 nssa
R7(config-router)#end
————完——