1.拓扑图
配置步骤
1.按拓扑图配置接口ip地址
2.启用OSPF协议
声明网络及所在区域
配置区域类型
3查看OSPF数据库
4查看路由表
给出配置(命令的解析请等待博主补充)
R1# R1#config terminal R1(config)#interface ran f0/0 , f0/1 R1(config-if)#no shut R1(config-if)#interface f0/0 R1(config-if)#ip address 192.168.0.1 255.255.255.0 R1(config)#interface f0/1 R1(config-if)#no shut R1(config-if)#ip add 172.20.0.1 255.255.0.0 R1(config-if)#exit R1(config)#router ospf 1 R1(config-router)#? R1(config-router)#network 192.168.0.0 0.0.0.255 area 0 R1(config-router)#network 172.20.0.0 0.0.255.255 area 2 R1(config-router)#exit R1(config)#end R1#copy runn start |
R1#show ip ospf database OSPF Router with ID (192.168.0.1) (Process ID 1) Router Link States (Area 0) Link ID ADV Router Age Seq# Checksum Link count 192.168.0.1 192.168.0.1 1584 0x80000006 0xF38E 1 192.168.0.2 192.168.0.2 1455 0x80000005 0xF38C 1 Net Link States (Area 0) Link ID ADV Router Age Seq# Checksum 192.168.0.2 192.168.0.2 1455 0x80000002 0x9CEF Summary Net Link States (Area 0) Link ID ADV Router Age Seq# Checksum 172.16.0.0 192.168.0.2 715 0x80000004 0xEF21 172.17.0.0 192.168.0.2 715 0x80000002 0xF11F 172.20.0.0 192.168.0.1 1575 0x80000001 0xCB45 Router Link States (Area 2) Link ID ADV Router Age Seq# Checksum Link count 192.168.0.1 192.168.0.1 1584 0x80000001 0x8912 1 Summary Net Link States (Area 2) Link ID ADV Router Age Seq# Checksum 172.16.0.0 192.168.0.1 1595 0x80000001 0x60E 172.17.0.0 192.168.0.1 1595 0x80000001 0x40E 192.168.0.0 192.168.0.1 1595 0x80000001 0xCF98 R1# |
R2#config R2(config)#interface ran f0/0 ,f0/1 R2(config-if)#no shut R2(config-if)#interface f0/0 R2(config-if)#ip address 192.168.0.2 255.255.255.0 R2(config-if)#interface f0/1 R2(config-if)#ip address 172.16.0.1 255.255.0.0 R2(config-if)#ip ospf ? R2(config-if)#ip ospf network ? broadcast Specify OSPF broadcast multi-access network non-broadcast Specify OSPF NBMA network point-to-multipoint Specify OSPF point-to-multipoint network point-to-point Specify OSPF point-to-point network R2(config-if)#exit R2(config)#router ospf 3 R2(config-router)#network 192.168.0.0 0.0.0.255 area 0 R2(config-router)#network 172.16.0.0 0.0.255.255 area 1 R2(config)#router ospf 3 R2(config-router)#? Router configuration commands: area OSPF area parameters R2(config-router)#area ? <0-4294967295> OSPF area ID as a decimal value A.B.C.D OSPF area ID in IP address format R2(config-router)#area 1 ? authentication Enable authentication default-cost Set the summary default-cost of a NSSA/stub area nssa Specify a NSSA area range Summarize routes matching address/mask (border routers only) stub Specify a stub area virtual-link Define a virtual link and its parameters R2(config-router)#area 1 stub ? no-summary Do not send summary LSA into stub area <cr> R2(config-router)#area 1 stub no-summary R2(config-router)# end R2#copy runn start |
R2#show ip ospf database OSPF Router with ID (192.168.0.2) (Process ID 3) Router Link States (Area 0) Link ID ADV Router Age Seq# Checksum Link count 192.168.0.1 192.168.0.1 363 0x80000007 0xF18F 1 192.168.0.2 192.168.0.2 63 0x80000006 0xF18D 1 Net Link States (Area 0) Link ID ADV Router Age Seq# Checksum 192.168.0.2 192.168.0.2 63 0x80000003 0x9AF0 Summary Net Link States (Area 0) Link ID ADV Router Age Seq# Checksum 172.16.0.0 192.168.0.2 1323 0x80000004 0xEF21 172.17.0.0 192.168.0.2 1323 0x80000002 0xF11F 172.20.0.0 192.168.0.1 363 0x80000002 0xC946 Router Link States (Area 1) Link ID ADV Router Age Seq# Checksum Link count 172.17.0.1 172.17.0.1 1309 0x80000004 0xEB7D 2 192.168.0.2 192.168.0.2 1333 0x80000004 0xA638 1 Net Link States (Area 1) Link ID ADV Router Age Seq# Checksum 172.16.0.1 192.168.0.2 1333 0x80000002 0xF8EE Summary Net Link States (Area 1) Link ID ADV Router Age Seq# Checksum 0.0.0.0 192.168.0.2 1820 0x80000002 0x973A |
R3#config R3(config)#inter ran f0/0 , f0/1 R3(config-if)#no shut R3(config-if)#interface f0/0 R3(config-if)#ip address 172.16.0.2 255.255.0.0 R3(config-if)#interface f0/1 R3(config-if)#ip address 172.17.0.1 255.255.0.0 R3(config-if)#exit R3(config)#router ospf 1 R3(config-router)#network 172.16.0.0 0.0.255.255 area 1 R3(config-router)#network 172.17.0.0 0.0.255.255 area 1 R3(config-router)#area 1 stub no-summary R3(config-router) #end R3#copy runn start |
R3#show ip ospf database OSPF Router with ID (172.17.0.1) (Process ID 1) Router Link States (Area 1) Link ID ADV Router Age Seq# Checksum Link count 172.17.0.1 172.17.0.1 32 0x80000003 0xED7C 2 192.168.0.2 192.168.0.2 33 0x80000003 0xA837 1 Net Link States (Area 1) Link ID ADV Router Age Seq# Checksum 172.16.0.1 192.168.0.2 33 0x80000001 0xFAED Summary Net Link States (Area 1) Link ID ADV Router Age Seq# Checksum 0.0.0.0 192.168.0.2 457 0x80000001 0x9939 R3#show ip interface brief Interface IP-Address OK? Method Status Protocol FastEthernet0/0 172.16.0.2 YES manual up up FastEthernet0/1 172.17.0.1 YES manual up up R3#show ip ospf database OSPF Router with ID (172.17.0.1) (Process ID 1) Router Link States (Area 1) Link ID ADV Router Age Seq# Checksum Link count 172.17.0.1 172.17.0.1 855 0x80000004 0xEB7D 2 192.168.0.2 192.168.0.2 871 0x80000004 0xA638 1 Net Link States (Area 1) Link ID ADV Router Age Seq# Checksum 172.16.0.1 192.168.0.2 871 0x80000002 0xF8EE Summary Net Link States (Area 1) Link ID ADV Router Age Seq# Checksum 0.0.0.0 192.168.0.2 1358 0x80000002 0x973A R3# |
查看路由表
R1#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set O IA 172.17.0.0/16 [110/3] via 192.168.0.2, 00:30:36, FastEthernet0/0 O IA 172.16.0.0/16 [110/2] via 192.168.0.2, 00:30:36, FastEthernet0/0 C 172.20.0.0/16 is directly connected, FastEthernet0/1 C 192.168.0.0/24 is directly connected, FastEthernet0/0 |
R2#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set O 172.17.0.0/16 [110/2] via 172.16.0.2, 00:47:34, FastEthernet0/1 C 172.16.0.0/16 is directly connected, FastEthernet0/1 O IA 172.20.0.0/16 [110/2] via 192.168.0.1, 00:30:55, FastEthernet0/0 C 192.168.0.0/24 is directly connected, FastEthernet0/0 |
R3#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is 172.16.0.1 to network 0.0.0.0 C 172.17.0.0/16 is directly connected, FastEthernet0/1 C 172.16.0.0/16 is directly connected, FastEthernet0/0 O*IA 0.0.0.0/0 [110/2] via 172.16.0.1, 00:47:55, FastEthernet0/0 R3# |
转载于:https://blog.51cto.com/lddxfs/1320848