本实验通过loopback接口模拟直连路由的引入,旨在熟悉路由策略的使用:
实验拓扑如下:
R1配置:
#基础的接口ip地址,以及用来模拟引入的直连路由
interface GigabitEthernet0/0/0
ip address 12.1.1.1 255.255.255.0
interface LoopBack0
ip address 10.0.1.1 255.255.255.0
#
interface LoopBack1
ip address 10.0.2.2 255.255.255.0
#
interface LoopBack2
ip address 10.0.3.3 255.255.255.0
# R1和R2之间使用ospf路由协议,并且只宣告直连接口
ospf 1 router-id 1.1.1.1
import-route direct route-policy chris #将直连路由引入ospf
area 0.0.0.0
network 12.1.1.1 0.0.0.0
#将目标路由用ACL抓出来
acl number 2000
rule 5 permit source 10.0.1.0 0
rule 10 permit source 10.0.2.0 0
# 创建名称为chris的路由策略名称,如果匹配上acl 2000,将cost值修改为30
route-policy chris permit node 10
if-match acl 2000
apply cost 30
#
实验结果查看R2的路由表:
<R2>display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 2 Routes : 2
OSPF routing table status : <Active>
Destinations : 2 Routes : 2
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.1.0/24 O_ASE 150 30 D 12.1.1.1 GigabitEthernet0/0/0
10.0.2.0/24 O_ASE 150 30 D 12.1.1.1 GigabitEthernet0/0/0
OSPF routing table status : <Inactive>
Destinations : 0 Routes : 0
结论:有3条loopback模拟的直连路由,但是在R2的ospf路由表中只有10.0.1.0和10.0.2.0这2条路由。实验结果和预期是相符的。
PS: "O_ASE"在此处就是ospf的路由。
<完>.