简单的OSPF实验

发布时间:2023年12月26日

网上类似的实验多如牛毛,我写这个目的是为了巩固一下,其实好早好早之前就想学ospf,但是我实在太懒散了,不晓得现在还来不来得及。

废话到此为止,开工

拓扑如下:

目的,通过OSPF,将如上各个路由器全部打通

R1配置:

R1#conf t?
R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.255
R1(config-if)#exit ??
R1(config)#interface fastEthernet 0/0
R1(config-if)#no shut
R1(config-if)#ip addr 192.168.100.1 255.255.255.0
R1(config-if)#exit
R1(config)#interface serial 1/0
R1(config-if)#ip add 172.100.100.2 255.255.255.0
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#router ospf 1
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 1.1.1.1 0.0.0.0 area 0
R1(config-router)#network 192.168.100.0 0.0.0.255 area 0
R1(config-router)#network 172.100.100.0 0.0.0.255 area 0
R1(config)#

R2配置

conf t?
interface loopback 0
ip address 2.2.2.2 255.255.255.255
exit ??
interface fastEthernet 0/0
no shut
ip addr 192.168.100.2 255.255.255.0
exit
router ospf 1
router-id 2.2.2.2
network 2.2.2.2 0.0.0.0 area 0
network 192.168.100.0 0.0.0.255 area 0

R3配置

conf t?
interface loopback 0
ip address 3.3.3.3 255.255.255.255
exit ??
interface fastEthernet 0/0
no shut
ip addr 192.168.100.3 255.255.255.0
exit
router ospf 1
router-id 3.3.3.3
network 3.3.3.3 0.0.0.0 area 0
network 192.168.100.0 0.0.0.255 area 0

R4配置

conf t?
interface loopback 0
ip address 4.4.4.4 255.255.255.255
exit ??
interface fastEthernet 0/0
no shut
ip addr 192.168.100.4 255.255.255.0
exit
router ospf 1
router-id 4.4.4.4
network 4.4.4.4 0.0.0.0 area 0
network 192.168.100.0 0.0.0.255 area 0

R5配置

conf t?
interface loopback 0
ip address 5.5.5.5 255.255.255.255
exit ??
interface serial 1/0
ip add 172.100.100.1 255.255.255.0
no shut
exit
router ospf 1
router-id 5.5.5.5
network 5.5.5.5 0.0.0.0 area 0
network 172.100.100.0 0.0.0.255 area 0

查看邻居

R1# show ip ospf neighbor?

Neighbor ID ? ? Pri ? State ? ? ? ? ? Dead Time ? Address ? ? ? ? Interface
5.5.5.5 ? ? ? ? ? 0 ? FULL/ ?- ? ? ? ?00:00:39 ? ?172.100.100.1 ? Serial1/0
2.2.2.2 ? ? ? ? ? 1 ? FULL/BDR ? ? ? ?00:00:38 ? ?192.168.100.2 ? FastEthernet0/0
3.3.3.3 ? ? ? ? ? 1 ? FULL/DROTHER ? ?00:00:38 ? ?192.168.100.3 ? FastEthernet0/0
4.4.4.4 ? ? ? ? ? 1 ? FULL/DROTHER ? ?00:00:38 ? ?192.168.100.4 ? FastEthernet0/0
R1#

查看OSPF数据库

R4#show ip ospf database?

? ? ? ? ? ? OSPF Router with ID (4.4.4.4) (Process ID 1)

? ? ? ? ? ? ? ? Router Link States (Area 0)

Link ID ? ? ? ? ADV Router ? ? ?Age ? ? ? ? Seq# ? ? ? Checksum Link count
1.1.1.1 ? ? ? ? 1.1.1.1 ? ? ? ? 229 ? ? ? ? 0x80000006 0x00468D 4
2.2.2.2 ? ? ? ? 2.2.2.2 ? ? ? ? 610 ? ? ? ? 0x80000003 0x000366 2
3.3.3.3 ? ? ? ? 3.3.3.3 ? ? ? ? 511 ? ? ? ? 0x80000003 0x001745 2
4.4.4.4 ? ? ? ? 4.4.4.4 ? ? ? ? 424 ? ? ? ? 0x80000003 0x002B24 2
5.5.5.5 ? ? ? ? 5.5.5.5 ? ? ? ? 233 ? ? ? ? 0x80000003 0x005D08 3

? ? ? ? ? ? ? ? Net Link States (Area 0)

Link ID ? ? ? ? ADV Router ? ? ?Age ? ? ? ? Seq# ? ? ? Checksum
192.168.100.1 ? 1.1.1.1 ? ? ? ? 424 ? ? ? ? 0x80000003 0x00181D
R4#

查看路由表,前面有标识C的,表示直连路由,有标识O的表示通过OSPF学习到的路由

R4#show ip route?
Codes: C - connected, S - static, 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
? ? ? ?i - IS-IS, su - IS-IS summary, 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

? ? ?1.0.0.0/32 is subnetted, 1 subnets
O ? ? ? 1.1.1.1 [110/2] via 192.168.100.1, 00:04:23, FastEthernet0/0
? ? ?2.0.0.0/32 is subnetted, 1 subnets
O ? ? ? 2.2.2.2 [110/2] via 192.168.100.2, 00:04:23, FastEthernet0/0
? ? ?3.0.0.0/32 is subnetted, 1 subnets
O ? ? ? 3.3.3.3 [110/2] via 192.168.100.3, 00:04:23, FastEthernet0/0
? ? ?4.0.0.0/32 is subnetted, 1 subnets
C ? ? ? 4.4.4.4 is directly connected, Loopback0
? ? ?5.0.0.0/32 is subnetted, 1 subnets
O ? ? ? 5.5.5.5 [110/66] via 192.168.100.1, 00:04:24, FastEthernet0/0
? ? ?172.100.0.0/24 is subnetted, 1 subnets
O ? ? ? 172.100.100.0 [110/65] via 192.168.100.1, 00:04:24, FastEthernet0/0
C ? ?192.168.100.0/24 is directly connected, FastEthernet0/0
R4#

ping 测试,任何一个节点上ping环回地址,192.168.100.0/24地址,172.100.100.0/24的地址均可达

R4#ping 1.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/32/52 ms
R4#ping 192.168.100.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.100.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/34/44 ms
R4#ping 172.100.100.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.100.100.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/15/36 ms
R4#

文章来源:https://blog.csdn.net/tommany/article/details/135225062
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。