路由控制和策略路由

  • 华为设备

    外部路由优先级

    路由器分别定义了外部优先级和内部优先级。

    其中,0表示直接连接的路由,255表示任何来自不可信源端的路由;数值越小表明优先级越高。

    外部优先级是指用户可以手工为各路由协议配置的优先级

路由来源 优先级(越小越优)
Direct 0
OSPF 10
IS-IS 15
Static 60
RIP 100
OSPF ASE 150
OSPF NSSA 150
IBGP 255
EBGP 255
  • 华为设备(内部路由优先级)

    这个内部路由优先级是不能被用户手动修改的

路由协议的类型 路由协议的内部优先级
Direct 0
OSPF 10
IS-IS Level-1 15
IS-IS Level-2 18
Static 60
RIP 100
OSPF ASE 150
OSPF NSSA 150
IBGP 200
EBGP 20

什么是外部路由和内部路由?

  1. 内部路由(Interior Routing):
    • 内部路由是指用于在一个自治系统(AS,Autonomous System)内部传播路由信息的路由协议和路由表条目。AS是一个独立的IP网络域,由单一组织或管理团队控制。
    • 内部路由协议(Interior Gateway Protocol,IGP)用于在AS内传播路由信息,以确保内部的网络设备了解如何到达其他内部网络的目的地。常见的IGP包括RIP、OSPF、EIGRP等。
    • 内部路由通常用于描述AS内部的网络拓扑和路由策略,这些信息不会被传播到其他AS中。
  2. 外部路由(Exterior Routing):
    • 外部路由是指用于在不同自治系统之间传播路由信息的路由协议和路由表条目。这些路由信息用于跨越不同AS的边界,将数据包从一个AS传递到另一个AS。
    • 外部路由协议(Exterior Gateway Protocol,EGP)用于在不同AS之间交换路由信息,以确保数据包能够跨越多个AS的边界。
    • 外部路由通常用于描述如何到达不同AS中的目的地,它们是用于跨越互联网等多个AS的全球路由信息。
  • 思科设备
路由来源 管理距离
直接出口 0
使用出接口配置的路由 0
使用下一跳地址配置的静态路由 1
EIGRP汇总路由 5
外部BGP 20
内部EIGRP 90
IGRP 100
OSPF 110

一、路由控制

(1)、前言
  • 企业网设备通信之间,经常面临一些非法的流量访问和流量路径不优等问题。
  • 故为保证数据访问的安全性、提高带宽利用率
  • 就需要对网络中的流量进行精细的控制,如:控制流量可达性、调整网络流量路径等
1.1.1-路由策略

路由策略 :

路由策略是通过一系列的工具,对路由条目添加各种策略,实现对路由的产生,发送和选择进行控制,通过对路由条目的控制来达到对报文转发的控制

  • 工具 :

