路由控制
知识点介绍:
使用ACL匹配感兴趣路由
使用IP-Prefix匹配感兴趣路由
使用Filter-Policy进行路由过滤
使用Route-Policy进行路由过滤及路由属性修改
路由策略和策略路由区别:
路由策略
控制路由的发布,接收和引入
IP前缀列表
Filter-Policy
Route-Policy
Route-Policy是一个策略工具,用于过滤路由信息,以及为过滤后的路由信息设置路由属性,和filter-policy的区别是可以修改属性
一个Route-Policy由一个或多个节点(Node)构成,节点内(与),节点之间(或),每个节点包括多个if-match和apply子句。
[Huawei] route-policy route-policy-name { permit | deny } node node
[Huawei-route-policy] if-match ?
[Huawei-route-policy] apply ?
策略路由
控制一些特定用户、特定业务的流量走指定的转发路径
PBR介绍
PBR(Policy-Based Routing,策略路由):基于其他元素进行数据转发,源IP地址、源MAC地址、目的MAC地址、源端口号、目的端口号、VLAN-ID等等
PBR策略的优先级高于传统路由表。
PBR分类:
接口:
本地:
调用PBR
MQC流策略
配置流策略:
流量过滤:Traffic-Filter
在流量进入设备或者离开设备的接口上执行过滤动作,双向访问的业务禁止其中一个方向即可实现阻断业务的需求
综合实验配置:
本实验模拟企业生产网与数据中心互联的网络。
该企业向ISP申请了100.0.0.0/16网段作为对外服务的公网地址。
进行子网划分后:
在企业生产网中有100.0.10.0/24和100.0.20.0/24
在北京数据中心有100.0.1.0/24
在上海数据中心有100.0.2.0/24为节约公网地址,路由器互联的网段使用私网地址192.168.x.0/24,并且不发布到ISP。
IP和网关配置省略!!
1.企业生产网运行OSPF
1.1 OSPF进程号为1,全部划入区域0
1.2 RID如下:
DC-1:192.168.100.1
DC-2:192.168.100.2
GW:192.168.100.3
SW:192.168.100.4
1.3 全部使用通配符0.0.0.0通告。
1.4 确认PC1/2可以访问DC-1/2
//配置DC的ospf的时候不需要宣告ISIS方向那边的接口
DC-1
ospf 1 router-id 192.168.100.1
area 0.0.0.0
network 192.168.1.254 0.0.0.0
#
DC-2:
ospf 1 router-id 192.168.100.2
area 0.0.0.0
network 192.168.2.254 0.0.0.0
#
GW:
ospf 1 router-id 192.168.100.3
area 0.0.0.0
network 192.168.0.254 0.0.0.0
network 192.168.1.1 0.0.0.0
network 192.168.2.1 0.0.0.0
#
SW:
ospf 1 router-id 192.168.100.4
area 0.0.0.0
network 100.0.10.254 0.0.0.0
network 100.0.20.254 0.0.0.0
network 192.168.0.1 0.0.0.0
2.数据中心运行ISIS
2.1 ISIS进程号为1.
2.2 北京数据中心区域号为49.0001,上海数据中心区域号为49.0002
ISP的区域号为49.0100
2.3 设备系统ID如下:
DC-1:0000.0001.0001
DC-1-GW:0000.0001.0254
DC-2:0000.0002.0001
DC-2-GW:0000.0002.0254
ISP:0000.0000.0100
2.4 所有ISIS路由器都是Level-2路由器
2.5 ISP上引入外部直连路由1.1.1.1/32。(无策略)
//每个路由器配置完成ISIS接口视图下后记得要在接口视图下启用ISIS enable name
DC-1:
isis 1
is-level level-2
network-entity 49.0001.0000.0001.0001.00
interface GigabitEthernet0/0/1
isis enable 1
#
DC-1-GW:
isis 1
is-level level-2
network-entity 49.0001.0000.0001.0254.00
interface GigabitEthernet0/0/0
isis enable 1
interface GigabitEthernet0/0/1
isis enable 1
interface GigabitEthernet0/0/2
isis enable 1
#
DC-2:
isis 1
is-level level-2
network-entity 49.0002.0000.0002.0001.00
interface GigabitEthernet0/0/1
isis enable 1
#
DC-2-GW:
isis 1
is-level level-2
network-entity 49.0002.0000.0002.0254.00
interface GigabitEthernet0/0/0
isis enable 1
interface GigabitEthernet0/0/1
isis enable 1
interface GigabitEthernet0/0/2
isis enable 1
#
ISP:
isis 1
is-level level-2
network-entity 49.0100.0000.0000.0100.00
import-route direct
interface GigabitEthernet0/0/0
isis enable 1
interface GigabitEthernet0/0/1
isis enable 1
3.路由引入。
3.1 在DC-1将OSPF和ISIS双向引入。
3.2 在DC-2将OSPF和ISIS双向引入
3.3 在GW查看路由,确认去往北京/上海数据中心的路由,都有DC-1和DC-2两个下一跳。
DC-1:
ospf 1 router-id 192.168.100.1
import-route isis 1
#
isis 1
import-route ospf 1
DC-2:
ospf 1 router-id 192.168.100.2
import-route isis 1
#
isis 1
import-route ospf 1
4.路由策略
为确保企业生产网去往北京数据中心优先走DC-1,去往上海数据中心优先走DC-2
在路由引入时部署以下路由策略:
4.1 使用ip-prefix匹配路由
DC-1前缀列表名称为beijing,index自动生成,匹配北京数据中心路由:192.168.3.0/24 100.0.1.0/24 11.1.1.0/24
DC-2前缀列表名称为shanghai,index自动生成,匹配上海数据中心路由:192.168.4.0/24 100.0.2.0/24 12.1.1.0/24
4.2 使用route-policy修改路由cost值,
DC-1路由策略名称为bjcost:
node 10 匹配北京数据中心路由,不修改cost;
node 100 匹配其他所有路由,修改cost为20。
DC-2路由策略名称为shcost:
node 10 匹配上海数据中心路由,不修改cost;
node 100 匹配其他所有路由,修改cost为20。
4.3 DC-1和DC-2将ISIS引入OSPF时,分别调用路由策略。
4.4 在GW确认去往北京数据中心的路由下一跳为DC-1,去往上海数据中心的路由下一跳为DC-2。
//先配置IP-Profix,获得去往两个不同方向的流量,然后使用route-policy的apply来修改去往不同方向的cost值,再在ospf视图下引入isis修改过cost值的路由
DC-1:
ip ip-prefix beijing permit 192.168.3.0 24
ip ip-prefix beijing permit 100.0.1.0 24
ip ip-prefix beijing permit 11.1.1.0 24
DC-2:
ip ip-prefix shanghai permit 192.168.4.0 24
ip ip-prefix shanghai permit 100.0.2.0 24
ip ip-prefix shanghai permit 12.1.1.0 24
#
DC-1:
route-policy bjcost permit node 10
if-match ip-prefix beijing
#
route-policy bjcost permit node 100
apply cost 20
#
DC-2:
route-policy shcost permit node 10
if-match ip-prefix shanghai
#
route-policy shcost permit node 100
apply cost 20
#
DC-1:
ospf 1
import-route isis 1 route-policy bjcost
#
DC-2:
ospf 1
import-route isis 1 route-policy shcost
5.策略路由
因生产需要,vlan10访问ISP需通过北京数据中心,vlan20访问ISP需通过上海数据中心。在GW上配置PBR,完成以下需求:
5.1 使用acl3010,规则序号5,匹配vlan10访问1.1.1.1/32的流量。
5.2 使用acl3020,规则序号5,匹配vlan20访问1.1.1.1/32的流量。
5.3 使用流分类定义感兴趣流,vlan10的流分类名称为10,vlan20的流分类名称为20.
5.4 使用流行为定义下一跳地址
去往北京数据中心DC-1的流行为名称为to1
去往上海数据中心DC-2的流行为名称为to2
5.5 使用名称为PBR的流策略绑定流分类和流行为。
5.6 在GW的接口G0/0/0上调用流策略。
5.7 在PC1和PC2上使用追踪命令确认策略路由的效果。
//使用流策略来修改vlan10和vlan20的走向,先用acl匹配流量的来源和目的地,在使用流分类匹配acl,使用流行为重定向下一跳的地址,形成流策略,再在接口入方向上使用这个流策略
acl number 3010
rule 5 permit ip source 100.0.10.0 0.0.0.255 destination 1.1.1.1 0
#
acl number 3020
rule 5 permit ip source 100.0.20.0 0.0.0.255 destination 1.1.1.1 0
#
traffic classifier 10
if-match acl 3010
traffic classifier 20
if-match acl 3020
#
traffic behavior to1
redirect ip-nexthop 192.168.1.254
traffic behavior to2
redirect ip-nexthop 192.168.2.254
#
traffic policy PBR
classifier 10 behavior to1
classifier 20 behavior to2
#
interface GigabitEthernet0/0/0
traffic-policy PBR inbound
6.ISP过滤私网路由
企业申请的公网地址为100.0.0.0/16,ISP应仅接收这个网段的路由。
考虑到企业可能进行子网划分,因此使用ip-prefix+filter-policy来过滤路由。
在ISP上部署策略,完成以下要求:
6.1 ip-prefix名称为100,index 10,允许100.0.0.0/16及所有子网。其他网段默认拒绝。
6.2 isis中使用过滤策略filter-polciy直接调用ip-prefix。
6.3 确认ISP上没有192.168.x.0/24的私网路由。
//先用IP-prefix来匹配除了需要接收的网段,其他默认deny,然后用filter-policy过滤策略来允许这个IP-prefix
ip ip-prefix 100 index 10 permit 100.0.0.0 16 greater-equal 16 less-equal 32
#
isis 1
filter-policy ip-prefix 100 import