路由过滤命令详解route-map,distribute-list, prefix-list, ip as-path access-list

合集下载

Route-map的使用方法详解

Route-map的使用方法详解

Route-mapCCNP学习笔记关于route-map的配置讨论,1.Passive-interface被动接口RIP中的被动接口是只收不发,EIGRP中的被动接口是不收不发。

配置,路由进程中,Passive-interface default 关闭所有接口No passive-interface s1/1 打开s1/1接口2.Distribute-list分发列表配置,利用ACL来抓取路由条目,Access-list 1 permit 4.4.4.0 0.0.0.255(路由条目)在路由进程中应用分发列表,Router eigrp 100Distribute-list 1 in/out 接口这个就代表只允许4.4.4.0的路由条目通过,其他路由条目不允许通过。

In后面不能跟协议,只有out后面可以跟。

Out后面不可以跟接口。

3.Prefix-list前缀列表,设计用于专抓路由,不仅可以抓网络号,还可以抓掩码。

配置,利用prefix-list来抓取路由条目,Ip prefix-list 1 permit 2.2.2.0/24(代表必须严格匹配网络号必须是2.2.2.0,掩码必须是24位的。

)在路由进程中应用prefix-list,Router eigrp 100Distribute-list prefix 1 out 接口Prefix-list的其他写法:Ip prefix-list 1 permit 2.2.2.0/24 (匹配前24位:2.2.2.*,掩码必须为24位)Ip prefix-list 1 permit 2.2.2.0/24 le 32 (匹配前24位:2.2.2.*,掩码必须为24—32位)Ip prefix-list 1 permit 2.2.2.0/24 ge 26 (匹配前24位:2.2.2.*,掩码必须为26---32位)Ip prefix-list 1 permit 2.2.2.0/24 ge 25 le 30 (匹配前24位:2.2.2.*,掩码必须为25---32位)Ip prefix-list 1 permit 0.0.0.0/0 le 32 (匹配所有,不可以写any)Show ip prefix-list可以用查看。

route-map的原理及简单应用

route-map的原理及简单应用

route-map的原理及简单应⽤Route-map什么是route-map,怎么说呢?你说它属于什么呢?属于路由策略?还是属于策略路由?其实都不算,我个⼈理解,它只算是⼀个⼯具,上⾯两者都能⽤到但是这个⼯具吧,⽤着还挺爽,所涉及到的范围还挺多的呢?~IGP协议,BGP协议,....Distribute,redistribute,等等,都能看到它的⾝影初识route-map1、Route-map中的语句相当于acl的各⾏2、route-map的序列号默认为10,不会⾃动递增,所以需要⼿动的写序号3、route-map的⾏为默认是permit4、match——匹配条件,set——执⾏动作在match语句中,会有不同的表现形式1 match X1,X2,写在⼀⾏,⽤,隔开时,是逻辑上的“或”关系2 match X1Match X2 写在两⾏时,⽤回车隔开,是逻辑上的“且”关系“或”“且”想必不⽤多说了,很好理解,或,多个条件满⾜⼀个则OK且,就是都得满⾜.Route-map的运⾏⽅式PS:在route-map中,和ACL是⼀样的,最后都有⼀条deny 的动作,所以,我们在部署route-map时,也要分情况的来配置⼀条permit当然,是分情况哦~什么情况呢?⽐如说你在做路由重分布时,只想提取某些条⽬,那势必要拒绝其它的⽽如果在后期的BGP中,针对某些条⽬去施加特定属性时,就要去话茬其它没有被策略的,以保证路由条⽬的正常传递,这⼀点在后期的各个⼩实验中会有明显的体现,先要清楚这个事⼉~实例1如图所⽰,R1-R2运⾏RIP,R2-R3运⾏OSPF,在R2上进⾏双向重发布,可以先来分析⼀下,OSPF重分布到RIP ,需要写跳数,那请问这两个条⽬到达R1时的跳数是否⼀致?RIP进到OSPF时,可以去修改metric-type,R3上看到的类型是否⼀致?答案是肯定的,因为在重分布的时候并没有进⾏任何的修改,况且单独的重分布也没有办法进⾏设置。

BGP 路由表利用distribute-list列表过滤路由

BGP 路由表利用distribute-list列表过滤路由