条件工具:用于把需要控制的路由匹配出来(ACL ip-prefix、团体列表:as-path-filter

策略工具:用于把抓取出来的路由执行某个动作(例如: 拒接、允许、添加属性 router-policy)

调用工具:把定义好的路由策略,具体应用到某个协议中,让路由策略生效(filter-policy import-router

(2)、正反掩码和通配符

正掩码:

  • 1代表匹配,0代表任意 1的出现必须连续性出现,不能够交叉出现

反掩码:

  • 1代表任意,0代表匹配 0和1也不能交叉出现,在ospf协议的通告中采用反掩码

通配符:

  • 1代表任意,0代表匹配 0和1也不能交叉出现.ACL的规则匹配中使用的为通配符

1.2.1-通配符

通配符 :

  • ①.在ACL匹配IP地址时,通过指定精确IP地址和通配符掩码达到指定范围抓取报文的目的

  • ②.0 表示必须检查匹配的位, 1 表示任意不检查的位,概括为0检查 1忽略 和子网掩码、反掩码不同的是通配符掩码0和1可以不连续性出现

    0表示严格匹配,1表示任意

  • ③.例如rule permit ip source 192.168.1.0 0.0.0.255 表示只检查前面三组二进制位匹配即可.则192.168.1匹配,后面一组二进制位不检查,也就是允许192.168.1.0/24的报文通过

IP地址 IP地址通配符掩码 确定的地址范围
0.0.0.0 255.255.255.255 任意IP地址
172.18.0.0 0.0.255.255 172.18.0.0/16网段的IP地址
172.18.5.2 0.0.0.0 仅172.18.5.2这一个主机地址
172.18.8.0 0.0.0.7 172.18.8.0/29网段的IP地址
172.18.8.8 0.0.0.7 172.18.8.8/29网段的IP地址
10.1.2.0 0.0.254.255(通配符掩码中的1和0不连续) 10.1.0.0/24~10.1.254.0/24网段之间且第三个字节为偶数的IP地址,如10.1.0.0/24、10.1.2.0/24、10.1.4.0/24、10.1.6.0/24等。
  • 案例:
172.18.8.0  255.255.255.248
11111111.11111111.11111111.11111000  # 子网掩码
00000000.00000000.00000000.00000111  # 通配符掩码
0.0.0.7								 # 通配符十进制显示方式

# 匹配192.168.1.0-3这几条IP地址
192.168.1.0	192.168.1.00000000
192.168.1.1	192.168.1.00000001
192.168.1.2	192.168.1.00000010
192.168.1.3	192.168.1.00000011
00000000.00000000.00000000.00000011
通配符	0.0.0.3

# 匹配192.168.1.12-19
- 因为192.168.1.12-15不变位相同
- 192.168.1.16-19不变味相同,所以需要条规则和通配符分开匹配
192.168.1.12	192.168.1.00001100
192.168.1.13	192.168.1.00001101
192.168.1.14	192.168.1.00001110
192.168.1.15	192.168.1.00001111
00000000.00000000.00000000.00000011
通配符 0.0.0.3
rule permit source 192.168.1.12 0.0.0.3 // 表示从192.168.1.12开始
> 因为000011前面都是不变位,可以用0表示(匹配),后面两位是可变位用1表示(不匹配)
> 所以通配符0.0.0.3

192.168.1.16	192.168.1.00010000
192.168.1.17	192.168.1.00010001
192.168.1.18	192.168.1.00010010
192.168.1.19	192.168.1.00010011
00000000.00000000.00000000.00000011
通配符 0.0.0.3
rule permit source 192.168.1.16 0.0.0.3 // 表示从192.168.1.12开始
> 000100相同,用0表示(匹配),后面两位为可变位,各不相同用1表示(不匹配)

01111101	125
01111110	126
01111111	127
00000011	
192.168.1.125 0.0.0.3
(3)、ACL
  • ACL的匹配规则:

ACL的匹配规则遵循以下几点,被过滤的流量匹配到了ACL那么会直接丢弃该数据包,然后就跳出ACL不会继续匹配

被允许通过的流量匹配到了对应的ACL,则直接允许通过。如果有流量没有被ACL的允许和拒绝匹配到,这算隐含匹配

一些厂商的设备默认是将隐含匹配的这段数据流量丢弃。华为的 隐含匹配默认放通所有

配置ACL策略的时候最好优先配置通过策略,避免需要通过的流量被拒绝掉。然后编写拒绝策略。当然也有例外(详情:1.3.1ACL步长

在这里插入图片描述

1.3.1-ACL步长

ACL步长 :

ACL步长指的是进入了ACL的视图后,创建的每一条规则后面编号每次更新的长度

acl 2000
rule 5 permit source 192.168.1.1 0.0.0.0
rule 10 permit source 192.168.1.2 0.0.0.0
rule 15 permit source 192.168.1.3 0.0.0.0

同时这个步长也是可以设置的, ACL视图下使用 step {步长数}

[Huawei-acl-basic-2001] step 2   //配置步长值为2 
[Huawei-acl-basic-2001] display acl 2001
Basic ACL 2001, 3 rules                                                          
Acl's step is 2  
rule 2 deny source 10.1.1.0 0.0.0.255                           
rule 4 deny source 10.2.2.0 0.0.0.255                           
rule 6 deny source 10.3.3.0 0.0.0.255
1.3.2-步长的作用
  • 作用:

    可以通过设置合适的步长从而更好的从旧规则中添加新的规则

  • 案例:

    rule 5 deny source 10.1.1.1 0  //表示拒绝源IP地址为10.1.1.1的报文通过                    
    rule 10 deny source 10.1.1.2 0 //表示拒绝源IP地址为10.1.1.2的报文通过                     
    rule 15 permit source 10.1.1.0 0.0.0.255 //表示允许源IP地址为10.1.1.0/24网段地址的报文通过   
    

    ACL中有个原则为命中即中止匹配 ,上面的配置信息中可以看出系统在命中rule5rule10这两条规则后将会拒绝这些报文通过,然后再匹配rule15允许这条规则对应的报文通过.

    这个时候如果我想要添加一条rule deny source 10.1.1.3 0的规则,如果不设置步长那么会被排到rule15后面,此时ACL遵循命中则中止匹配原则,rule 20 deny 10.1.1.3 0会命中rule15的动作从而允许通过,这个时候10.1.1.0/24网段都被放通了,就无法拒绝10.1.1.3这台设备了

    rule 5 deny source 10.1.1.1 0
    rule 10 deny source 10.1.1.2 0
    rule 15 permit source 10.1.1.0 0.0.0.255
    rule 20 deny source 10.1.1.3 0
    
    #  解决办法:
    rule 11 deny 10.1.1.3 0
    
    rule 5 deny source 10.1.1.1 0  //表示禁止源IP地址为10.1.1.1的报文通过                    
    rule 10 deny source 10.1.1.2 0 //表示禁止源IP地址为10.1.1.2的报文通过                     
    rule 11 deny source 10.1.1.3 0 //表示拒绝源IP地址为10.1.1.3的报文通过  
    rule 15 permit source 10.1.1.0 0.0.0.255 //表示允许源IP地址为10.1.1.0网段地址的报文通过
    

试想一下,如果这条ACL的规则间隔不是5,而是1(rule 1、rule 2、rule 3…),这时再想插入新的规则,就只能先删除已有的规则,然后再配置新规则,最后将之前删除的规则重新配置还原。

因此,为了避免上述操作造成的麻烦,ACL引入了步长的概念。通过设置ACL步长,使规则之间留有一定的空间,就可以轻松的在旧规则中插入新规则了。

1.3.3-TCP/UDP端口号

源端口号格式:

source-port {eq port | gt port | lt port | range port-start port-end}

目的端口号格式:

destination-port { eq port | gt port | lt port | range port-start port-end }

在高级ACL中,当协议类型指定为TCP或UDP时,设备支持基于TCP/UDP的源/目的端口号过滤报文。

  • eq port:指定等于源/目的端口。 = = =
  • gt port:指定大于源/目的端口。 > > >
  • lt port:指定小于源/目的端口。 < < <
  • range port : 指定端口的范围。如:(range 21 23)21~23
acl number 3000
 rule 5 deny tcp source 192.168.1.1 0 destination 192.168.2.1 0 destination-port range 21 23 // 拒绝源IP地址192.168.1.1的设备访问192.168.2.121-23号端口(ftp ssh telnet)

实验1:

192.168.1.0/24这个子网中偶数位的主机抓取出来

# 先将偶数的主机位转为二进制
192.168.1.2		0000 0010
192.168.1.4		0000 0100
192.168.1.6		0000 0110
192.168.1.8		0000 1000

- 可以发现主机位的最后二进制位为0
- 我们只需要将前面的八位二进制数作为可变的取为1,最后一位都相同的二进制位取0: 得出1111 1110=254
- 因为偶数主机位的相同二进制位为0,所以网络地址写192.168.1.0

> 网段写: 192.168.1.0
> 通配符写: 0.0.0.254
192.168.1.0 = 0000 0000
 0 . 0 .0.	  1111 1110
  • 192.168.1.0/24这个子网中的奇数主机抓取出来
# 先将奇数的主机位转为二进制
192.168.1.1		0000 0001
192.168.1.3		0000 0011
192.168.1.5		0000 0101
192.168.1.7		0000 0111

- 我们发现主机位的最后二进制位为1
- 将前面的不相同的二进制数取0,相同一位的二进制数取1
- 因为奇数主机位的相同二进制位为1,所以网络地址写192.168.1.1

> 网段写: 192.168.1.1
> 通配符写: 0.0.0.254

实验2:

路由过滤实验 :

要求使用filter-policy将AR1设备所有接口发出的192.168.1.0的路由进行过滤,要求让AR2上没有这条路由

  • ACL被traffice-filter调用的时候默认存在允许所有语句
  • ACL被filter-policy调用的时候使用默认存在拒绝所有语句

并且将对端设备AR2的192.168.2.0网段的路由不进行接收

  • 一般这种策略用于运营商网络中比较多,过滤掉对端的路由节省自身的资源消耗
  • 或者说对端为竞争对手的设备,可以设置这条策略不帮对方的业务流量进行数据转发

将AR2设备的静态路由172.16.1.0的路由引入到rip协议的时候实现过滤

  • 拓扑图:

在这里插入图片描述

  • 基础配置:
[AR1]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.12.1/24         up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)   

[AR1]rip 1
[AR1-rip-1]version 2
[AR1-rip-1]network 10.0.0.0

[AR2]display ip interface brief
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 5
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 5
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.12.2/24         up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
LoopBack0                         192.168.1.1/24       up         up(s)     
LoopBack1                         192.168.2.1/24       up         up(s)     
LoopBack2                         172.16.1.1/24        up         up(s)     
NULL0                             unassigned           up         up(s)     


[AR2]rip 1
[AR2-rip-1]version 2
[AR2-rip-1]network 10.0.0.0
[AR2-rip-1]network 192.168.1.0
[AR2-rip-1]network 192.168.2.0
[AR2-rip-1]network 172.16.0.0
  • AR2上配置策略
[AR2]acl 2000
[AR2-acl-basic-2000]rule deny source 192.168.1.0 0
[AR2-acl-basic-2000]rule permit source any 

# 配置filter-policy:不允许将192.168.1.0的路由条目通告出去
[AR2]rip 1
[AR2-rip-1]filter-policy 2000 export 
  • AR1上验证:
 [AR1]display ip routing-table 192.168.1.0

  • 192.168.2.0的路由条目不予接收,AR1设备不上无法查看也无法对这个数据进行转发

  • AR1配置规则:

[AR1]acl 2000	
[AR1-acl-basic-2000]rule deny source 192.168.2.0 0
[AR1-acl-basic-2000]rule permit source any

[AR1]rip 1
[AR1-rip-1]filter-policy 2000 import
  • 验证:
[AR1]display ip routing-table 192.168.2.0

  • 将AR2设备的静态路由192.168.3.0的路由引入到rip协议的时候实现过滤

  • AR2:

# 配置静态路由并引入到rip[AR2]ip route-static 192.168.3.0 24 NULL 0
[AR2]ip route-static 192.168.4.0 24 NULL 0

# 配置策略
[AR2]acl 2000
[AR2-acl-basic-2000]rule deny source 192.168.3.0 0 



# rip协议下调用
[AR2]rip 1
# 将原有的策略路由删除
[AR2-rip-1]undo filter-policy 2000 export 
[AR2-rip-1]filter-policy 2000 export static //调用

  • AR1:

    AR1和AR2上验证是否有3.0网段的路由

[AR1]display ip routing-table 192.168.3.0
[AR2]display rip 1 database 
 ---------------------------------------------------
 Advertisement State : [A] - Advertised
                       [I] - Not Advertised/Withdraw
 ---------------------------------------------------
   172.16.0.0/16, cost 0, ClassfulSumm
       172.16.1.0/24, cost 0, [A], Rip-interface
   192.168.1.0/24, cost 0, ClassfulSumm
   192.168.1.0/24, cost 0, [A], Rip-interface
   192.168.2.0/24, cost 0, ClassfulSumm
   192.168.2.0/24, cost 0, [A], Rip-interface

filter-policy的使用方式 :

- 对所有接口发出的路由实现过滤
- 针对链路状态路由协议无效,因为链路状态路由协议不发送路由
filter-policy 2000 export

- 对所有接口接收的路由实现过滤
- 针对链路状态路由协议,是将链路状态计算出的路由的时候实现对这个路由条目过滤,本身还是无法过滤LSA
filter-policy 2000 import

- 针对特定接口接收/发送的路由实现过滤
filter-policy 2000 import/export [interface]

- 将静态路由引入到某些特定的路由协议时实现过滤
import-route static
filter-policy 2000 export static

二、前缀列表

ACL的局限性 :

  • ACL只能抓取路由的前缀,不能匹配路由的掩码信息

    • 举例:

      有两条路由如果前缀相同,使用ACL无法实现精确过滤

  • 既能够匹配路由的前缀信息,也能够匹配路由的掩码信息.

    • 注意:

      前缀列表不能用于流量的过滤

  • 前缀列表的组成:

    1.name 名字:用于标示一条唯一的前缀列表

    2.index 索引号:与ACL的rule编号类似,匹配顺序从小到大一次匹配 (默认步长为10)

    3、permit deny 允许或者拒绝

    4、length:长度,定义网络的前缀长度

    5、greater-equal:大于等于的意思

    ​ less-equal:小于等于的意思

    注意:

    配置前缀列表需要满足Length <= Ge <= Le

实验1:

只允许192.168.1.0前缀,掩码为25或者26的路由引入到ospf中

  • 拓扑图:

在这里插入图片描述

  • AR1:
[AR1]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.12.1/24         up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)

[AR1]ospf 1 router-id 1.1.1.1
[AR1-ospf-1]area 0
[AR1-ospf-1-area-0.0.0.0]display this
[V200R003C00]
#
 area 0.0.0.0 
  network 10.0.12.0 0.0.0.255 
#
return
  • AR2:
[AR2]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.12.2/24         up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s) 

