拓扑
配置接口
R1
R1# config t
R1(config)#int lo0
R1(config-if)#no shut
R1(config-if)#ip add 11.1.1.1 255.255.255.255
R1(config-if)#int e0/1
R1(config-if)#no shutdown
R1(config-if)#ip add 10.1.13.1 255.255.255.0
R1(config-if)#int e0/2
R1(config-if)#no shutdown
R1(config-if)#ip add 10.1.12.1 255.255.255.0
R1(config-if)#int s1/0
R1(config-if)#no shutdown
R1(config-if)#ip add 10.1.14.1 255.255.255.0
R2
R2#config t
R2(config)#int lo0
R2(config-if)#ino shutdown
R2(config-if)#ip add 22.1.1.1 255.255.255.255
R2(config-if)#int e0/0
R2(config-if)#ino shutdown
R2(config-if)#ip add 10.1.23.2 255.255.255.0
R2(config-if)#int e0/2
R2(config-if)#ino shutdown
R2(config-if)#ip add 10.1.12.2 255.255.255.0
R2(config-if)#int s1/1
R2(config-if)#ino shutdown
R2(config-if)#ip add 10.1.24.2 255.255.255.0
R3
R3#config t
R3(config)#int lo0
R3(config-if)#no shut
R3(config-if)#ip add 33.1.1.1 255.255.255.255
R3(config-if)#int e0/0
R3(config-if)#no shut
R3(config-if)#ip add 10.1.23.3 255.255.255.0
R3(config)#int e0/2
R3(config-if)#no shut
R3(config-if)#ip add 10.1.34.3 255.255.255.0
R3(config-if)#int e0/1
R3(config-if)#no shut
R3(config-if)#ip add 10.1.13.3 255.255.255.0
R4
R4#config t
R4(config)#int lo0
R4(config-if)#no shutdown
R4(config-if)#ip add 44.1.1.1 255.255.255.255
R4(config-if)#int e0/2
R4(config-if)#no shutdown
R4(config-if)#ip add 10.1.34.4 255.255.255.0
R4(config-if)#int s1/0
R4(config-if)#no shutdown
R4(config-if)#ip add 10.1.14.4 255.255.255.0
R4(config-if)#int s1/1
R4(config-if)#no shutdown
R4(config-if)#ip add 10.1.24.4 255.255.255.0
R4(config-if)#no shutdown
联通测试
R1#ping 10.1.12.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.12.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 8/43/80 ms
R1#ping 10.1.13.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.13.3, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 56/73/84 ms
R1#ping 10.1.14.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.14.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/37/64 ms
配置ospf
R1
R1(config)#router ospf 100
R1(config-router)#router-id 11.1.1.1
R1(config-router)#network 10.1.12.0 0.0.0.255 area 0
R1(config-router)#network 10.1.13.0 0.0.0.255 area 0
R1(config-router)#network 10.1.14.0 0.0.0.255 area 0
R1(config-router)#network 11.1.1.1 0.0.0.0 area 0
R2
R2(config)#router ospf 100
R2(config-router)#router-id 22.1.1.1
R2(config-router)#network 10.1.12.0 0.0.0.255 area 0
R2(config-router)#network 10.1.23.0 0.0.0.255 area 0
R2(config-router)#network 10.1.24.0 0.0.0.255 area 0
R2(config-router)#network 22.1.1.1 0.0.0.0 area 0
R3
R3(config)#router ospf 100
R3(config-router)#router-id 33.1.1.1
R3(config-router)#network 10.1.13.0 0.0.0.255 area 0
R3(config-router)#network 10.1.23.0 0.0.0.255 area 0
R3(config-router)#network 10.1.34.0 0.0.0.255 area 0
R3(config-router)#network 33.1.1.1 0.0.0.0 area 0
R4
R4(config)#router ospf 100
R4(config-router)#router-id 44.1.1.1
R4(config-router)#network 10.1.14.0 0.0.0.255 area 0
R4(config-router)#network 10.1.24.0 0.0.0.255 area 0
R4(config-router)#network 10.1.34.0 0.0.0.255 area 0
R4(config-router)#network 44.1.1.1 0.0.0.0 area 0
查看ospf邻居
R1
R1(config-router)#do show ip ospf nei
Neighbor ID Pri State Dead Time Address Interface
44.1.1.1 0 FULL/ - 00:00:31 10.1.14.4 Serial1/0
33.1.1.1 1 FULL/BDR 00:00:35 10.1.13.3 Ethernet0/1
22.1.1.1 1 FULL/BDR 00:00:31 10.1.12.2 Ethernet0/2
查看链路状态数据库
R1
R1#show ip ospf database
OSPF Router with ID (11.1.1.1) (Process ID 100)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
11.1.1.1 11.1.1.1 359 0x80000007 0x000B61 5
22.1.1.1 22.1.1.1 339 0x80000006 0x00160A 5
33.1.1.1 33.1.1.1 314 0x80000005 0x00F6A1 4
44.1.1.1 44.1.1.1 295 0x80000005 0x0050F0 6
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
10.1.12.1 11.1.1.1 729 0x80000001 0x008C60
10.1.13.1 11.1.1.1 545 0x80000001 0x00FAE5
10.1.23.2 22.1.1.1 528 0x80000001 0x006C53
10.1.34.3 33.1.1.1 314 0x80000001 0x004C46
查看osfp路由表
R1
R1#show ip route ospf
33.0.0.0/32 is subnetted, 1 subnets
O 33.1.1.1 [110/11] via 10.1.13.3, 00:06:52, Ethernet0/1
22.0.0.0/32 is subnetted, 1 subnets
O 22.1.1.1 [110/11] via 10.1.12.2, 00:06:52, Ethernet0/2
10.0.0.0/24 is subnetted, 6 subnets
O 10.1.24.0 [110/74] via 10.1.12.2, 00:06:52, Ethernet0/2
O 10.1.23.0 [110/20] via 10.1.13.3, 00:06:52, Ethernet0/1
[110/20] via 10.1.12.2, 00:06:52, Ethernet0/2
O 10.1.34.0 [110/20] via 10.1.13.3, 00:06:52, Ethernet0/1
44.0.0.0/32 is subnetted, 1 subnets
O 44.1.1.1 [110/21] via 10.1.13.3, 00:06:52, Ethernet0/1
测试
R1#ping 22.1.1.1 source 11.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 22.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 11.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/9/12 ms
R1#ping 33.1.1.1 source 11.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 33.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 11.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/10/12 ms
R1#ping 44.1.1.1 source 11.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 44.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 11.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/33/44 ms
R1#ping 10.1.34.4 source 11.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.34.4, timeout is 2 seconds:
Packet sent with a source address of 11.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/22/36 ms
R1#ping 10.1.24.4 source 11.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.24.4, timeout is 2 seconds:
Packet sent with a source address of 11.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/20/24 ms
R1#ping 10.1.23.3 source 11.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.23.3, timeout is 2 seconds:
Packet sent with a source address of 11.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/9/12 ms