路由策略

luyouceltuopu126203917

设备互联方式、互联地址如图所示,所有设备均创建Loopback0,其IP地址为10.0.x.x/32,其中x为设备编号,R1、R2、R3在互联接口、Loopback0接口上激活OSPF。

R3、R4属于IS-IS Area 49.0001,两者都是Level-1路由器,R3、R4的系统ID采用0000.0000.000x格式,其中x为设备编号。

R1上存在三个业务网段A、B、C(使用Loopback1、2、3接口路由模拟),在R1上将直连路由引入到OSPF,但是OSPF域内的路由器上不需要C业务的路由,为此在R1上引入直连路由时通过Route-Policy过滤引入的路由。

R2上不需要A业务网段的路由,但是R3上需要A、B业务网段的路由,为此在R2上配置Filter-Policy对OSPF接收的路由进行过滤。

IS-IS域内的路由器需要访问A业务,因此需要在R3上执行路由重分发,将OSPF路由引入到IS-IS,但是IS-IS域内的路由器不需要访问B业务,为此在R1上引入直连路由时为A、B业务网段路由打上不同的路由标记,R3上执行重分发时根据路由标记过滤B业务网段路由。

任务思路

  1. 设备基础IP地址配置。
  2. 配置R1、R2、R3之间的OSPF,在互联接口、Loopback0接口上激活OSPF。在R3、R4之间配置IS-IS。
  3. 在R1上将直连路由引入到OSPF中,同时配置路由策略不引入C业务网段的路由,将A、B业务网段路由分别打上路由标记10、20。
  4. 在R2上配置Filter-Policy对接收的OSPF路由进行过滤,只接收B业务网段的路由。
  5. 在R3上将OSPF路由引入到IS-IS中,通过Route-Policy匹配路由标记,只引入A业务网段的OSPF外部路由。

1.配置ip

#配置R1的GE0/0/2、Loopback0接口IP地址

[R1]interface GigabitEthernet0/0/2

[R1-GigabitEthernet0/0/2] ip address 10.0.12.1 255.255.255.0

[R1-GigabitEthernet0/0/2] quit

[R1]interface LoopBack0

[R1-LoopBack0] ip address 10.0.1.1 255.255.255.255

[R1-LoopBack0] quit

#在R1上创建多个环回口,用于模拟业务网段A、B、C

[R1]interface LoopBack1

[R1-LoopBack1] ip address 172.16.1.1 255.255.255.0

[R1-LoopBack1] quit

[R1]interface LoopBack2

[R1-LoopBack2] ip address 172.16.2.1 255.255.255.0

[R1-LoopBack2] quit

[R1]interface LoopBack3

[R1-LoopBack3] ip address 172.16.3.1 255.255.255.0

[R1-LoopBack3] quit

#配置R2的GE0/0/2、GE0/0/3、Loopback0接口IP地址

[R2]interface LoopBack0

[R2-LoopBack0] ip address 10.0.2.2 255.255.255.255

[R2-LoopBack0] quit

[R2]interface GigabitEthernet0/0/2

[R2-GigabitEthernet0/0/2] ip address 10.0.23.2 255.255.255.0

[R2-GigabitEthernet0/0/2] quit

[R2]interface GigabitEthernet0/0/3

[R2-GigabitEthernet0/0/3] ip address 10.0.12.2 255.255.255.0

[R2-GigabitEthernet0/0/3] quit

#配置R3的GE0/0/2、GE0/0/3、Loopback0接口IP地址

[R3]interface LoopBack0

[R3-LoopBack0] ip address 10.0.3.3 255.255.255.255

[R3-LoopBack0] quit

[R3]interface GigabitEthernet0/0/2

[R3-GigabitEthernet0/0/2] ip address 10.0.34.3 255.255.255.0

[R3-GigabitEthernet0/0/2] quit

[R3]interface GigabitEthernet0/0/3