利用distribute-list列表过滤路由实验目的:1:熟练配置路由重分发2:利用distribute­list过滤相应的路由1:具体配置R1!EnableConf thostname Londonno ip domain­lookline cons0no exec­timelogg sync!interface Loopback0ip address172.16.1.1255.255.255.0!interface Loopback1ip address172.16.2.1255.255.255.0!interface Loopback2ip address172.16.3.1255.255.255.0!interface Loopback3ip address172.16.4.1255.255.255.0!interface Loopback4ip address172.16.5.1255.255.255.0!interface Loopback5ip address172.16.6.1255.255.255.0!interface Loopback6ip address172.16.7.1255.255.255.0!interface Loopback7ip address172.16.8.1255.255.255.0!Interface loopback8Ip add1.1.1.1255.255.255.255!interface Serial1ip address10.1.1.1255.255.255.252no sh!router ospf1router­id1.1.1.1network0.0.0.0255.255.255.255area0!end按要求配置该路由器的各个接口,并启用ospf,最后把所有网络宣告进ospf中,且属于area0。

路由过滤命令详解route-map,distribute-list, prefix-list, ip as-path access-list

路由过滤命令详解route-map,distribute-list, prefix-list, ip as-path access-list

! interfaceSerial1 ipaddress10.34.16.83.255.255.255.252 ip policy route-map sense ! access-list1permit172.16.0.0 0.0.255.255 access-list110permittcp any eq www any ! route-map sense permit10 matchipaddress1 110 set ip precedence critical ! route-mapsensepermit20 setiptos2 //正对所有上面 route-map 语句不匹配的其他流量
<1> Standard ACL interfaceSerial0 ipaddress172.16.5.1255.255.255.0 ippolicyroute-mapsense ! access-list1permit172.16.6.00.0.0.255 access-list2permit172.16.7.00.0.0.255 ! route-mapsensepermit10 matchipaddress1 setipnext-hop172.16.4.2 ! route-mapsensepermit20 matchipaddress2
matchipaddress120 ! route-mapsensepermit20 matchlength10001600 setipnext-hop172.16.2.1 ! route-mapsensepermit30 matchlength0400 setipnext-hop172.16.3.1 注:如果没有第一个 route-map 条目,router 本身的 Packets 及 OSPF 的 Packets 都会由于后两个 route-map 语句被转发到错误的地址。 Case Study: Policy Routing and Quality of Service Routing PolicyRouting 结合 ip 包头的 Precedence 和 Type of Service(TOS)可以实现基 于 QOS 的策略路由。 注:Precedence 和 TOS 的配置既可使用 Number 字段,也可以使用 Keyword. 针对 IP 包头中的 TOS 字段(8bit)(如下图),根据 RFC1349 的规定,第 0,1,2 三 bit 作为 ip precedence 使用,而第 3,4,5,6 四个字段作为 Type of Service(ToS) 使用.

策略路由配置命令

策略路由配置命令

一、基于distribute的路由过滤1.定义acl (conf)#access-list 1 deny 192.168.1.0 0.0.0.255(conf)#access-list 1 permit any2.进入路由重发布(conf)#router rip (conf-router)#distribute-list 1 out ospf 1 在rip协议下,配置distribute 列表,引用acl 1,过滤从ospf 1重发布到rip的网络路由。

也就是说,通过该路由器进行ospf的重发布到rip网络中,过滤acl 1的数据。

在该例中的意思就是ospf中如果有数据属于192.168.1.0/24,那么在rip 网络中无法学习到这些路由。

由于重发布的命令是redistribute,所以这里可以理解为发布到rip网络中。

=============================================================================== ============================================二、基于route-map的路由过滤 1.定义acl (conf)#access-list 1 deny 192.168.1.0 0.0.0.255(conf)#access-list 1 permit any2.定义route-map (conf)# route-map ospf-rip permit 10 其中ospf-rip为route-map的名称,10为序列号,下述条件如果成立的话动作为permit。

注意:route-map和acl相同的是,在尾部都有隐藏的默认拒绝所有的条件。

3.匹配条件(config-route-map)#match ip address 1 查询acl 1是否满足4.进入路由重发布(conf)#router rip (conf-router)#redistribute ospf 1 metric 4 route-map ospf-rip 在路由重发布的时候,对route-map的ospf-rip条目进行匹配过滤。

路由协议重分布acl prefix-list route-map