[AR2]ospf 1 router-id 2.2.2.2
[AR2-ospf-1]area 0
[AR2-ospf-1-area-0.0.0.0]display this
[V200R003C00]
#
 area 0.0.0.0 
  network 10.0.12.0 0.0.0.255 
#
return

# 添加实验所需用到的路由
[AR2]ip route-static 192.168.1.0 24 NULL 0
[AR2]ip route-static 192.168.1.0 25 NULL 0
[AR2]ip route-static 192.168.1.0 26 NULL 0
[AR2]ip route-static 192.168.1.0 28 NULL 0

# 配置前缀列表
[AR2]ip ip-prefix test permit 192.168.1.0 24 greater-equal 25 less-equal 26

# 将静态路由引入到ospf进程中,并调用前缀列表
[AR2]ospf 1
[AR2-ospf-1]import-route static
[AR2-ospf-1]filter-policy ip-prefix test export static
  • AR1上面验证:

    前缀列表默认隐含拒绝所有的语句,当路由不配任何index(索引号)的时候,将会被拒绝

[AR1]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

    192.168.1.0/25  O_ASE   150  1           D   10.0.12.2       GigabitEthernet
0/0/0
    192.168.1.0/26  O_ASE   150  1           D   10.0.12.2       GigabitEthernet