[R3-GigabitEthernet0/0/3] ip address 10.0.23.3 255.255.255.0

[R3-GigabitEthernet0/0/3] quit

#配置R4的GE0/0/3、Loopback0接口IP地址

[R4]interface GigabitEthernet0/0/3

[R4-GigabitEthernet0/0/3] ip address 10.0.34.4 255.255.255.0

[R4-GigabitEthernet0/0/3] quit

[R4]interface LoopBack0

[R4-LoopBack0] ip address 10.0.4.4 255.255.255.255

[R4-LoopBack0] quit

#在R2、R4上检查IP地址连通性

2.配置ospf和isis

#配置R1

[R1]ospf 1 router-id 10.0.1.1

[R1-ospf-1] area 0

[R1-ospf-1-area-0.0.0.0] network 10.0.1.1 0.0.0.0

[R1-ospf-1-area-0.0.0.0] network 10.0.12.1 0.0.0.0

[R1-ospf-1-area-0.0.0.0] quit

[R1-ospf-1] quit

#配置R2

[R2]ospf 1 router-id 10.0.2.2

[R2-ospf-1] area 0.0.0.0

[R2-ospf-1-area-0.0.0.0] network 10.0.2.2 0.0.0.0

[R2-ospf-1-area-0.0.0.0] network 10.0.12.2 0.0.0.0

[R2-ospf-1-area-0.0.0.0] network 10.0.23.2 0.0.0.0

[R2-ospf-1-area-0.0.0.0] quit

[R2-ospf-1] quit

#配置R3

[R3]ospf 1 router-id 10.0.3.3

[R3-ospf-1] area 0.0.0.0

[R3-ospf-1-area-0.0.0.0] network 10.0.3.3 0.0.0.0

[R3-ospf-1-area-0.0.0.0] network 10.0.23.3 0.0.0.0

[R3-ospf-1-area-0.0.0.0] quit

[R3-ospf-1] quit

#在R2上检查OSPF邻居的概要信息

R3、R4上配置IS-IS,区域为49.0001,系统ID采用0000.0000.000x格式(x为设备编号),两台设备都为Level-1路由器,在互联接口、R4的Loopback0接口上激活IS-IS。

#配置R3

[R3]isis 1

[R3-isis-1] is-level level-1

[R3-isis-1] network-entity 49.0001.0000.0000.0003.00

[R3-isis-1] quit

[R3]interface GigabitEthernet0/0/2

[R3-GigabitEthernet0/0/2] isis enable 1

[R3-GigabitEthernet0/0/2] quit

#配置R4

[R4]isis 1

[R4-isis-1] is-level level-1

[R4-isis-1] network-entity 49.0001.0000.0000.0004.00

[R4-isis-1] quit

[R4]interface GigabitEthernet0/0/3

[R4-GigabitEthernet0/0/3] isis enable 1

[R4-GigabitEthernet0/0/3] quit

[R4]interface LoopBack 0

[R4-LoopBack0] isis enable 1

[R4-LoopBack0] quit

#在R3上检查IS-IS邻居状态

3.在R1上引入直连路由

在R1上将直连路由引入到OSPF中,同时配置路由策略过滤C业务网段,将A、B业务网段路由分别打上路由标记10、20。

#创建IP前缀列表1,匹配Loopback1接口路由(A业务网段)

[R1]ip ip-prefix 1 index 10 permit 172.16.1.0 24 greater-equal 24 less-equal 24

#创建IP前缀列表2,匹配Loopback2接口路由(B业务网段)

[R1]ip ip-prefix 2 index 10 permit 172.16.2.0 24 greater-equal 24 less-equal 24

#创建Route-Policy hcip,并创建节点10、20,分别调用IP前缀列表1、2,打上路由标记

[R1]route-policy hcip permit node 10

[R1-route-policy] if-match ip-prefix 1

[R1-route-policy] apply tag 10