路由协议重分布acl prefix-list route-map

路由协议重分布acl prefix-list route-map路由协议的迁移,路由协议的重分布,单点双向重分布时的汇总路由回馈问题,双向双出口重分布,ACL,distribute-list,prefix-list,route-map,作者:许洪铭<路由协议的迁移>当网络中原有的路由协议不能再很好的满足需求的时候,就需要转换为另一种路由协议,这就需要进行路由协议的迁移。

原则:1、尽可能少的减少网络的停工时间2、一旦在迁移过程中出了问题,要能迅速回退到初始状态3、在迁移过程中要避免出现路由黑洞和环路在路由迁移过程中还有可能要改变原有的IP地址,使用新的编址方案,这就需要进行地址的迁移。

地址迁移过程:1、配置第二地址2、将第二地址network进路由协议中3、如果第二地址路由正常,将第二地址改为第一地址R1(config-is)#ip address address mask secondary 配置辅助地址需要将辅助地址升级为主地址时,直接将辅助地址在接口配置即可(不要加secondary)他会自动冲掉主地址和辅助地址。

路由迁移过程:1、将原有协议的AD值改小2、在现在网络上配置新的路由协议3、将原有协议的AD值再改大,让新协议的路由起作用,修改过程中两个协议并存不影响正常工作。

4、如果路由正常,删除原有协议,必需要经过一段时间的测试之后才能进行删除。

R1(config-route)#distance eigrp 150 170 修改EIGRP路由协议的内部管理距离和外部管理距离(默认为170)注:OSPF不能用Secondary地址建邻居。

Eigrp能用Secondary地址建邻居。

割接就是对网络的软件硬件进行升级<路由协议的重分布>定义:重分布是指连接到不同路由选择域的边界路由器在不同自主系统之间交换和通告路由选择信息的能力。

重分布原则:路由必须位于路由选择表中才能被重分发在重分发时设定种子metric协议 Seed MetricRIP 无限大即任何路由协议重分布进RIP时,默认的METRIC都是无穷大的,不可以使用,所以必须手工指定EIGRP 无限大也必须手工指定OSPF 20 如果重分布进来的是BGP的话,Metric是1,这是个特例IS-IS 0 可以不用手工指定,即可正常传递。

路由过滤命令详解

路由过滤命令详解

路由过滤命令详解(一) Route Maps特性:Route Maps类似于access lists,不同之处在于Route Maps可以改变Packets/Routes的部分属性。

用途:Route Maps主要用于Redistribution和Policy Routing及BGP的实现。

实现:Policy Routing发送Packets到Route Maps实现策略路由转发。

Redistribution发送Routes到Route Maps实现路由条目的过滤。

配置说明:Route Maps如果没有指定Action及Sequence Number属性,默认:Action: permitSequence Number: 10且Sequence Number不会自动增加。

即如果在使用Route Maps语句时不指定Sequence Number,则覆盖Sequence Number为10的默认条目。

Route Maps Deny Action:Redistribution:特定路由条目不会被重分布。

Policy Routing:特定的Packets不会按策略路由转发,但会梗概正常的路由表条目转发。

Case Study:Policy Routing注:(1)Policy Routing只影响入流量。

(2)可以使用Standard及Extended ACL.(3)全局配置ip local policy route-map sense可将策略路由应用于Router 本身发送的Packets.<1> Standard ACLinterface Serial 0ip address 172.16.5.1 255.255.255.0ip policy route-map sense!access-list 1 permit 172.16.6.0 0.0.0.255access-list 2 permit 172.16.7.0 0.0.0.255!route-map sense permit 10match ip address 1set ip next-hop 172.16.4.2!route-map sense permit 20match ip address 2set ip next-hop 172.16.4.3<2> Extended ACLinterface Ethernet 0ip address 172.16.1.4 255.255.255.0ip policy route-map sense!access-list 105 permit tcp 172.16.1.0 0.0.0.255 eq ftp anyaccess-list 105 permit tcp 172.16.1.0 0.0.0.255 eqftp-data anyaccess-list 106 permit tcp 172.16.1.0 0.0.0.255 eq telnetany!route-map sense permit 10match ip address 105set ip next-hop 172.16.2.1!route-map sense permit 20match ip address 106set ip next-hop 172.16.3.1<3> Length of the Packetsip policy route-map sense!route-map sense permit 10match length 1000 1600set ip next-hop 172.16.2.1!route-map sense permit 20match length 0 400set ip next-hop 172.16.3.1<4> Router's Packetsinterface Ethernet0ip address 172.16.1.4 255.255.255.0ip policy route-map sense!ip local policy route-map sense!access-list 120 permit ip any 172.16.1.0 0.0.0.255access-list 120 permit ospf any any!route-map sense permit 10match ip address 120!route-map sense permit 20match length 1000 1600set ip next-hop 172.16.2.1!route-map sense permit 30match length 0 400set ip next-hop 172.16.3.1注:如果没有第一个route-map条目,router本身的Packets及OSPF的Packets都会由于后两个route-map语句被转发到错误的地址。

