实验拓扑
划分子网
172.16.0.0/16
172.16.0.0/24
172.16.0.0/25 -/30
172.16.0.0/30
172.16.0.4/30
172.16.0.8/30
172.16.0.128/25
环回
172.16.1.0/24
172.16.2.0/24
172.16.3.0/24
172.16.4.0/24
172.16.5.0/24
首先写地址并且写环回地址 R1与其他路由器配置都一样
[R1]interface s4/0/0
[R1-Serial4/0/0]ip address 172.16.0.1 30
[R1-Serial4/0/0]q
[R1]interface LoopBack 0
[R1-LoopBack0]ip address 172.16.1.1 24
然后启用OSPF协议 其他几个路由器只需要根据自身情况改变就可以了
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]network 172.16.0.0 0.0.255.255
检查是否有学到
<R1>display ospf peer brief
OSPF Process 1 with Router ID 1.1.1.1
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.1 Serial4/0/0 2.2.2.2 Full
----------------------------------------------------------------------------
R3的OSPF如下 R4与R5基本样子一样
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 172.16.0.130 0.0.0.0
[R3-ospf-1-area-0.0.0.0]q
[R3-ospf-1]area 2
[R3-ospf-1-area-0.0.0.2]network 172.16.0.5 0.0.0.0
[R3-ospf-1-area-0.0.0.2]network 172.16.3.1 0.0.0.0
R3存在环回100
[R3]interface LoopBack 100
[R3-LoopBack100]ip address 100.1.1.1 24
[R3-ospf-1]q
[R3]ospf 1 rou
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]default-route-advertise always
改变接口的优先级
[R3-GigabitEthernet0/0/0]ospf dr-priority 0
R3R4之间的明文认证
[R3-Serial4/0/0]ospf authentication-mode simple cipher huawei
配置结束 查看是否连通
<R1>ping 172.16.0.10
PING 172.16.0.10: 56 data bytes, press CTRL_C to break
Reply from 172.16.0.10: bytes=56 Sequence=1 ttl=254 time=60 ms
Reply from 172.16.0.10: bytes=56 Sequence=2 ttl=254 time=50 ms
Reply from 172.16.0.10: bytes=56 Sequence=3 ttl=254 time=70 ms
Reply from 172.16.0.10: bytes=56 Sequence=4 ttl=254 time=70 ms
Reply from 172.16.0.10: bytes=56 Sequence=5 ttl=254 time=60 ms
--- 172.16.0.10 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/62/70 ms
查看是否学完整
<R1>display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 7 Routes : 7
OSPF routing table status : <Active>
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 O_ASE 150 1 D 172.16.0.2 Serial4/0/0
172.16.0.4/30 OSPF 10 97 D 172.16.0.2 Serial4/0/0
172.16.0.8/30 OSPF 10 97 D 172.16.0.2 Serial4/0/0
172.16.0.128/25 OSPF 10 49 D 172.16.0.2 Serial4/0/0
172.16.2.1/32 OSPF 10 48 D 172.16.0.2 Serial4/0/0
172.16.4.1/32 OSPF 10 49 D 172.16.0.2 Serial4/0/0
172.16.5.1/32 OSPF 10 49 D 172.16.0.2 Serial4/0/0
OSPF routing table status : <Inactive>
Destinations : 0 Routes : 0