0/0/0

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0
2.1.1-前缀列表的表达式

前缀列表的表达式 :

- 匹配单条路由
ip  ip-prefix test permit 192.168.1.0 24

- 匹配前缀为192.168.1.0/24的路由条目.从25到32掩码之间的路由
- (在不设置less-equal(小于等于的前缀数值)的情况下默认匹配最大掩码)
ip ip-prefix test permit 192.168.1.0 24 greater-equal 25

- 匹配前缀为192.168.1.0/24的路由条目,从24到-32掩码之间的路由
ip ip-prefix test permit 192.168.1.0 24 less-equal 32

- 匹配前缀为192.168.1.0/24的路由条目,从26到30之间的路由
ip ip-prefix test permit 192.168.1.0 24 greate-equal 26 less-equal 30

- 匹配默认路由
ip ip-prefix test permit 0.0.0.0 0

- 匹配所有路由
ip ip-prefix test perm 0.0.0.0 0 less-equal 32

- 匹配所有的主机路由
ip ip-prefix test permit 0.0.0.0 0 greate-equal 32
  • 当前缀列表不添加Ge和Le的时候,Ge和Le等于length(路由前缀的长度)
  • 当前缀列表添加Ge,而不添加Le的时候,Le默认等于32
  • 当前缀列表添加Le,而不添加Ge的时候,Ge等于Length

匹配所有掩码等于24位的路由

ip ip-prefix 0.0.0.0 0 greater-equal 24 less-equal 24

2.1.2-使用实例
  • 配置名为p1的地址前缀列表,只允许10.0.0.0/8网段内,掩码长度在17~18之间的路由通过
[HUAWEI] ip ip-prefix p1 permit 10.0.0.0 8 greater-equal 17 less-equal 18
  • 配置名为p3的地址前缀列表,拒绝0.0.0.1 ~ 0.255.255.255范围内的所有路由通过,允许其它路由通过
[HUAWEI] ip ip-prefix p3 index 10 deny 0.0.0.0 8 match-network
[HUAWEI] ip ip-prefix p3 index 20 permit 0.0.0.0 0 less-equal 32

前缀列表的匹配规则 :

唯一匹配:

  • 当路由匹配了一个索引之后,不在向下面的索引继续匹配

顺序匹配:

  • 按照索引号的大小,从小到大依次进行匹配,如果不配置index,默认以10递增

默认拒绝:

  • 当路由不匹配任何索引之后,路由将会被拒绝
序号 命令 匹配结果 原因解释
Case1 ip ip-prefix aa index 10 permit 1.1.1.1 24 路由1.1.1.1/24 permit,其他都deny。 这种情况属于单节点的精确匹配,只有目的地址,掩码完全相同的路由才会匹配成功,而且节点的匹配模式为permit,所以路由1.1.1.1/24被permit,属于匹配成功并被permit。根据默认拒绝原则,其他路由由于未匹配成功被deny。
Case2 ip ip-prefix aa index 10 deny 1.1.1.1 24 路由全部被deny。 这种情况依然属于单节点的精确匹配,但节点的匹配模式为deny,所以路由1.1.1.1/24被deny,属于匹配成功但被deny。根据默认拒绝原则,其他路由则属于未匹配成功被默认deny。
Case3 ip ip-prefix aa index 10 permit 1.1.1.1 24 less-equal 32 路由1.1.1.1/24,1.1.1.1/32,1.1.1.1/26被permit,其他路由被deny。 这种情况依然属于单节点的精确匹配,节点的匹配模式为permit,同时定义了less-equal等于32,也就是说前缀为1.1.1.0,掩码范围在24和32之间的路由都会被permit。根据默认拒绝原则,其他路由则属于未匹配成功被默认deny。
Case4 ip ip-prefix aa index 10 permit 1.1.1.0 24 greater-equal 24 less-equal 32 路由1.1.1.1/24,1.1.1.1/32,1.1.1.1/26被permit,其他路由被deny。 这种情况依然属于单节点的精确匹配,节点的匹配模式为permit,由于greater-equal等于24,less-equal等于32,也就是说前缀为1.1.1.0,掩码范围在24和32之间的路由都会被permit,所以这种配置效果等同于Case3。根据默认拒绝原则,其他路由则属于未匹配成功被默认deny。
Case5 ip ip-prefix aa index 10 permit 1.1.1.1 24 greater-equal 26 路由1.1.1.1/32,1.1.1.1/26被permit,其他路由被deny。 这种情况依然属于单节点的精确匹配,节点的匹配模式为permit,由于greater-equal等于26,也就是说前缀为1.1.1.0,掩码范围在26和32之间的路由都会被permit。根据默认拒绝原则,其他路由则属于未匹配成功被默认deny。
Case6 ip ip-prefix aa index 10 permit 1.1.1.1 24 greater-equal 26 less-equal 32 路由1.1.1.1/32,1.1.1.1/26被permit,其他路由被deny。 这种情况依然属于单节点的精确匹配,节点的匹配模式为permit,由于greater-equal等于26,less-equal等于32,也就是说前缀为1.1.1.0,掩码范围在26和32之间的路由都会被permit,所以这种配置效果等同于Case5。根据默认拒绝原则,其他路由则属于未匹配成功被默认deny。
Case7 ip ip-prefix aa index 10 deny 1.1.1.1 24
ip ip-prefix aa index 20 permit 1.1.1.1 32
路由1.1.1.1/32被permit,其他路由都被deny。 这种情况属于多节点的精确匹配。路由1.1.1.1/24在匹配index 10时,满足匹配条件,但匹配模式是deny,根据唯一匹配原则,属于匹配成功但被deny。路由1.1.1.1/32在匹配index 10时,不满足匹配条件,然后根据顺序匹配原则,继续匹配index 20,此时匹配成功,且index 20的匹配模式是permit,属于匹配成功并被permit。根据默认拒绝原则,其他路由则属于未匹配成功被默认deny。
Case8 ip ip-prefix aa index 10 permit 0.0.0.0 8 less-equal 32 路由1.1.1.1/24、1.1.1.1/32、1.1.1.1/26、2.2.2.2/24和1.1.1.2/16都被permit。 前缀为0.0.0.0。0.0.0.0为通配地址,当前缀为0.0.0.0时,可以在其后指定掩码以及掩码范围,不论掩码指定为多少,都表示掩码长度范围内的所有路由全部被permit或deny。此时greater-equal等于8,less-equal等于32,由于0.0.0.0为通配地址,又由于节点的模式是permit,所以所有掩码长度在8到32的路由都被permit。
Case9 ip ip-prefix aa index 10 deny 0.0.0.0 24 less-equal 32
ip ip-prefix aa index 20 permit 0.0.0.0 0 less-equal 32
路由1.1.1.2/16被permit,其他路由都被deny。 对于index 10,greater-equal等于24,less-equal等于32,由于0.0.0.0为通配地址,所有掩码长度在24到32的路由全部被deny。1.1.1.2/16由于不匹配index 10,将进行index 20的匹配,对于index 20,greater-equal等于0,less-equal等于32,由于0.0.0.0为通配地址,所以1.1.1.2/16属于可以匹配上被permit。
Case10 ip ip-prefix aa index 10 deny 2.2.2.2 24
ip ip-prefix aa index 20 permit 0.0.0.0 0 less-equal 32
除路由2.2.2.2/24外的其他路由都被permit。 对于index 10,符合条件的路由2.2.2.2/24被deny。其他路由不匹配index 10,将进行index 20的匹配,由于都可以匹配上所以都被permit。