route命令详解与使用实例

route命令详解与使用实例

route命令详解与使⽤实例1. 使⽤背景需要接⼊两个⽹络,⼀个是部署环境所在内⽹环境,这个环境是上不了外⽹,外⽹环境很可能是⼀个⽆线⽹络。

如果两者都连接上,很可能导致有⼀⽅不能起作⽤,即外⽹或内⽹上不了,常常需要使⽤繁琐的“禁⽤⽹络连接”、“启⽤⽹络连接”的操作来进⾏内外⽹的切换,甚是⿇烦。

为了解决这个问题,可以使⽤route命令来使得同时内外⽹都可⽤。

2. route命令route命令是在本地 IP 路由表中显⽰和修改条⽬⽹络命令。

route命令的语法如下:route [-f] [-p] [Command [Destination] [mask Netmask] [Gateway] [metric Metric]] [if Interface]]route命令常⽤的命令如下:1)route delete:删除路由;2)route print:打印路由的Destination;3)route add:添加路由;4)route change:更改现存路由。

⼀般使⽤route delete、route add、route print这三条命令可解决路由的所有功能。

2.1 打印路由信息打印路由信息使⽤命令:route print。

===========================================================================Interface List0x1 MS TCP Loopback interface0x2 00 26 18 31 4f d1 Realtek RTL8168C(P)/8111C(P) PCI-E Gigabit Ethernet NIC - 数据包计划程序微型端⼝0x50004 00 53 45 00 00 00 WAN (PPP/SLIP) Interface======================================================================================================================================================Active Routes:Network Destination Netmask Gateway Interface Metric0.0.0.0 0.0.0.0 116.69.106.119 116.69.106.119 10.0.0.0 0.0.0.0 192.168.2.226 192.168.2.79 20115.168.64.94 255.255.255.255 116.69.106.119 116.69.106.119 1116.69.106.119 255.255.255.255 127.0.0.1 127.0.0.1 50116.255.255.255 255.255.255.255 116.69.106.119 116.69.106.119 50127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1192.168.2.0 255.255.255.0 192.168.2.79 192.168.2.79 20192.168.2.79 255.255.255.255 127.0.0.1 127.0.0.1 20192.168.2.255 255.255.255.255 192.168.2.79 192.168.2.79 20224.0.0.0 240.0.0.0 192.168.2.79 192.168.2.79 20224.0.0.0 240.0.0.0 116.69.106.119 116.69.106.119 1255.255.255.255 255.255.255.255 116.69.106.119 116.69.106.119 1255.255.255.255 255.255.255.255 192.168.2.79 192.168.2.79 1Default Gateway: 116.69.106.119===========================================================================Persistent Routes:None第⼀列是⽹络⽬的地址。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