[R1-route-policy] quit

[R1]route-policy hcip permit node 20

[R1-route-policy] if-match ip-prefix 2

[R1-route-policy] apply tag 20

[R1-route-policy] quit

#在R1的OSPF中引入直连路由,调用Route-Policy hcip

[R1]ospf 1

[R1-ospf-1] import-route direct route-policy hcip

r1上查看ospf lsdb,Loopback1、2接口路由已经被成功引入OSPF中。

#在R1上查看OSPF LSDB中AS-external LSA 172.16.1.0的相关信息

[R1]display ospf lsdb ase 172.16.1.0

​ OSPF Process 1 with Router ID 10.0.1.1

​ Link State Database

Type : External

Ls id : 172.16.1.0

Adv rtr : 10.0.1.1

Ls age : 165

Len : 36

Options : E

seq# : 80000001

chksum : 0xa954

Net mask : 255.255.255.0

TOS 0 Metric: 1

E type : 2

Forwarding Address : 0.0.0.0

Tag : 10

Priority : Low

外部路由172.16.1.0/24已经被打上Tag 10。

#在R1上查看OSPF LSDB中AS-external LSA 172.16.2.0的相关信息

[R1]display ospf lsdb ase 172.16.2.0

​ OSPF Process 1 with Router ID 10.0.1.1

​ Link State Database

Type : External

Ls id : 172.16.2.0

Adv rtr : 10.0.1.1

Ls age : 355

Len : 36

Options : E

seq# : 80000001

chksum : 0x539f

Net mask : 255.255.255.0

TOS 0 Metric: 1

E type : 2

Forwarding Address : 0.0.0.0

Tag : 20

Priority : Low

外部路由172.16.2.0/24已经被打上Tag 20。

4.在R2上配置过滤策略

在R2上配置Filter-Policy对接收的OSPF路由进行过滤,只接收B业务网段的路由。

#查看配置Filter-Policy前的OSPF路由表

display ospf routing

#查看配置Filter-Policy前的IP路由表中的OSPF路由

display ip routing-table protocol ospf

在OSPF路由表以及IP路由表中都可以看到OSPF外部路由172.16.1.0/24、172.16.2.0/24。

#配置基础ACL

[R2]acl number 2000

[R2-acl-basic-2000] rule 5 deny source 172.16.1.0 0.0.0.255

[R2-acl-basic-2000] rule 10 permit

#在OSPF中部署入方向的Filter-Policy,调用ACL 2000

[R2]ospf 1

[R2-ospf-1] filter-policy 2000 import

#查看配置Filter-Policy后的OSPF路由表

dis ospf routing

发现两条外部路由都还存在

#查看配置Filter-Policy后的IP路由表中的OSPF路由

display ip routing-table protocol ospf

在IP路由表中路由172.16.2.0/24已经不存在,但是在OSPF路由表中依旧存在。这验证了对于OSPF,Filter-Policy只是限制路由加入IP路由表,不影响本地的LSDB以及LSA的传递。

#在R3上查看IP路由表中的OSPF路由

display ip routing-table protocol ospf

R3的IP路由表中OSPF外部路由172.16.1.0/24、172.16.2.0/24依旧存在。

5.在R3上将OSPF路由引入到IS-IS

在R3上将OSPF路由引入到IS-IS中,通过Route-Policy匹配路由标记,只引入A业务网段的OSPF外部路由。

#创建Route-Policy hcip

[R3]route-policy hcip permit node 10

[R3-route-policy] if-match tag 10

[R3-route-policy] quit

#在IS-IS中引入OSPF路由,调用Route-Policy hcip只引入A业务网段的OSPF外部路由

[R3]isis 1

[R3-isis-1] import-route ospf 1 level-1 route-policy hcip

(注意指定level)

#查看R3的IS-IS路由表

display isis route

Level-1的路由重分发表中只有172.16.1.0/24。