三、路由策略工具

(1)、Route- Policy

Route-Policy :

Route-policy是一种功能非常强大的路由策略工具,它可以灵活的与ACL、IP-Prefix list、As-Path-Filter等工具配合使用

  • 功能:

    ①.可以匹配路由信息,也可以对路由属性进行修改

    ②.BGP协议实施策略的主要工具

    ③.可以作为filter-policy的匹配条件

  • Router-Policy的组成部分:

    1、匹配模式:

    • permit:当路由匹配permit的节点,将会执行apply语句
    • deny:当路由匹配deny的节点,将会被拒绝,不执行apply语句

    2、节点号

    • 一个route-policy由多个节点号进行组成,每个节点叫做一个node,配置route-policy的时候必须携带节点号,执行策略的时候按照节点号大小进行,从小到大依次进行
    • 多个node之间是==逻辑“或”==的关系

    3、匹配语句

    • if-match,用于定义一些条件,满足条件即代表匹配,一个node中可以定义多个if-match语句
    • 多个if-match之间是==逻辑“与”==的关系
    • 一个node里也可以不配置if-match语句,如果不匹配,则代表匹配所有

    4、执行语句

    • apply语句,用于执行某一项动作,设备按照apply语句的动作对路由信息进行修改
    • 一个node可以存在多个apply语句,如果存在多个,则都执行修改,也可以不存在apply语句,如果不存在apply语句,只代表匹配,而不修改属性

    5、名字:用于标识唯一的一个Route-Policy

3.1.1-顺序匹配

当路由哦满足多个node的时候,按照node号从小到大一次进行匹配

匹配一个node之后,不会向下再次匹配

3.1.2-唯一匹配

当路由匹配一个node之后,不会向下再次匹配

当路由不满足任何node之后,将会被拒绝

实验1:

192.168.1.0/24 外部路由类型为type1 cost为200 tag66

192.168.2.0/24 外部路由类型为type2 cost为100 tag77

172.16.1.0/24 外部路由类型为type1 cost为300 tag为999

  • AR1:
[AR1]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.12.1/24         up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)     

[AR1]ospf 1 router-id 1.1.1.1
[AR1-ospf-1]area 0
[AR1-ospf-1-area-0.0.0.0]display this
[V200R003C00]
#
 area 0.0.0.0 
  network 10.0.12.0 0.0.0.255 
#
return
  • AR2:
[AR2]ospf 1 router-id 2.2.2.2
[AR2-ospf-1]area 0
[AR2-ospf-1-area-0.0.0.0]display this
[V200R003C00]
#
 area 0.0.0.0 
  network 10.0.12.0 0.0.0.255 
#
return

ip route-static 172.16.1.0 255.255.255.0 NULL0
ip route-static 172.16.2.0 255.255.255.0 NULL0
ip route-static 192.168.1.0 255.255.255.0 NULL0
ip route-static 192.168.2.0 255.255.255.0 NULL0
ip route-static 192.168.3.0 255.255.255.0 NULL0
ip route-static 192.168.4.0 255.255.255.0 NULL0
  • AR2:配置策略
[AR2]acl 2000
[AR2-acl-basic-2000]rule permit source 192.168.1.0 0
[AR2-acl-basic-2000]quit

[AR2]acl 2001
[AR2-acl-basic-2001]rule permit source 192.168.2.0 0
[AR2-acl-basic-2001]quit

[AR2]acl 2002 
[AR2-acl-basic-2002]rule permit source 172.16.1.0 0
[AR2-acl-basic-2002]quit

[AR2]route-policy import permit node 10
[AR2-route-policy]if-match acl 2000	
[AR2-route-policy]apply cost-type type-1
[AR2-route-policy]apply cost 200
[AR2-route-policy]apply cost 66
       