matchipaddress120 ! route-mapsensepermit20 matchlength10001600 setipnext-hop172.16.2.1 ! route-mapsensepermit30 matchlength0400 setipnext-hop172.16.3.1 注:如果没有第一个 route-map 条目,router 本身的 Packets 及 OSPF 的 Packets 都会由于后两个 route-map 语句被转发到错误的地址。 Case Study: Policy Routing and Quality of Service Routing PolicyRouting 结合 ip 包头的 Precedence 和 Type of Service(TOS)可以实现基 于 QOS 的策略路由。 注:Precedence 和 TOS 的配置既可使用 Number 字段,也可以使用 Keyword. 针对 IP 包头中的 TOS 字段(8bit)(如下图),根据 RFC1349 的规定,第 0,1,2 三 bit 作为 ip precedence 使用,而第 3,4,5,6 四个字段作为 Type of Service(ToS) 使用.
set ip precedence ------------------------------------- Bits Number Keyword 000 0 routine 001 1 priority 010 2 immediate 011 3 flash 100 4 flash-override 101 5 critical 110 6 internet 111 7 network
Redistribution: 特定路由条目不会被重分布。 PolicyRouting: 特定的 Packets 不会按策略路由转发,但会梗概正常的路由表 条目转发。
Case Study:Policy Routing 注:(1)PolicyRouting 只影响入流量。 (2)可以使用 Standard 及 ExtendedACL. (3)全局配置 iplocalpolicyroute-mapsense 可将策略路由应用于 Router 本身 发送的 Packets.
ippolicyroute-mapsense ! route-mapsensepermit10 matchlength10001600 setipnext-hop172.16.2.1 ! route-mapsensepermit20 matchlength0400 setipnext-hop172.16.3.1 <4> Router's Packets inte72.16.4.3 <2> Extended ACL interfaceEthernet0 ipaddress172.16.1.4255.255.255.0 ippolicyroute-mapsense ! access-list105permittcp172.16.1.00.0.0.255eqftpany access-list105permittcp172.16.1.00.0.0.255eqftp-dataany access-list106permittcp172.16.1.00.0.0.255eqtelnetany ! route-mapsensepermit10 matchipaddress105 setipnext-hop172.16.2.1 ! route-mapsensepermit20 matchipaddress106 setipnext-hop172.16.3.1 <3> Length of the Packets interfaceEthernet0 ipaddress172.16.1.4255.255.255.0
! interfaceSerial1 ipaddress10.34.16.83.255.255.255.252 ip policy route-map sense ! access-list1permit172.16.0.0 0.0.255.255 access-list110permittcp any eq www any ! route-map sense permit10 matchipaddress1 110 set ip precedence critical ! route-mapsensepermit20 setiptos2 //正对所有上面 route-map 语句不匹配的其他流量
Route Maps 主要用于 Redistribution 和 Policy Routing 及 BGP 协议。 实现: Policy Routing(策略路由 PBR)发送 Packets(数据包)到 Route Maps,实 现策略路由转发。 Redistribution(路由重分布)发送 Routes(路由条目)到 RouteMaps,实现 路由条目的过滤。 配置说明: RouteMaps 如果没有指定 Action 及 SequenceNumber 属性,默认: Action: permit SequenceNumber: 10 且 SequenceNumber 不会自动增加。 即如果在使用 RouteMaps 语句时不指定 SequenceNumber,则覆盖 Sequence Number 为 10 的默认条目。 Route Maps 的 Deny Action:
ipaddress172.16.1.4255.255.255.0 ippolicyroute-mapsense ! ip local policy route-map sense //全局下对本地产生的 packets 调用
route-map sense ! access-list120permitipany172.16.1.00.0.0.255 access-list120permitospfanyany ! route-mapsensepermit10
路由过滤命令详解:route-map、distribute-list、 prefix-list、ip as-path access-list 以及 filter-list
(一) Route Maps 特性:
Route Maps 类似于 access lists,不同之处在于 Route Maps 可以改变 Packets/Routes 的部分属性。 用途:
setiptos2(Set max reliable ToS)和 setip precedence priority
setipprecedence priority
Case Study: Route Tagging
<1> Standard ACL interfaceSerial0 ipaddress172.16.5.1255.255.255.0 ippolicyroute-mapsense ! access-list1permit172.16.6.00.0.0.255 access-list2permit172.16.7.00.0.0.255 ! route-mapsensepermit10 matchipaddress1 setipnext-hop172.16.4.2 ! route-mapsensepermit20 matchipaddress2
------------------------------------- set ip tos
------------------------------------- Bits Number Keyword 0000 0 normal 0001 1 min-monetary-cost 0010 2 max-reliability 0100 4 max-throughput 1000 8 min-delay 如上所示,从高位到低位依次置 1 所代表的含义是:正常服务、低花费(开销)、 高可靠性、高吞吐量,低延迟。要注意的是这四个 bit 只能同时置 1 个位,不能同时 置两个或多个位为 1。 ------------------------------------- interfaceSerial0 ipaddress10.1.18.67255.255.255.252 ip policy route-map sense
相关文档
最新文档