area0
为骨干区域,其他area1
、area2
都为普通区域/常规区域。普通区域必须和骨干区域直接相连。区域边界路由器
;ABR用来链接骨干区域和普通区域。自制系统边界路由器
,自制系统边界路由器用来链接ospf的AS与外部其他的路由。[AR2]router id 2.2.2.2 #手动指定route id
[AR2]q
<AR2>reset ospf process #重启ospf进程,使route id生效
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys AR1
[AR1]int s4/0/0
[AR1-Serial4/0/0]ip add 12.1.1.1 24
[AR1-Serial4/0/0]q
[AR1]un in en
Info: Information center is disabled.
[AR1]
[AR1]int lo 0
[AR1-LoopBack0]ip add 1.1.1.1 24
把R1换回也配置到area 1内。
[AR1]ospf 1 #1为自治系统ID
[AR1-ospf-1]area 1 #自治系统内的区域ID
[AR1-ospf-1-area-0.0.0.1]network 12.1.1.0 0.0.0.255 #将12.1.1.0网段宣告到area 1区域
[AR1-ospf-1-area-0.0.0.1]network 1.1.1.0 0.0.0.255
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys AR2
[AR2]int s4/0/0
[AR2-Serial4/0/0]ip add 12.1.1.2 24
[AR2-Serial4/0/0]q
[AR2]un in en
[AR2]int g0/0/0
[AR2-GigabitEthernet0/0/0]ip add 23.1.1.2 24
[AR2-GigabitEthernet0/0/0]q
[AR2]int LoopBack 0
[AR2-LoopBack0]ip add 2.2.2.2 24
[AR2-LoopBack0]q
[AR2]
把R2换回也配置到area 0内。
[AR2]ospf 1
[AR2-ospf-1]area 1
[AR2-ospf-1-area-0.0.0.1]network 12.1.1.0 0.0.0.255
[AR2-ospf-1-area-0.0.0.1]q
[AR2-ospf-1]area 0
[AR2-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.255
[AR2-ospf-1-area-0.0.0.0]network 2.2.2.0 0.0.0.255
[AR2-ospf-1-area-0.0.0.0]q
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys AR3
[AR3]int g0/0/0
[AR3-GigabitEthernet0/0/0]ip add 23.1.1.3 24
[AR3-GigabitEthernet0/0/0]q
[AR3]un in en
Info: Information center is disabled.
[AR3]int g0/0/1
[AR3-GigabitEthernet0/0/1]ip add 192.168.1.3 24
[AR3-GigabitEthernet0/0/1]q
[AR3]int LoopBack 0
[AR3-LoopBack0]ip add 3.3.3.3 24
把R3换回也配置到area 0内。
[AR3]ospf 1
[AR3-ospf-1]area 0
[AR3-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.255
[AR3-ospf-1-area-0.0.0.0]network 3.3.3.0 0.0.0.255
[AR3-ospf-1-area-0.0.0.0]q
[AR3-ospf-1]area 2
[AR3-ospf-1-area-0.0.0.2]network 192.168.1.0 0.0.0.255
[AR3-ospf-1-area-0.0.0.2]
<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys AR4
[AR4]un in en
Info: Information center is disabled.
[AR4]int g0/0/0
[AR4-GigabitEthernet0/0/0]ip add 192.168.1.4 24
[AR4-GigabitEthernet0/0/0]q
[AR4]int LoopBack 0
[AR4-LoopBack0]ip add 4.4.4.4 24
[AR4-LoopBack0]
把R4换回也配置到area 2内。
[AR4]ospf 1
[AR4-ospf-1]area 2
[AR4-ospf-1-area-0.0.0.2]network 192.168.1.0 0.0.0.255
[AR4-ospf-1-area-0.0.0.2]network 4.4.4.0 0.0.0.255
[AR4-ospf-1-area-0.0.0.2]
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys AR5
[AR5]un in en
Info: Information center is disabled.
[AR5]int g0/0/0
[AR5-GigabitEthernet0/0/0]ip add 192.168.1.5 24
[AR5-GigabitEthernet0/0/0]q
[AR5]int LoopBack 0
[AR5-LoopBack0]ip add 5.5.5.5 24
[AR5-LoopBack0]q
[AR5]int LoopBack 1
[AR5-LoopBack1]ip add 8.8.8.8 24
把R5换回也配置到area 2内。
<AR5>sys
Enter system view, return user view with Ctrl+Z.
[AR5]
[AR5]ospf 1
[AR5-ospf-1]area 2
[AR5-ospf-1-area-0.0.0.2]network 192.168.1.0 0.0.0.255
[AR5-ospf-1-area-0.0.0.2]network 5.5.5.0 0.0.0.255
[AR5-ospf-1-area-0.0.0.2]
等下再做RIP
[AR1]ping 192.168.1.5
PING 192.168.1.5: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.5: bytes=56 Sequence=1 ttl=253 time=170 ms
Reply from 192.168.1.5: bytes=56 Sequence=2 ttl=253 time=50 ms
Reply from 192.168.1.5: bytes=56 Sequence=3 ttl=253 time=50 ms
Reply from 192.168.1.5: bytes=56 Sequence=4 ttl=253 time=50 ms
Reply from 192.168.1.5: bytes=56 Sequence=5 ttl=253 time=60 ms
--- 192.168.1.5 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/76/170 ms
<AR1>dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 17 Routes : 17
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.0/24 Direct 0 0 D 1.1.1.1 LoopBack0
1.1.1.1/32 Direct 0 0 D 127.0.0.1 LoopBack0
1.1.1.255/32 Direct 0 0 D 127.0.0.1 LoopBack0
2.2.2.2/32 OSPF 10 48 D 12.1.1.2 Serial4/0/0
3.3.3.3/32 OSPF 10 49 D 12.1.1.2 Serial4/0/0
4.4.4.4/32 OSPF 10 50 D 12.1.1.2 Serial4/0/0
5.5.5.5/32 OSPF 10 50 D 12.1.1.2 Serial4/0/0
12.1.1.0/24 Direct 0 0 D 12.1.1.1 Serial4/0/0
12.1.1.1/32 Direct 0 0 D 127.0.0.1 Serial4/0/0
12.1.1.2/32 Direct 0 0 D 12.1.1.2 Serial4/0/0
12.1.1.255/32 Direct 0 0 D 127.0.0.1 Serial4/0/0
23.1.1.0/24 OSPF 10 49 D 12.1.1.2 Serial4/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 OSPF 10 50 D 12.1.1.2 Serial4/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
只想查看ospf协议的路由,可以加参数protocol
,后面在跟ospf
<AR1>dis ip routing-table protocol ?
bgp Border Gateway Protocol (BGP) routes
direct Direct routes
isis IS-IS routing protocol defined by ISO
ospf Open Shortest Path First (OSPF) routes
rip Routing Information Protocol (RIP) routes
static Static routes
unr User network routes
<AR1>dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 6 Routes : 6
OSPF routing table status : <Active>
Destinations : 6 Routes : 6
Destination/Mask Proto Pre Cost Flags NextHop Interface
2.2.2.2/32 OSPF 10 48 D 12.1.1.2 Serial4/0/0
3.3.3.3/32 OSPF 10 49 D 12.1.1.2 Serial4/0/0
4.4.4.4/32 OSPF 10 50 D 12.1.1.2 Serial4/0/0
5.5.5.5/32 OSPF 10 50 D 12.1.1.2 Serial4/0/0
23.1.1.0/24 OSPF 10 49 D 12.1.1.2 Serial4/0/0
192.168.1.0/24 OSPF 10 50 D 12.1.1.2 Serial4/0/0
OSPF routing table status : <Inactive>
Destinations : 0 Routes : 0
<AR1>
[AR1]dis 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 23.1.1.2 Full
----------------------------------------------------------------------------