[AR2-route-policy]display this
[V200R003C00]
#
route-policy import permit node 10 
 if-match acl 2000 
 apply cost 200 
 apply cost-type type-1 
 apply tag 66 
#
route-policy import permit node 20 
 if-match acl 2001 
 apply cost 100 
 apply cost-type type-2 
 apply tag 77 
#
route-policy import permit node 30 
 if-match acl 2002 
 apply cost 300 
 apply cost-type type-1 
 apply tag 999 
#
return

# 协议下调用
[AR2]ospf 1
[AR2-ospf-1]import-route static route-policy import 
[AR2-ospf-1]quit
# 验证
[AR2]display ospf lsdb 

	 OSPF Process 1 with Router ID 2.2.2.2
		 Link State Database 

		         Area: 0.0.0.0
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    2.2.2.2         2.2.2.2             55  36    80000009       1
 Router    10.0.12.1       10.0.12.1         1451  36    80000005       1
 Network   10.0.12.1       10.0.12.1         1451  32    80000002       0
 

		 AS External Database
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 External  192.168.2.0     2.2.2.2             55  36    80000001     100
 External  192.168.1.0     2.2.2.2             55  36    80000001     200
 External  172.16.1.0      2.2.2.2             55  36    80000001     300

[AR2]display ospf lsdb ase 192.168.1.0

	 OSPF Process 1 with Router ID 2.2.2.2
		 Link State Database


  Type      : External
  Ls id     : 192.168.1.0
  Adv rtr   : 2.2.2.2  
  Ls age    : 144 
  Len       : 36 
  Options   :  E  
  seq#      : 80000001 
  chksum    : 0xe6ee
  Net mask  : 255.255.255.0 
  TOS 0  Metric: 200 
  E type    : 1
  Forwarding Address : 0.0.0.0 
  Tag       : 66 
  Priority  : Low

允许其它所有的路由引入进来

  • 一个node里也可以不配置if-match语句,如果不匹配,则代表匹配所有

  • 一个node里如果不存在apply语句,只代表匹配,而不修改属性

  • 保持默认属性:

    ospf外部路由属性

    • type 2
    • cost 1
    • tag 1
[AR2]route-policy import permit no de 400
[AR2-route-policy]quit

# 验证
[AR2]display ospf lsdb 

	 OSPF Process 1 with Router ID 2.2.2.2
		 Link State Database 

		         Area: 0.0.0.0
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    2.2.2.2         2.2.2.2            460  36    80000009       1
 Router    10.0.12.1       10.0.12.1           56  36    80000006       1
 Network   10.0.12.1       10.0.12.1           56  32    80000003       0
 

		 AS External Database
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 External  192.168.4.0     2.2.2.2            209  36    80000001       1
 External  192.168.2.0     2.2.2.2            460  36    80000001     100
 External  192.168.3.0     2.2.2.2            209  36    80000001       1
 External  192.168.1.0     2.2.2.2            460  36    80000001     200
 External  172.16.2.0      2.2.2.2            209  36    80000001       1
 External  172.16.1.0      2.2.2.2            460  36    80000001     300

[AR2]display ospf lsdb ase 172.16.2.0

	 OSPF Process 1 with Router ID 2.2.2.2
		 Link State Database


  Type      : External
  Ls id     : 172.16.2.0
  Adv rtr   : 2.2.2.2  
  Ls age    : 242 
  Len       : 36 
  Options   :  E  
  seq#      : 80000001 
  chksum    : 0x27e2
  Net mask  : 255.255.255.0 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 0.0.0.0 
  Tag       : 1 
  Priority  : Low
(2)、filter-policy
3.2.1-使用filter-policy过滤OSPF路由
实验2:
  • 拓扑图:

在这里插入图片描述

AR1:

[AR1]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 5
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 5
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.12.1/30         up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
LoopBack1                         1.1.1.1/32           up         up(s)     
LoopBack2                         192.168.2.1/24       up         up(s)     
LoopBack3                         192.168.3.1/24       up         up(s)     
NULL0                             unassigned           up         up(s)

[AR1]display current-configuration | begin ospf
ospf 1 router-id 1.1.1.1
 area 0.0.0.0 
  network 10.0.12.1 0.0.0.0 
  network 192.168.2.0 0.0.0.255 
  network 192.168.3.0 0.0.0.255 

AR2:

[AR2]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 5
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 5
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.12.2/30         up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
LoopBack1                         2.2.2.2/32           up         up(s)     
LoopBack2                         172.16.2.1/24        up         up(s)     
LoopBack3                         172.16.3.1/24        up         up(s)     
NULL0                             unassigned           up         up(s)

#  创建ACL策略:
[AR2]display acl 2000
Basic ACL 2000, 2 rules
Acl's step is 5
 rule 5 deny source 192.168.2.0 0.0.0.255 (2 matches)
 rule 10 permit (9 matches)'
 
 #  配置OSPF,并在ospf协议视图下使用filter-policy绑定acl2000.设置入站路由更新方向
[AR2]display current-configuration | begin ospf
ospf 1 router-id 2.2.2.2
 filter-policy 2000 import
 area 0.0.0.0 
  network 10.0.12.2 0.0.0.0 
  network 172.16.2.0 0.0.0.255 
  network 172.16.3.0 0.0.0.255 
  • 验证:

AR2:

[AR2]display ip routing-table 192.168.2.1

[AR2]ping 192.168.2.1
  PING 192.168.2.1: 56  data bytes, press CTRL_C to break
    Request time out
    Request time out

  --- 192.168.2.1 ping statistics ---
    2 packet(s) transmitted
    0 packet(s) received
    100.00% packet loss

四、调整网络的流量路径

  • 路由策略:

    修改路由协议的参数,通过调整路由协议的参数以及一些工具来影响路由表的表项,借此达到控制数据流量的传输路径的目的

    属于控制平面

    如:cost值

  • 策略路由:

    根据报文的特征,通过人为的干预控制数据报文从哪个接口转发出去

    不影响路由表,只影响到策略路由的所属层面 转发层面

  • 策略路由的优势:

    传统的路由转发是通过数据报文中的目的地址,查找路由表进行匹配,从而将数据转发出去。

    策略路由是通过对报文的一些特征进行匹配(源IP,目的IP、源目IP的端口,协议、源Mac等)

    指定转发策略,使报文按照管理员的预期走指定的路径,从而实现对报文转发路径的精确控制

