【實驗名稱】
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!