prefix-list与route-map的比较.doc_第1页
prefix-list与route-map的比较.doc_第2页
prefix-list与route-map的比较.doc_第3页
prefix-list与route-map的比较.doc_第4页
prefix-list与route-map的比较.doc_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

IP prefix-list及與ACL, route-map的比較Cisco 2011-03-12 23:07:43 阅读6 评论1 字号:大中小订阅 下面是一條標準的prefix-list, 我們對其進行分析:ip prefix-list 100 permit 128.0.0.0/2 ge 16 le 24ge=greater or equal le=less or equal1、 R1(config)#ip prefix-list ? WORD Name of a prefix list sequence-number Include/exclude sequence numbers in NVGENR1(config)#ip prefix-list 100 ? deny Specify packets to reject description Prefix-list specific descriptin permit Specify packets to forward seq sequence number of an entry基本的格式上和ACL還是差不多的。2、關鍵的對於128.0.0.0/2的這個/2代表了什麼含義? 128.0.0.0 換成2進制數為10 000000 00000000 00000000 00000000/2代表只對前面的2位必須match,即,前2位是不變的,在不帶ge 16 le 24的情況下,prefix-list裏的128.0.0.0/2 代表的是一個範圍,是從128.0.0.0/7到191.255.255.252/30,而加上ge 16 le 24 的意思就是ip地址mask從 /16到/24下面是幾個例: prefix-list 100 permit 0.0.0.0/0 代表的是所有路由prefix-list 100 permit 0.0.0.0/32 代表的是預設路由prefix-list 100 permit 0.0.0.0/0 ge 32代表的是所有host路由3、在ACL裏,128.0.0.0/2是什麼含義? 下面是128.0.0.0的2進表達表示 10 000000 00000000 00000000 00000000在ACL裏,permit 128.0.0.0/2,那就沒意義了,要使用128.0.0.0,最小的mask位數為7位(2的7次是128)4、其實ACL也有方法定義一個範圍,以實現類似prefix-list的功能。 access-list 10 permit 199.172.0.0 0.0.3.0,這裏這個0.0.3.0,即起了一個定義範圍的作用,0表示match,1表示不關心。這樣的話,199.172.0.0 這個被定義物裏,前16個bit和最後8個bit都是被定死的,唯獨第三段的最後2bit是不關心的,可以變換,所以結果就是:199.172.0.0199.172.1.0 199.172.2.0199.172.3.0per 199.172.1.0 0.0.254.0 奇數路由per 199.172.0.0 0.0.254.0 偶數路由A bit mask used in access rules, IPSec rules, and NAT rules to specify which portions of the packets IP address must match the IP address in the rule 例: 1.1.1.1/8 ge 16 le 32/8表示必須從參考的IP中匹配前8個2進位,因此所匹配的路由是1開頭實際匹配的是00000001,剛好8位。 但是後頭定義的是路由首碼的範圍,意義是,如果有路由是1.1.1.0/8 那這樣的情況是不符合定義的,因為他的首碼 是8,而不是大於16 小於32 的範圍。所以它不能通過, 那1.1.1.0/9呢?一樣也不是範圍內的,那1.1.1.0/17呢?這條路由可以pass理由是他的首碼大於了16,小於32,那2.2.2.0/17呢?這樣的情況雖然首碼符合了定義,但是路由是2.x.x.x,不符合參考IP前8個2進位必須為00000001,即等於1.x.x.x,因此總結:首碼列表由2個部分組成,一個是參考的IP,一個是匹配的 mask,比如你要想匹配住2.x.x.x, 那我們只需要寫1.1.1.0/6 ge 7 le 32這樣的話,就是匹配了,參考IP 1.1.1.0中的前6個2, 即是: 00000001中的000000xx.x.x 即可以是00000000,00000001,00000002,00000003開頭的IP路由。再來就是首碼範圍,這次的首碼範圍也變大了,是大於7。很多路由都會被匹配,如2.2.2.2/8 這個路由也會PASS了。在進行路由過濾和位址限制方面,Prefix-list佔用CPU的資源比採用access-list要少很多, 它提供更快的訪問列表裝入速度,目前IOS版本11.1CC(17),11.3(3)和12.0都提供該項特性。 Prefix-list保存了access-list的多項重要特性: 1、Permit和Deny; 2、最先匹配法則; 3、基於Prefix長度的過濾(精確匹配或range匹配) 然而,與Route-map搭配使用的Prefix-list不支援包過濾。 Sequence Number 用於內部正確標識“真正”的match(以最小的Sequence Num為准)。 解釋如下:1、Prefix-list可以採用增量方式從新定義,也就是說,它裏面的條目可以單獨增加或刪除,而無需像access-list一樣,一刪就得將整個access-list刪掉重寫。2、To_DCC_Routes 是這個prefix-list增量表的名字。3、Seq 10用於內部正確標識“真正”的match(以最小的Sequence Num為准)。 4、Match的工作原理與Access-list十分類似。空的Prefix-list允許所有的首碼; 當Prefix-list中的任何一條都不滿足的話,就認為隱含拒絕; 當Prefix-list中的多項條目均滿足時,以最小的Sequence Num的那條作為匹配。 這裏有一個例子,如果有以下這樣的Prefix-list: ip prefix-list abc deny 10.0.0.0/8 le 32 ip prefix-list abc permit 0.0.0.0/0 le 32則10.1.0.0/16滿足上述兩條,但該Prefix會被拒絕,因為第一條才是真正的匹配。ACL , prefix , route-map共同特點:1 一個空的/不存在 的acl & prefix預設是permit all ,一個不存在 的 route-map 預設是deny all 2 一個acl 如果配置一條以上permit或deny語句,最後一筆為隱藏的deny all3 route-map預設deny all(即使為空) - 以下為各種例子,以如下的網路架構為網路環境:R1 (s1/0,192.168.1.1) = (s1/0,192.168.1.2) R2Case Study: ACLR1#conf tR1(config)#line vty 0 4R1(config-line)#password ciscoR1(config-line)#loginR1(config-line)#access-class 3 inR2#telnet 192.168.1.1 Password :R1 沒有阻擋可以直接進去Summary: 空的(未定義的)acl預設允許所有的主機。-Case Study: Route-mapR1(config)#router ospf 100R1(config-router)#default-information originate route-map senseR1(config-router)#exitR2#sh ip routeGateway of last resort is not set 172.16.0.0/24 is subnetted, 2 subnetsO 172.16.1.0 110/65 via 192.168.1.1, 00:32:38, Serial1/0C 172.16.2.0 is directly connected, Loopback0 192.168.1.0/30 is subnetted, 1 subnetsC 192.168.1.0 is directly connected, Serial1/0註: 不存在的route-map預設deny all。所以這個case的route-map永遠返回不滿足要求。-R1(config)#router ospf 100R1(config-router)#default-information originate route-map senseR1(config-router)#exitR1(config)#route-map sense permit 10R2#sh ip routeGateway of last resort is 192.168.1.6 to network 0.0.0.0 172.16.0.0/24 is subnetted, 2 subnetsO 172.16.1.0 110/65 via 192.168.1.1, 00:32:38, Serial1/0C 172.16.2.0 is directly connected, Loopback0 192.168.1.0/30 is subnetted, 1 subnetsC 192.168.1.0 is directly connected, Serial1/0O*E2 0.0.0.0/0 110/1 via 192.168.1.6, 00:00:12, Serial1/1-R1(config)#router ospf 100R1(config-router)#default-information originate route-map senseR1(config-router)#exitR1(config)#route-map sense permit 10R1(config-route-map)#match ip add 1R2#sh ip routeGateway of last resort is not set 172.16.0.0/24 is subnetted, 2 subnetsO 172.16.1.0 110/65 via 192.168.1.1, 00:32:38, Serial1/0C 172.16.2.0 is directly connected, Loopback0 192.168.1.0/30 is subnetted, 1 subnetsC 192.168.1.0 is directly connected, Serial1/0-R1(config)#router ospf 100R1(config-router)#default-information originate route-map senseR1(config-router)#exitR1(config)#route-map sense deny 10R2#sh ip routeGateway of last resort is 192.168.1.6 to network 0.0.0.0 172.16.0.0/24 is subnetted, 2 subnetsO 172.16.1.0 110/65 via 192.168.1.1, 00:32:38, Serial1/0C 172.16.2.0 is directly connected, Loopback0 192.168.1.0/30 is subnetted, 1 subnetsC 192.168.1.0 is directly connected, Serial1/0O*E2 0.0.0.0/0 110/1 via 192.168.1.6, 00:00:12, Serial1/1-R1(config)#router ospf 100R1(config-router)#default-information originate route-map senseR1(config-router)#exitR1(config)#route-map sense deny 10R1(config-route-map)#match ip add 1R2#sh ip routeGateway of last resort is not set 172.16.0.0/24 is subnetted, 2 subnetsO 172.16.1.0 110/65 via 192.168.1.1, 00:32:38, Serial1/0C 172.16.2.0 is directly connected, Loopback0 192.168.1.0/30 is subnetted, 1 subnetsC 192.168.1.0 is directly connected, Serial1/0-Case Study: Prefix-listR1(config)#int lo0R1(config-if)#ip add 172.16.33.1 255.255.255.0R1(config-if)#no shutR1(config-if)#ip ospf network point-to-pointR1(config-if)#exitR1(config)#router ospf 100R1(config-router)#redistribute connected subnetsR1(config-router)#distribute-list prefix sense out connectedR1(config)#R2#sh ip routeGateway of last resort is not set 172.16.0.0/24 is subnetted, 4 subnetsO 172.16.44.0 33/65 via 192.168.1.1, 00:07:54, Serial1/0O E2 172.16.33.0 55/20 via 192.168.1.1, 00:00:01, Serial1/0O IA 172.16.1.0 44/65 via 192.168.1.1, 00:07:54, Serial1/0C 172.16.2.0 is directly connected, Loopback0 192.168.1.0/30 is subnetted, 1 subnetsC 192.168.1.0 is directly connected, Serial1/0R1(config)#ip prefix-list sense seq 5 deny 172.16.33.0/24 rtb#sh ip routeGateway of last resort is not set 172.16.0.0/24 is subnetted, 3 subnetsO 172.16.44.0 33/65 via 192.168.1.1, 00:09:15, Serial1/0O IA 172.16.1.0 44/65 via 192.168.1.1, 00:09:15, Serial1/0C 172.16.2.0 is directly connected, Loopback0 192.168.1.0/30 is subnetted, 1 subnetsC 192.168.1.0 is directly connected, Serial1/0Summary: 空的prefix-list預設允許所有的路由。-Case Study: Integrate Route-map and ACLR1(config)#router ospf 100R1(config-router)#default-information originate route-map senseR1(config-router)#exitR1(config)#route-map sense deny 5R1(config-route-map)#match ip address 33R1(config-route-map)#R2#sh ip route Gateway of last resort is not set 172.16.0.0/24 is subnetted, 2 subnetsO 172.16.1.0 110/65 via 192.168.1.1, 00:32:38, Serial1/0C 172.16.2.0 is directly connected, Loopback0 192.168.1.0/30 is subnetted, 1 subnetsC 192.168.1.0 is directly connected, Serial1/0Summary: 至少定義一條permit或deny語句才能使用acl或route-map的隱含deny功能。空的acl預設允所有的路由。我们无论在实际应用,还是CCIE实验中,路由重分发、路由过滤一向会是一个难点,现把几点需要注意的地方总结如下:一、路由过滤的方法:(三种)1、distribute-list2、route-map3、summary下面分别简单举例,只允许10.10.0.0/16条目进入路由表1、distribute-listip prefix-list cracker permit 10.10.0.0/16router eigrp 10 distribute-list prefix-list cracker in s0/02、route-mapip prefix-list cracker permit 10.10.0.0/16route-map crackerpermit 10 match ip address prefix-list crackerrouter ospf 10 redis eigrp 10 metric 100 subnets route-map cracker3、summary有时我们可以用summary来汇总路由,并且由于汇总对精细路由条目抑制的本能,我们相当于又多加了一条过滤语句。int s0/0 ip summary-address eigrp 10 10.10.0.0 255.255.0.0从s0/0发出的路由将在汇总的同时被过滤。二、路由过滤路由过滤仅对Distance-vector 路由协议有效,OSPF这类link-status协议无视路由过滤,当然除非我们在路由进程下去做。这也是我们为什么经常在其它路由协议向OSPF重分发时,看不到路由过滤语句distribute-list存在的原因。但这不代表使用route-map的方法不可以。下面我们分两种情况讨论1、EIGRP RIP 这两种路由协议,无论你在in out方向均可做,不用过多考虑,直接distribute-list上。例:禁止10.10.0.0/16汇总路由进入EIGRP/RIProuter rip distribute-list prefix-list cracker in s0/0ip prefix-list cracker deny 10.10.0.0/16ip prefix-list cracker permit 0.0.0.0/0 le 32router eigrp 10 distribute-list prefix-list cracker in s0/02、OSPF 路由过滤例:禁止10.10.0.0/16汇总路由进入OSPFrouter os 10 redis eigrp 10 metric 100 subnets route-map crackerip prefix-list cracker permit 10.10.0

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论