单区域OSPF配置实验。拓扑图如下:
一、根据拓扑图配置PC和路由器IP地址
PC1
PC-1> ip 172.16.0.2/16 172.16.0.1
PC-1> save
PC2
PC-2> ip 172.18.0.2/16 172.18.0.1
PC-2> save
PC3
PC-3> ip 172.17.0.2/16 172.17.0.1
PC-3> save
R1
R1#conf t
R1(config)#interface fastEthernet 0/0
R1(config-if)#ip address 172.16.0.1 255.255.0.0
R1(config-if)#no sh
R1(config-if)#exit
R1(config)#interface serial 2/0
R1(config-if)#ip address 192.168.0.1 255.255.255.252
R1(config-if)#no sh
R1(config-if)#clock rate 64000
R1(config-if)#exit
R2
R2#conf t
R2(config)#interface serial 2/1
R2(config-if)#ip address 192.168.0.2 255.255.255.252
R2(config-if)#no sh
R2(config-if)#clock rate 64000
R2(config-if)#exit
R2(config)#interface serial 2/0
R2(config-if)#ip address 192.168.0.5 255.255.255.252
R2(config-if)#no sh
R2(config-if)#clock rate 64000
R2(config-if)#exit
R2(config)#interface serial 2/2
R2(config-if)#ip address 192.168.0.13 255.255.255.252
R2(config-if)#no sh
R2(config-if)#clock rate 64000
R2(config-if)#exit
R3
R3#conf t
R3(config)#interface serial 2/0
R3(config-if)#ip address 192.168.0.6 255.255.255.252
R3(config-if)#no sh
R3(config-if)#clock rate 64000
R3(config-if)#exit
R3(config)#interface serial 2/1
R3(config-if)#ip address 192.168.0.9 255.255.255.252
R3(config-if)#no sh
R3(config-if)#clock rate 64000
R3(config-if)#exit
R4
R4#conf t
R4(config)#interface serial 2/0
R4(config-if)#ip address 192.168.0.10 255.255.255.252
R4(config-if)#no sh
R4(config-if)#clock rate 64000
R4(config-if)#exit
R4(config)#interface fastEthernet 0/0
R4(config-if)#ip address 172.18.0.1 255.255.0.0
R4(config-if)#no sh
R4(config-if)#exit
R4(config)#interface serial 2/1
R4(config-if)#ip address 192.168.0.17 255.255.255.252
R4(config-if)#no sh
R4(config-if)#clock rate 64000
R4(config-if)#exit
R5
R5#conf t
R5(config)#interface serial 2/0
R5(config-if)#ip address 192.168.0.18 255.255.255.252
R5(config-if)#no sh
R5(config-if)#clock rate 64000
R5(config-if)#exi
R5(config)#interface fastEthernet 0/0
R5(config-if)#ip address 172.17.0.1 255.255.0.0
R5(config-if)#no sh
R5(config-if)#exit
R5(config)#interface serial 2/1
R5(config-if)#ip address 192.168.0.14 255.255.255.252
R5(config-if)#no sh
R5(config-if)#clock rate 64000
R5(config-if)#exit
二、配置OSPF
R1
R1(config)#router ospf 1
R1(config-router)#network 172.16.0.0 0.0.255.255 area 0
R1(config-router)#network 192.168.0.0 0.0.0.255 area 0
R1(config-router)#exit
R2
R2(config)#router ospf 1
R2(config-router)#network 0.0.0.0 255.255.255.255 area 0
R3
R3(config)#router ospf 1
R3(config-router)#network 0.0.0.0 255.255.255.255 area 0
R4
R4(config)#router ospf 1
R4(config-router)#network 0.0.0.0 255.255.255.255 area 0
R5
R5(config)#router ospf 1
R5(config-router)#network 0.0.0.0 255.255.255.255 area 0
三、验证连通性
PC1
PC-1> ping 172.18.0.2
172.18.0.2 icmp_seq=1 timeout
172.18.0.2 icmp_seq=2 timeout
84 bytes from 172.18.0.2 icmp_seq=3 ttl=60 time=119.687 ms
84 bytes from 172.18.0.2 icmp_seq=4 ttl=60 time=106.721 ms
84 bytes from 172.18.0.2 icmp_seq=5 ttl=60 time=119.686 ms
查看相关路由器的路由表信息
R2#show ip route ospf
O 172.17.0.0/16 [110/65] via 192.168.0.14, 00:24:23, Serial2/2
O 172.16.0.0/16 [110/65] via 192.168.0.1, 00:24:23, Serial2/0
O 172.18.0.0/16 [110/129] via 192.168.0.14, 00:24:23, Serial2/2
[110/129] via 192.168.0.6, 00:24:23, Serial2/1
192.168.0.0/30 is subnetted, 5 subnets
O 192.168.0.8 [110/128] via 192.168.0.6, 00:24:23, Serial2/1
O 192.168.0.16 [110/128] via 192.168.0.14, 00:24:23, Serial2/2
四、OSPF相关命令
只显示OSPF学习到的路由
R1#show ip route ospf 1
O 172.17.0.0/16 [110/129] via 192.168.0.2, 00:19:23, Serial2/0
O 172.18.0.0/16 [110/193] via 192.168.0.2, 00:19:23, Serial2/0
192.168.0.0/30 is subnetted, 5 subnets
O 192.168.0.8 [110/192] via 192.168.0.2, 00:19:23, Serial2/0
O 192.168.0.12 [110/128] via 192.168.0.2, 00:19:23, Serial2/0
O 192.168.0.4 [110/128] via 192.168.0.2, 00:19:23, Serial2/0
O 192.168.0.16 [110/192] via 192.168.0.2, 00:19:23, Serial2/0
R1#
只显示邻居
R1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
192.168.0.13 0 FULL/ - 00:00:39 192.168.0.2 Serial2/0
显示邻居详细信息
R1#show ip ospf neighbor detail
Neighbor 192.168.0.13, interface address 192.168.0.2
In the area 0 via interface Serial2/0
Neighbor priority is 0, State is FULL, 6 state changes
DR is 0.0.0.0 BDR is 0.0.0.0
Options is 0x12 in Hello (E-bit L-bit )
Options is 0x52 in DBD (E-bit L-bit O-bit)
LLS Options is 0x1 (LR)
Dead timer due in 00:00:38
Neighbor is up for 00:33:21
Index 1/1, retransmission queue length 0, number of retransmission 0
First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
Last retransmission scan length is 0, maximum is 0
Last retransmission scan time is 0 msec, maximum is 0 msec
显示链路状态数据库
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 10 0x80000004 0x009324 3
192.168.0.9 192.168.0.9 1386 0x80000005 0x00650C 4
192.168.0.13 192.168.0.13 1315 0x80000007 0x00E7A0 6
192.168.0.17 192.168.0.17 1949 0x80000002 0x000A75 5
192.168.0.18 192.168.0.18 1334 0x80000003 0x00BEB2 5
显示链路状态数据库详细信息
R1#show ip ospf database router
OSPF Router with ID (192.168.0.1) (Process ID 1)
Router Link States (Area 0)
LS age: 47
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 192.168.0.1
Advertising Router: 192.168.0.1
LS Seq Number: 80000004
Checksum: 0x9324
Length: 60
Number of Links: 3
Link connected to: another Router (point-to-point)
(Link ID) Neighboring Router ID: 192.168.0.13
(Link Data) Router Interface address: 192.168.0.1
Number of TOS metrics: 0
TOS 0 Metrics: 64
Link connected to: a Stub Network
(Link ID) Network/subnet number: 192.168.0.0
--More--
显示接口OSPF配置信息
R1#show ip ospf interface
Serial2/0 is up, line protocol is up
Internet Address 192.168.0.1/30, Area 0
Process ID 1, Router ID 192.168.0.1, Network Type POINT_TO_POINT, Cost: 64
Transmit Delay is 1 sec, State POINT_TO_POINT
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:05
Supports Link-local Signaling (LLS)
Index 2/2, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 192.168.0.13
Suppress hello for 0 neighbor(s)
FastEthernet0/0 is up, line protocol is up
Internet Address 172.16.0.1/16, Area 0
Process ID 1, Router ID 192.168.0.1, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.0.1, Interface address 172.16.0.1
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
--More--