策略路由 :

  • 本地策略路由: 针对设备自身产生的流量生效
  • 接口策略路由: 针对设备的流量生效
(1)、接口策略路由(MQC)

接口策略路由 : MQC(模块化QOS命令行)

  • 流分类: 用于匹配报文的特征,把满足特征的报文匹配出来
  • 流行为:用于指定某个指定的动作,比如修改报文转发的下一跳
  • 流策略: 用于将流分类和流行为进行管理
实验1: MQC
  • 拓扑图:

在这里插入图片描述

(1)、基础配置
  • AR1:
[AR1]display ip interface brief
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 5
The number of interface that is DOWN in Physical is 0
The number of interface that is UP in Protocol is 5
The number of interface that is DOWN in Protocol is 0

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              192.168.1.254/24     up         up        
GigabitEthernet0/0/1              192.168.2.254/24     up         up        
GigabitEthernet0/0/2              12.0.12.1/24         up         up        
GigabitEthernet1/0/0              12.0.13.1/24         up         up        
NULL0                             unassigned           up         up(s)  

[AR1]ip route-static 9.9.9.9 32 12.0.12.2
[AR1]ip route-static 9.9.9.9 32 12.0.13.3
  • AR2:
[AR2]int g0/0/0
[AR2-GigabitEthernet0/0/0]ip address 12.0.12.2 24

[AR2]int lo0
[AR2-LoopBack0]ip address 9.9.9.9 32

[AR2]ip route-static 0.0.0.0 0 12.0.13.1
[AR2]ip route-static 0.0.0.0 0 12.0.12.1
  • AR3:
[AR3]int g0/0/0	
[AR3-GigabitEthernet0/0/0]ip address 12.0.13.3 24

[AR3]int lo0
[AR3-LoopBack0]ip address 9.9.9.9 32
[AR3-LoopBack0]quit

[AR3]ip route-static 0.0.0.0 0 12.0.13.1

  • PC1上测试访问链路:

    PC1访问9.9.9.9走的是AR1的g0/0/2链路

在这里插入图片描述

  • PC2上测试访问链路:

    PC2访问9.9.9.9走的是AR1的g0/0/2链路

在这里插入图片描述

(2)、配置MQC策略路由

策略路由配置流程:

①.编写acl抓取需要的流量

②.创建classifier匹配acl

③.配置traffic behavior流行为,设置下一跳IP地址

④.创建traffic policy绑定流行为

⑤.最后在接口下调用策略路由

  • AR1:

    创建策略

# 创建流分类
[AR1]acl 2000
[AR1-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[AR1-acl-basic-2000]quit

[AR1]traffic classifier 1.0
[AR1-classifier-1.0]if-match acl 2000
[AR1-classifier-1.0]quit
                          
[AR1]acl 2001
[AR1-acl-basic-2001]rule permit source 192.168.2.0 0.0.0.255
[AR1-acl-basic-2001]quit

[AR1]traffic classifier 2.0
[AR1-classifier-2.0]if-match acl 2001
[AR1-classifier-2.0]quit
                          
# 设置流行为
[AR1]traffic behavior ar2
[AR1-behavior-ar2]redirect ip-nexthop 12.0.12.2
[AR1-behavior-ar2]quit

[AR1]traffic behavior ar3
[AR1-behavior-ar3]redirect ip-nexthop 12.0.13.3
[AR1-behavior-ar3]quit

# 配置流策略:将流行为和流分类进行绑定
[AR1]traffic policy test
[AR1-trafficpolicy-test]classifier 1.0 behavior ar2
[AR1-trafficpolicy-test]classifier 2.0 behavior ar3
[AR1-trafficpolicy-test]quit

# 入接口调用策略
[AR1]int g0/0/0
[AR1-GigabitEthernet0/0/0]traffic-policy test inbound

[AR1]int g0/0/1	
[AR1-GigabitEthernet0/0/1]traffic-policy test inbound 
(3)、验证
  • 抓包测试:

  • g0/0/2

在这里插入图片描述

  • g1/0/0

在这里插入图片描述

实验2: PBR-1

实验实现方法:

通过使用华为设备中的Policy-Based-Route工具将192.168.1.0/24网段访问9.9.9.9/32的流量重定向到AR2

192.168.2.0/24网段访问9.9.9.9/32的流量重定向到AR3

互联互通使用静态路由

  • 拓扑图:

在这里插入图片描述

(1)、基础配置
  • AR1:
[AR1]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 5
The number of interface that is DOWN in Physical is 0
The number of interface that is UP in Protocol is 5
The number of interface that is DOWN in Protocol is 0

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              192.168.1.254/24     up         up        
GigabitEthernet0/0/1              192.168.2.254/24     up         up        
GigabitEthernet0/0/2              10.0.12.1/24         up         up        
GigabitEthernet4/0/0              10.0.13.1/24         up         up        
NULL0                             unassigned           up         up(s) 

[AR1]ip route-static 0.0.0.0 0.0.0.0 10.0.12.2
[AR1]ip route-static 0.0.0.0 0.0.0.0 10.0.13.3
[AR1]ip route-static 3.3.3.3 255.255.255.255 10.0.12.2
[AR1]ip route-static 3.3.3.3 255.255.255.255 10.0.13.3
  • AR2:
[AR2]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.12.2/24         up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s) 

[AR2]ip route-static 3.3.3.3 255.255.255.255 NULL0
[AR2]ip route-static 192.168.1.0 255.255.255.0 10.0.12.1
[AR2]ip route-static 192.168.2.0 255.255.255.0 10.0.12.1
  • AR3:
[AR3]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.13.3/24         up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)  	

[AR3]ip route-static 3.3.3.3 255.255.255.255 NULL0
[AR3]ip route-static 192.168.1.0 255.255.255.0 10.0.13.1
[AR3]ip route-static 192.168.2.0 255.255.255.0 10.0.13.11
(2)、配置PBR策略路由
  • AR1:

