组网需求
- 在普通区域内实现通过缺省路由访问AS外部
- 网络中有R1、R2、R3三台路由器。R1、R2为核心区域,R2、R3在区域1,R2位ABR,R3位ASBR
组网拓扑
配置思路
- 配置路由器基本功能以及各个接口IP地址
- 配置OSPF路由协议,设置区域,宣告路由
- 在ASBR上宣告缺省路由
配置命令
配置路由器基本功能以及各个接口IP地址
R1配置
1
2
3
4sys
sys R1
int g0/0/0
ip add 10.1.12.1 30
R2配置
1
2
3
4
5
6sys
sys R2
int g0/0/0
ip add 10.1.12.2 30
int g0/0/1
ip add 10.1.23.1 30
R3配置
1
2
3
4
5
6
7
8sys
sys R3
int g0/0/1
ip add 10.1.23.2 30
int g0/0/2
ip add 192.168.0.1 30
int LoopBack 0
ip add 10.1.3.3 32
配置OSPF协议,设置区域,宣告路由
R1配置
1
2
3
4sys
ospf 1 router-id 10.1.1.1
area 0
network 10.1.12.0 0.0.0.3
R2配置
1
2
3
4
5
6sys
ospf 1 router-id 10.1.2.2
area 0
network 10.1.12.0 0.0.0.3
area 1
network 10.1.23.0 0.0.0.3
R3配置
1
2
3
4sys
ospf 1 router-id 10.1.3.3
area 0
network 10.1.23.0 0.0.0.3
在ASBR上配置缺省路由宣告(不同的宣告方式always或者permit-calculate-other)
R3配置(配置always,ASBR上不需要存在缺省路由)
1
2
3sys
ospf 1
default-route-advertise alwaysR2配置(配置permit-calculate-other,需要在所要经过的所有路由器上都有缺省路由)
1
2sys
ip route-static 0.0.0.0 0 10.1.23.2
R3配置(配置permit-calculate-other,需要在所要经过的所有路由器上都有缺省路由)
1
2
3
4
5sys
ospf 1
default-route-advertise permit-calculate-other
ip route-static 0.0.0.0 0 10.1.23.1
查看结果
查看OSPF的LSA数据库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20display ospf lsdb
<R1>display ospf lsdb
OSPF Process 1 with Router ID 10.1.1.1
Link State Database
Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 10.1.2.2 10.1.2.2 1324 36 80000004 1
Router 10.1.1.1 10.1.1.1 1331 36 80000004 1
Network 10.1.12.2 10.1.2.2 1324 32 80000002 0
Sum-Net 10.1.23.0 10.1.2.2 1368 28 80000001 1
Sum-Net 10.1.3.3 10.1.2.2 1330 28 80000001 1
Sum-Asbr 10.1.3.3 10.1.2.2 1124 28 80000001 1
AS External Database
Type LinkState ID AdvRouter Age Len Sequence Metric
External 0.0.0.0 10.1.3.3 658 36 80000001 1
查看路由表
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26display ip routing-table
<R1>display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 O_ASE 150 1 D 10.1.12.2 GigabitEthernet
0/0/0
10.1.3.3/32 OSPF 10 2 D 10.1.12.2 GigabitEthernet
0/0/0
10.1.12.0/30 Direct 0 0 D 10.1.12.1 GigabitEthernet
0/0/0
10.1.12.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
10.1.12.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
10.1.23.0/30 OSPF 10 2 D 10.1.12.2 GigabitEthernet
0/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
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0