【实验名称】
OSPF单区域基本配置
【实验目的】
掌握在路由器上配置OSPF单区域
【实验功能】
实现网络的互联互通,从而实现信息的共享和传递
【实验设备】
三层交换机(1台)、路由器(2台)、V35线缆(1条)、交叉线和直连线(1条、2条)
【实验拓扑】
【实验步骤】
Swwitch1
Switch>enable
Switch#configure terminal
Switch(config)#vlan 10
Switch(config-vlan)#exit
Switch(config)#interface fastEthernet 0/5
Switch(config-if)#switchport access vlan 10
Switch(config-if)#exit
Switch(config)#interface vlan 10
Switch(config-if)#ip address 172.16.5.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#interface fastEthernet 0/24
Switch(config-if)#no switchport
Switch(config-if)#no shutdown
Switch(config-if)#ip address 172.16.1.1 255.255.255.0
Router 1
Router>enable
Router#configure terminal
Router(config)#interface fastEthernet 0/0
Router(config-if)#no shutdown
Router(config-if)#ip address 172.16.1.2 255.255.255.0
Router(config-if)#exit
Router(config)#interface serial 2/0
Router(config-if)#no shutdown
Router(config-if)#ip address 172.16.2.1 255.255.255.0
Router 2
Router>enable
Router#configure terminal
Router(config)#interface serial 2/0
Router(config-if)#no shutdown
Router(config-if)#ip address 172.16.2.2 255.255.255.0
Router(config-if)#clock rate 64000
Router(config-if)#exit
Router(config)#interface fastEthernet 0/0
Router(config-if)#no shutdown
Router(config-if)#ip address 172.16.3.1 255.255.255.0
PC2:ip 172.16.3.2 255.255.255.0
接下来是本章节重点! 配置OSPF
Switch 1
Switch(config)#router ospf 1 (开启OSPF协议 进程号为1)
Switch(config-router)#network 172.16.5.0 255.255.255.0 area 0 (宣告自己的直连网络,并分配区域号)
Switch(config-router)#network 172.16.1.0 255.255.255.0 area 0 (宣告自己的直连网络,并分配区域号)
Router1
Router(config)#router ospf 1
Router(config-router)#network 172.16.1.0 255.255.255.0 area 0
Router(config-router)#network 172.16.2.0 255.255.255.0 area 0
Router2
Router(config)#router ospf 1
Router(config-router)#network 172.16.1.0 255.255.255.0 area 0
Router(config-router)#network 172.16.2.0 255.255.255.0 area 0
此时 全网互联互通
PC>ping 172.16.5.11
Pinging 172.16.5.11 with 32 bytes of data:
Reply from 172.16.5.11: bytes=32 time=157ms TTL=125
Reply from 172.16.5.11: bytes=32 time=125ms TTL=125
Reply from 172.16.5.11: bytes=32 time=78ms TTL=125
Reply from 172.16.5.11: bytes=32 time=121ms TTL=125
Ping statistics for 172.16.5.11:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 78ms, Maximum = 157ms, Average = 120ms
下面我们来看看3个设备 是否自动学习了其他网段的路由信息
Switch 1
Switch#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
172.16.0.0/24 is subnetted, 4 subnets
C 172.16.1.0 is directly connected, FastEthernet0/24 (C代表直连网络)
O 172.16.2.0 [110/782] via 172.16.1.2, 00:02:58, FastEthernet0/24 (O代表OSPF学习到的)
O 172.16.3.0 [110/783] via 172.16.1.2, 00:01:58, FastEthernet0/24
C 172.16.5.0 is directly connected, Vlan10
Router1
Router#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
172.16.0.0/24 is subnetted, 4 subnets
C 172.16.1.0 is directly connected, FastEthernet0/0
C 172.16.2.0 is directly connected, Serial2/0
O 172.16.3.0 [110/782] via 172.16.2.2, 00:02:38, Serial2/0
O 172.16.5.0 [110/2] via 172.16.1.1, 00:03:28, FastEthernet0/0
Router 2
Router#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
172.16.0.0/24 is subnetted, 4 subnets
O 172.16.1.0 [110/782] via 172.16.2.1, 00:03:02, Serial2/0
C 172.16.2.0 is directly connected, Serial2/0
C 172.16.3.0 is directly connected, FastEthernet0/0
O 172.16.5.0 [110/783] via 172.16.2.1, 00:03:02, Serial2/0
原创:胡斌
我会从简单到难的发表一些我学过的知识,希望能给一些想入门的朋友帮助,也希望找一些志同道合的朋友、老师 给我些指教。 QQ 276200261!