PBR策略路由配置:

①.编写ACL,抓取对应的流量

②.创建PBR node10 node20

  • 匹配对应ACL
  • 设置执行动作,重定向下一跳IP地址
  • 绑定路由器的出接口
[AR1]display current-configuration configuration acl-adv 3000
[V200R003C00]
#
acl number 3000  
 rule 5 permit ip source 192.168.1.0 0.0.0.255 destination 3.3.3.3 0 
acl number 3001  
 rule 5 permit ip source 192.168.2.0 0.0.0.255 destination 3.3.3.3 0 
#

[AR1]display current-configuration configuration policy-based-route 
[V200R003C00]
#
policy-based-route PBR permit node 10
 if-match acl 3000
 apply output-interface GigabitEthernet0/0/2  
 apply ip-address next-hop 10.0.12.2
# 
policy-based-route PBR permit node 20
 if-match acl 3001
 apply output-interface GigabitEthernet4/0/0  
 apply ip-address next-hop 10.0.13.3  
#

[AR1]ip local policy-based-route PBR
(3)、验证

PC1和PC2分别ping 9.9.9.9

  • G0/0/2

在这里插入图片描述

  • G4/0/0

    在这里插入图片描述

实验3:PBR-2

实验目的:

PBR-1实验过于粗糙,为了模拟项目环境中的业务场景,要求公司192.168.1.0/24网段访问Internet的流量走 AR2 .

192.168.2.0/24网段访问Internet的流量走 AR3 .

为了实现上面的目的,必须对ACL策略和PBR的调度进行更精细化的处理.

  • ACL2000 ACL2001分别抓取192.168.1.0/24192.168.2.0/24的流量进行重定向下一跳
  • ACL3000则是保证两个网段内网互相通信不被重定向下一跳,从而保证内网的流量正常访问
  • 最后在PBR上分别做配置,permit node 10 permit node 20 ,其中permit node 30则是绑定内网的两个接口保证内网流量支持互访
  • 拓扑图:

在这里插入图片描述

(1)、基础配置
  • AR1:
[AR1]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 5
The number of interface that is DOWN in Physical is 0
The number of interface that is UP in Protocol is 5
The number of interface that is DOWN in Protocol is 0

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.12.1/24         up         up        
GigabitEthernet0/0/1              10.0.13.1/24         up         up        
GigabitEthernet0/0/2              192.168.1.254/24     up         up        
GigabitEthernet4/0/0              192.168.2.254/24     up         up        
NULL0                             unassigned           up         up(s) 

[AR1]ip route-static 0.0.0.0 0.0.0.0 10.0.13.3
[AR1]ip route-static 0.0.0.0 0.0.0.0 10.0.12.2
  • AR2:
[AR2]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.12.2/24         up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)  

[AR2]ip route-static 3.3.3.3 255.255.255.255 NULL0
[AR2]ip route-static 192.168.1.0 255.255.255.0 10.0.12.1
[AR2]ip route-static 192.168.2.0 255.255.255.0 10.0.12.1
  • AR3:
[AR3]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.13.3/24         up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s) 

[AR3]ip route-static 3.3.3.3 255.255.255.255 NULL0
[AR3]ip route-static 192.168.1.0 255.255.255.0 10.0.12.1
[AR3]ip route-static 192.168.2.0 255.255.255.0 10.0.12.1
(2)、配置PBR策略路由
  • AR1
[AR1]display acl all
 Total quantity of nonempty ACL number is 3 

Basic ACL 2000, 1 rule
Acl's step is 5
 rule 5 permit source 192.168.1.0 0.0.0.255 

Basic ACL 2001, 1 rule
Acl's step is 5
 rule 5 permit source 192.168.2.0 0.0.0.255 

Advanced ACL 3000, 2 rules
Acl's step is 5'
 rule 5 permit ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
 
 rule 10 permit ip source 192.168.2.0 0.0.0.255 destination 192.168.1.0 0.0.0.255 
 
 [AR1]display current-configuration configuration policy-based-route 
[V200R003C00]
#
policy-based-route PBR permit node 10
 if-match acl 2000
 apply output-interface GigabitEthernet0/0/0  
 apply ip-address next-hop 10.0.12.2  
#
policy-based-route PBR permit node 20
 if-match acl 2001
 apply output-interface GigabitEthernet0/0/1  
 apply ip-address next-hop 10.0.13.3  
#
policy-based-route PBR permit node 30
 if-match acl 3000
 apply output-interface GigabitEthernet4/0/0 GigabitEthernet0/0/2 
#
       
 [AR1]ip local policy-based-route PBR

路由策略和策略路由的区别
路由策略 策略路由
基于控制平面,会影响到路由的表项 基于转发平面,不会影响路由表表项,且设备接收到了报文后,会向查找策略路由进行匹配转发,若匹配失败,则在查找路由表转发
只能基于目的地址进程策略制定 可以基于源地址、目的地址、协议类型、报文大小等进行策略制定
与路由协议结合使用 手工逐跳配置,保证报文按策略进行转发
常用工具:
Route-Policy、Filter-Policy
常用工具:
Traffic-Filter、Traffic-Policy、Policy-Based-Route等

相关推荐

  1. 重发布策略

    2024-06-18 09:52:02       12 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-06-18 09:52:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-18 09:52:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-18 09:52:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-18 09:52:02       18 阅读

热门阅读

  1. idea git stash报错Too many revisions specified

    2024-06-18 09:52:02       7 阅读
  2. 创建单例模式的六种方式

    2024-06-18 09:52:02       8 阅读
  3. jQuery 常用函数解析

    2024-06-18 09:52:02       6 阅读
  4. MVVM模式理解(基于Qt分析)

    2024-06-18 09:52:02       5 阅读
  5. 11 类型泛化

    2024-06-18 09:52:02       6 阅读
  6. 游戏服务器要注意哪些安全事项?

    2024-06-18 09:52:02       8 阅读
  7. 【杂记-浅谈VRRP虚拟路由冗余协议】

    2024-06-18 09:52:02       6 阅读
  8. Python写一个MES系统和ERP系统协同任务流程

    2024-06-18 09:52:02       7 阅读