BGP-community应用配置实例
BGP实验手册

实验十、BGP实验实验要求:1、掌握BGP的基本配置方法。
2、掌握如何查看BGP的各种配置信息。
3、掌握基于回环口的BGP的邻居关系建立的配置方法。
4、理解需要使用回环口为目的。
5、理解BGP同步功能的作用和配置。
6、掌握使用指向NULL0接口的静态路由的汇总配置方法。
7、掌握使用聚合属性的路由汇总配置方法。
实验拓扑:根据实验要求,实验拓扑如图10-1所示。
图10-1 BGP实验拓扑注:R1和R2属于自治系统65001,R3属于自治系统65002实验步骤:1、根据实验拓扑,对路由器各接口配置IP地址,使直连链路相互间可以进行通信。
2、在R1和R2上配置EIGRP,关闭自动汇总。
参考命令如下:R1(config)#router eigrp 50 50修改为自己学号后两位R1(config-router)#network 192.168.1.0R1(config-router)#network 1.0.0.0R1(config-router)#no auto-summaryR2(config)#router eigrp 50 50修改为自己学号后两位R2(config-router)#network 192.168.1.0R2(config-router)#network 2.0.0.0R2(config-router)#no auto-summary3、首先在R1和R2配置BGP协议,使用回环口创建邻居关系,参考命令如下:R1(config)#router bgp 65001 65001修改为65000+自己学号后两位R1(config-router)#neighbor 2.2.2.2 remote-as 65001 65001修改为65000+自己学号后两位R1(config-router)#network 1.1.1.1 mask 255.255.255.255R1(config-router)#network 172.16.0.0 mask 255.255.255.0R1(config-router)#network 172.16.1.0 mask 255.255.255.0R1(config-router)#network 172.16.2.0 mask 255.255.255.0R1(config-router)#network 172.16.3.0 mask 255.255.255.0R1(config-router)#network 192.168.1.0R2(config)#router bgp 65001 65001修改为65000+自己学号后两位R2(config-router)#neighbor 1.1.1.1 remote-as 65001 65001修改为65000+自己学号后两位R2(config-router)#network 2.2.2.2 mask 255.255.255.255R2(config-router)#network 192.168.1.0R2(config-router)#network 192.168.2.04、配置后在路由器R1中查看BGP邻居关系和汇总信息,参考命令如下:R1#show ip bgp neighborsR1#show ip bgp summary问题1:R1中邻居关系的状态是什么?5、查看路由器R1和R2的BGP的路由链路数据库信息,参考命令如下:R1#show ip bgp ipv4 unicast问题2:在数据库中是否有非直连链路信息?6、在路由器R1和R2中分别指定回环接口建立邻居关系,参考命令如下:R1(config)#router bgp 65001 65001修改为65000+自己学号后两位R1(config-router)#neighbor 2.2.2.2 update-source lo1 lo1为地址1.1.1.1的接口R2(config)#router bgp 65001 65001修改为65000+自己学号后两位R2(config-router)#neighbor 1.1.1.1 update-source lo0 lo0为地址2.2.2.2的接口问题3:再次查看R1的邻居关系,邻居关系状态为什么?问题4:在路由器R2中查看路由链路数据库,能否看到R1上面的路由?如果能看到的话这些路由是否为最佳路由?(提示:最佳路由提示符为“*>”)问题5:查看R2路由表,能否看到172.16.1.0路由?7、在路由器R1、R2中关闭同步功能R1(config)#router bgp 65001 65001修改为65000+自己学号后两位R1(config-router)#no synchronizationR2(config)#router bgp 65001 65001修改为65000+自己学号后两位R2(config-router)#no synchronization问题6:过一段时间查看路由器R2的路由表,是否能看到172.16.1.0的路由?8、在路由器R2和R3中配置不同自治系统的BGP路由,参考命令如下:R2(config)#router bgp 65001 65001修改为65000+自己学号后两位R2(config-router)#neighbor 3.3.3.3 remote-as 65002 65002修改为65001+自己学号后两位R2(config-router)#neighbor 3.3.3.3 update-source lo0 lo0为地址2.2.2.2的接口R2(config-router)#neighbor 3.3.3.3 ebgp-multihop 2R2(config)#ip route 3.3.3.3 255.255.255.255 192.168.2.3注:添加静态路由,使得R2能够访问3.3.3.3R3(config)#router bgp 65002 65002修改为65001+自己学号后两位R3(config-router)#neighbor 2.2.2.2 remote-as 65001 65001修改为65000+自己学号后两位R3(config-router)#neighbor 2.2.2.2 update-source lo1 lo1为3.3.3.3的接口R3(config-router)#neighbor 2.2.2.2 ebgp-multihop 2R3(config-router)#network 192.168.2.0R3(config-router)#network 192.168.3.0R3(config-router)#network 192.168.4.0R3(config-router)#network 192.168.5.0R3(config-router)#network 192.168.6.0R3(config-router)#network 192.168.7.0R3(config)#ip route 2.2.2.2 255.255.255.255 192.168.2.2注:添加静态路由,使得R2能够访问2.2.2.2问题7:查看路由器R3的路由表,能否得到全网的路由信息?问题8:查看路由器R1的路由器,能否得到全网的路由信息?9、在路由器R1中添加静态路由,使得能够访问3.3.3.3R1(config)#ip route 3.3.3.3 255.255.255.255 192.168.1.2问题9:过一段时间后再查看路由器R1的路由表,能否看到全网路由信息?10、通过路由汇总配置,有效的减少路由表的大小,提高路由效率。
配置BGP

配置BGPBGP协议概述BGP是目前Internet使用最广的外部网关协议(Exterior Gateway Protocol,EGP),其提供的主要功能是在不同的自治系统(autonomous systems,AS)之间交换网络可达信息,并通过协议自身机制消除路由环路。
BGP使用TCP作为传输协议,用TCP协议的可靠传输机制保证BGP的传输可靠性。
运行BGP协议的router称为BGP speaker,建立了BGP会话连接(BGP session)的BGP speakers之间被称作对等体(BGP peers)。
BGP speaker之间建立对等体的模式有两种:IBGP(Internal BGP)和EBGP(External BGP)。
IBGP是指在相同AS内建立的BGP连接,EBGP是指在不同AS之间建立的BGP连接。
二者的作用简而言之就是:EBGP是完成不同AS之间路由信息的交换,IBGP是完成路由信息在本AS内的过渡。
锐捷网络的BGP协议有如下特点:●支持BGP-4●支持路径属性✓ORIGN Attribute✓AS_PATH Attribute✓NEXT_HOP Attribute✓MULTI_EXIT_DISC Attribute✓LOCAL-PREFERENCE Attribute✓ATOMIC_AGGREGATE Attribute✓AGGREGATOR Attribute✓COMMUNITY Attribute✓ORIGINATOR_ID Attribute✓CLUSTER_LIST Attribute●支持BGP对等体组●支持使用Loopback接口●支持使用TCP的MD5认证●支持BGP和IGP的同步●支持BGP路由聚合●支持BGP路由衰减●支持BGP路由反射器●支持AS联盟●支持BGP软复位缺省的BGP配置:要运行交换机的BGP ,在特权模式下,按照如下步骤进行: Step1 Step2 Step3 Step4 Step5 Step6 Step7使用no router bgp 关闭BGP 。
BGP小结

BGP小结一、需要使用BGP的网络:1、在国干网络使用BGP:目的是为了传递各个省、运营商或不同AS的路由,为不同的AS间数据互访进行寻经;将本国使用的路由发布到国际网络上。
国干路由器和AS出口路由器建立EBGP邻居。
2、省干网络使用BGP:目的是为了传递本省内各个不同城市的路由,为本省内不同城市间数据互访进行寻经;将本省内使用的路由发布到国干网络上。
省干落地设备可以与城域网出口建立EBGP邻居,同时为城域网下发EBGP缺省路由。
3、城域网出口路由器使用BGP:EBGP网络的末梢设备,目的将本城域网使用的路由发布到省干网络上,同时从省干落地设备接受BGP缺省路由;同时和城域网汇聚层设备建立IBGP邻居。
4、城域网汇聚层路由器使用BGP:城域网BGP网络的末梢设备,目的是对出网流量在汇聚层进行分流,从而可以减轻城域网骨干层路由器的负担。
MP-BGP运行在MPLS的网络上,目的是为了传递VPN的路由。
二、BGP常用的属性:BGP路由属性是一套参数,它对特定的路由进行了进一步的描述,使得BGP 能够对路由进行过滤和选择。
在配置路由策略时我们将广泛地使用路由属性,但是不是所有路由属性都要被用上。
事实上,路由属性被分为以下几类:必遵属性:所有BGP路由器都可以识别,且必须存在于Update消息中。
如果缺少这种属性,路由信息就会出错。
可选属性:所有BGP路由器都可以识别,但不要求必须存在于Update消息中,可以根据具体情况来选择。
过渡属性:在AS之间具有可传递性的属性。
BGP路由器可以不支持此属性,但它仍然会接收带有此属性的路由,并通告给其他对等体。
非过渡属性:如果BGP路由器不支持此属性,则相应的Update消息会被忽略,且不会通告给其他对等体。
1、Origin属性:起点属性是一个必遵过渡属性,它指示路由更新的起源。
BGP允许三种类型的起源:BGP来说,BGP优先选用具有最小起点属性值的路由,即:IGP 优先于EGP,EGP优先于INCOMPLETE。
bgp属性

属性名称 origin
类别 公认必遵
属性特点 传递性 BGP能够识别并传递(更 AS内,AS间都传递 新消息中必须包含)
2
AS_path
公认必遵
BGP能够识别并传递(更 AS内,AS间都传递 新消息中必须包含)
3
NEXT-HOP
公认必遵
BGP能够识别并传递(更 AS内,AS间都传递 新消息中必须包含)
全局配置命令:ip bgp-community newformat; neighbor 10.1.12.2 send-community(默 认不传递,需加这条命令传递); ip community list 11 permit 100:11; match community 11 exact-match,精确 匹配; set excommunity cost X,cost小的优先 。 Set set excommunity pre-bestpath cost X,cost值超越weight成为第一路径 选择标准 sh ip community-list XX aggregator-address summary-only asset(汇总路由携带明细路由,则更新消息 里补包含Atomic-Agg属性)。
相关命令
bgp default local-prefrerence 500 修改默认LP值
bgp always-compare-med bgp bestpath med missing-as-worst set metric-type internal bgp bestpath med confed bgp deterministic-med default-metric X
6
COMMUNITY
可选传递Байду номын сангаас
CISCO+OSPF+MPLS+BGP配置实例加讲解

CISCO 路由器OSPF+MPLS+BGP配置实例二OO八年九月四日目录一、网络环境 (3)二、网络描述 (3)三、网络拓扑图 (4)四、P路由器配置 (4)五、PE1路由器配置 (6)六、PE2路由器配置 (9)七、CE1路由器配置 (11)八、CE2路由器配置 (13)九、业务测试 (14)一、网络环境由5台CISCO7204组成的网络,一台为P路由器,两台PE路由器,两台CE 路由器;二、网络描述在P和两台PE路由器这间通过OSPF动态路由协议完成MPLS网络的建立,两台PE路由器这间启用BGP路由协议,在PE路由器上向所属的CE路由器指VPN 路由,在CE路由器中向PE路由器配置静态路由。
配置思路:1、在P和两台PE路由器这间通过OSPF动态路由协议,在P和PE路由器两两互连的端口上启用MPLS,两台PE之间的路为备份路由,这属公网路由。
2、两台PE路由器这间启用BGP路由协议,这使得属于VPN的IP地址能在两个网络(两台CE所属的网络)互相发布,这属私网(VPN)路由。
3、在PE路由器上向所属的CE路由器指VPN路由,这打通了两个网络(两台CE所属的网络)之间的路由。
三、网络拓扑图P路由器(r1)(r4) CE1路由器(r5)LOOP0:192.168.3.1/24LOOP0:192.168.4.1/24四、P路由器配置p#SHOW RUNBuilding configuration...Current configuration : 1172 bytes!version 12.3service timestamps debug datetime msecservice timestamps log datetime msecno service password-encryption!hostname p!boot-start-markerboot-end-marker!!no aaa new-modelip subnet-zero!!!ip cefip audit po max-events 100!!interface Loopback0ip address 202.98.4.3 255.255.255.255 !interface FastEthernet0/0description to_r2ip address 10.1.1.10 255.255.255.252 ip ospf cost 20duplex fulltag-switching mtu 1508tag-switching ip!interface FastEthernet1/0description to_r3ip address 10.1.1.6 255.255.255.252 ip ospf cost 20duplex fulltag-switching mtu 1508tag-switching ip!interface FastEthernet2/0no ip addressshutdownduplex half!interface FastEthernet3/0no ip addressshutdownduplex half!router ospf 100log-adjacency-changesredistribute connected subnets redistribute static subnetsnetwork 10.1.1.6 0.0.0.0 area 0 network 10.1.1.10 0.0.0.0 area 0!ip classlessno ip http serverno ip http secure-server!gatekeepershutdown!!line con 0exec-timeout 0 0logging synchronousstopbits 1line aux 0stopbits 1line vty 0 4login!!endp#五、PE1路由器配置pe1#show runBuilding configuration...Current configuration : 1813 bytes!version 12.3service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption!hostname pe1!boot-start-markerboot-end-marker!!no aaa new-modelip subnet-zero!!!ip vrf vpnard 1:100route-target export 200:1route-target import 200:1!ip cefip audit po max-events 100!!interface Loopback0ip address 202.98.4.1 255.255.255.255!interface FastEthernet0/0description to_r5ip vrf forwarding vpnaip address 172.16.1.1 255.255.255.252 duplex fulltag-switching ip!interface FastEthernet1/0description to_r1ip address 10.1.1.5 255.255.255.252ip ospf cost 20duplex fulltag-switching mtu 1508tag-switching ip!interface FastEthernet2/0ip address 10.1.1.1 255.255.255.252ip ospf cost 100duplex fulltag-switching mtu 1508tag-switching ip!interface FastEthernet3/0no ip addressshutdownduplex half!router ospf 100log-adjacency-changesredistribute connected metric-type 1 subnetsnetwork 10.1.1.0 0.0.0.255 area 0network 202.98.4.0 0.0.0.255 area 0!router bgp 100no bgp default ipv4-unicastbgp log-neighbor-changesneighbor 202.98.4.2 remote-as 100neighbor 202.98.4.2 update-source Loopback0 neighbor 202.98.4.2 version 4!address-family vpnv4neighbor 202.98.4.2 activateneighbor 202.98.4.2 send-community extendedexit-address-family!address-family ipv4 vrf vpnaredistribute connectedredistribute staticno auto-summaryno synchronizationexit-address-family!ip classlessip route vrf vpna 192.168.3.0 255.255.255.0 172.16.1.2 no ip http serverno ip http secure-server!ip ospf name-lookup!!gatekeepershutdown!!line con 0exec-timeout 0 0logging synchronousstopbits 1line aux 0stopbits 1line vty 0 4login!!endpe1#六、PE2路由器配置pe2#show runBuilding configuration...Current configuration : 1725 bytes!version 12.3service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption!hostname pe2!boot-start-markerboot-end-marker!!no aaa new-modelip subnet-zero!!!ip vrf vpnard 1:100route-target export 200:1route-target import 200:1!ip cefip audit po max-events 100!!interface Loopback0ip address 202.98.4.2 255.255.255.255 !interface FastEthernet0/0description to_r1ip address 10.1.1.9 255.255.255.252ip ospf cost 20duplex fulltag-switching ip!interface FastEthernet1/0ip vrf forwarding vpnaip address 172.16.2.1 255.255.255.0duplex fulltag-switching ip!interface FastEthernet2/0ip address 10.1.1.2 255.255.255.252ip ospf cost 100duplex fulltag-switching ip!interface FastEthernet3/0no ip addressshutdownduplex half!router ospf 100log-adjacency-changesredistribute connected metric 1 subnets redistribute static metric-type 1 subnets network 10.1.1.0 0.0.0.255 area 0!router bgp 100no bgp default ipv4-unicastbgp log-neighbor-changesneighbor 202.98.4.1 remote-as 100neighbor 202.98.4.1 update-source Loopback0 neighbor 202.98.4.1 version 4!address-family vpnv4neighbor 202.98.4.1 activateneighbor 202.98.4.1 send-community extended exit-address-family!address-family ipv4 vrf vpnaredistribute connectedredistribute staticno auto-summaryno synchronizationexit-address-family!ip classlessip route vrf vpna 192.168.4.0 255.255.255.0 172.16.2.2 no ip http serverno ip http secure-server!gatekeepershutdown!!line con 0exec-timeout 0 0logging synchronousstopbits 1line aux 0stopbits 1line vty 0 4login!!End七、CE1路由器配置ce1#show runBuilding configuration...Current configuration : 892 bytes!version 12.3service timestamps debug datetime msecservice timestamps log datetime msecno service password-encryption!hostname ce1!boot-start-markerboot-end-marker!!no aaa new-modelip subnet-zero!!!ip cefip audit po max-events 100!!interface Loopback0ip address 192.168.3.1 255.255.255.0 !interface FastEthernet0/0description to_r3ip address 172.16.1.2 255.255.255.252 duplex full!interface FastEthernet1/0no ip addressshutdownduplex half!interface FastEthernet2/0no ip addressshutdownduplex half!interface FastEthernet3/0no ip addressshutdownduplex half!ip classlessip route 0.0.0.0 0.0.0.0 172.16.1.1no ip http serverno ip http secure-server!!!gatekeepershutdown!!line con 0exec-timeout 0 0logging synchronousstopbits 1line aux 0stopbits 1line vty 0 4login!!end八、CE2路由器配置Ce2#show runBuilding configuration...*Sep 3 13:53:56.167: %SYS-5-CONFIG_I: Configured from console by console Current configuration : 888 bytes!version 12.3service timestamps debug datetime msecservice timestamps log datetime msecno service password-encryption!hostname ce2!boot-start-markerboot-end-marker!!no aaa new-modelip subnet-zero!!!ip cefip audit po max-events 100!!interface Loopback0ip address 10.10.13.1 255.255.255.0!interface FastEthernet0/0no ip addressshutdownduplex half!interface FastEthernet1/0description to_r2ip address 10.10.12.2 255.255.255.0duplex full!interface FastEthernet2/0no ip addressshutdownduplex half!interface FastEthernet3/0no ip addressshutdownduplex half!ip classlessip route 0.0.0.0 0.0.0.0 172.16.2.1no ip http serverno ip http secure-server!!gatekeepershutdown!!line con 0exec-timeout 0 0logging synchronousstopbits 1line aux 0stopbits 1line vty 0 4login!!end九、业务测试ce1# ping 172.16.1.1Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:Success rate is 100 percent (5/5), round-trip min/avg/max = 96/190/324 ms ce1#ce2#ping 192.168.3.1Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:Success rate is 100 percent (5/5), round-trip min/avg/max = 336/468/588 ms ce2#。
BGP_aggregation

BGP aggregationYeslab Ender(安德)制作,更多内容请关注://andrew14BGP aggregation (1)1、实验目的:了解和掌握BGP聚合。
(1)2、实验拓扑描述 (1)3、实验步骤: (2)步骤一、建立基本的BGP连接 (2)步骤二、汇总各个参数具体实验 (3)1、实验目的:了解和掌握BGP聚合。
BGP的路由聚合是一项庞大而重要的任务,公布的一项数据表明,中国某ISP通告的前缀数目总是名列前茅的,这自然会增加设备的负担以及其他一些性能。
本实验涉及的内容包括:summary-only(只通告汇总路由);as-set(还原路由AS属性);suppress-map(抑制某些路由);attribute-map(可修改极少的一些属性),advertise-map以及通常的先汇总再通告的情况,route-map的参数,可以用这个参数在汇总之后的路由上增加一些属性比如community等2、实验拓扑描述IP地址说明,比如R2上连接R3的地址为23.1.1.2/24,以此类推3、实验步骤:步骤一、建立基本的BGP连接如图所示R1和R2建立EBGP邻居关系,AS200内为全互联的full-mesh,R4和R5为EBGP 邻居关系。
这里仅仅给出R4的邻居配置:router bgp 200no synchronizationbgp log-neighbor-changesnetwork 44.1.1.0 mask 255.255.255.0redistribute connected route-map CONN---该route-map匹配R4和R5的直连,重分步到AS200 neighbor 10.1.1.3 remote-as 200neighbor 10.1.1.5 remote-as 300neighbor 22.1.1.1 remote-as 200neighbor 22.1.1.1 update-source Loopback0neighbor 33.1.1.1 remote-as 200no auto-summary我们来查看邻居情况R4#show ip bgp summaryBGP router identifier 44.1.1.1, local AS number 200-------------------------------------------------省略部分无关内容-------------------------------------------- Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 10.1.1.3 4 200 95 104 61 0 0 01:31:55 010.1.1.5 4 300 98 142 61 0 0 01:31:40 122.1.1.1 4 200 450 431 61 0 0 01:13:17 2步骤二、汇总各个参数具体实验R1上增加环回口lo0---3并通告路由,然后观察汇总的路由情况router bgp 100no synchronizationbgp log-neighbor-changesnetwork 1.1.1.0 mask 255.255.255.0network 11.1.0.0 mask 255.255.255.0network 11.1.1.0 mask 255.255.255.0network 11.1.2.0 mask 255.255.255.0下面是一种通用的汇总办法,即先用静态做一条汇总路由指向null 0,然后在BGP同通告该路由达到汇总的目的R1(config)#ip route 11.1.0.0 255.255.252.0 null 0R1(config)#router bgp 100R1(config-router)#network 11.1.0.0 m 255.255.252.0在R1和R2上查看路由情况R1#show ip bgpBGP table version is 64, local router ID is 11.1.1.1Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path*> 11.1.0.0/24 0.0.0.0 0 32768 i*> 11.1.0.0/22 0.0.0.0 0 32768 i---R1通告成功汇总路由*> 11.1.1.0/24 0.0.0.0 0 32768 i*> 11.1.2.0/24 0.0.0.0 0 32768 i*> 11.1.3.0/24 0.0.0.0 0 32768 iR2#sh ip bgpBGP table version is 44, local router ID is 22.1.1.1Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path*> 11.1.0.0/24 12.1.1.1 0 0 100 i*> 11.1.0.0/22 12.1.1.1 0 0 100 i-R2接收到汇总的路由,同时也收到了明细路由*> 11.1.1.0/24 12.1.1.1 0 0 100 i*> 11.1.2.0/24 12.1.1.1 0 0 100 i*> 11.1.3.0/24 12.1.1.1 0 0 100 i步骤3、使用aggregate命令汇总去掉之前的汇总R1(config)#router bgp 100R1(config-router)#no network 11.1.0.0 m 255.255.252.0R1(config)#no ip route 11.1.0.0 255.255.252.0 null 0只通告汇总之后的路由- summary-only参数R1(config)#router bgp 100R1(config-router)#aggregate-address 11.1.0.0 255.255.252.0 summary-only查看R2的情况,它仅仅收到通告后的路由R2#show ip bgpBGP table version is 50, local router ID is 22.1.1.1Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path*> 11.1.0.0/22 12.1.1.1 0 0 100 i另外一种情况,通告汇总路由,同时抑制某些路由不被通告出去- suppress-map R1(config)#access-list 1 permit 11.1.2.0 0.0.0.255R1(config)#route-map SupR1(config-route-map)#match ip address 1R1(config)#router bgp 100R1(config-router)#aggregate-address 11.1.0.0 255.255.252.0 suppress-map SupR1#clear ip bgp *查看R1和R2的路由情况R1#show ip bgpBGP table version is 11, local router ID is 11.1.3.1Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path*> 11.1.0.0/24 0.0.0.0 0 32768 i*> 11.1.0.0/22 0.0.0.0 32768 i*> 11.1.1.0/24 0.0.0.0 0 32768 is> 11.1.2.0/24 0.0.0.0 0 32768 i---S代表被抑制,其他路由通告给R2*> 11.1.3.0/24 0.0.0.0 0 32768 iR2上验证了我们预期的结果,没有11.1.2.0/24的路由R2#show ip bgpBGP table version is 63, local router ID is 22.1.1.1Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path*> 11.1.0.0/24 12.1.1.1 0 0 100 i*> 11.1.0.0/22 12.1.1.1 0 0 100 i*> 11.1.1.0/24 12.1.1.1 0 0 100 i*> 11.1.3.0/24 12.1.1.1 0 0 100 i去掉R1上的汇总,以便我们进行下面的实验R1(config)#router bgp 100R1(config-router)#no aggregate-address 11.1.0.0 255.255.252.0 suppress-map Sup步骤3、观察另外两个参数as-set和attribute-map我们在R2上做汇总,这种场景也很合乎逻辑,即某些ISP接收到路由后汇总它们R2(config)#router bgp 200R2(config-router)#aggregate-address 11.1.0.0 255.255.252.0 summary-only查看R5以及R1的路由R5#sh ip bgpBGP table version is 80, local router ID is 55.1.1.1Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetwork Next Hop Metric LocPrf Weight Path*> 11.1.0.0/22 10.1.1.3 0 200 i需要说明的是该路由是由R2产生的,且其源自IGP,不再具有其源自AS100的属性。
BGP community属性

BGP community属性无敌详解文档(视频详解+配套文档)community属性是BGP众多路径属性中一个相对比较难理解的知识点,需要通过大量实验加深印象,为了帮助大家更清晰的了解这个路径属性,我特定编写了这份文档,希望对大家有所帮助。
本文档配套详解视频:1、community的基本概念可选传递,用于简化路由策略的执行。
可以将某些路由分配一个特定的COMMUNITY 属性,之后就可以基于COMMUNITY值而不是每条路由进行BGP属性的设置了。
COMMUNITY属性对邻居起作用,在设置后,同时需要向邻居发送(send community,默认是不会发送的)。
COMMUNITY属性是一组4个8位组的数值,RFC1997规定前2B表示AS号,后2B 表示基于管理目的设置的标示符,格式为AA:NN,而CISCO默认显示格式为NN:AA (CISCO IOS在显示community值时,默认是按10进制格式显示),可使用全局配置命令ip bgpcommunity new-format将CISCO默认格式改为RFC格式。
例如将AS12的某条路由COMM值改为10000,RFC采用十六进制表示COMMUNITY属性,而CISCO采用十进制。
RFC格式为12:10000,十六进制为0x 000C2710,再转换为十进制796432(这就是CISCO IOS默认显示的值)。
抓个包看一下:2、在route-map中设置community属性route-map test permit 10set community ?<1-4294967295> community numberaa:nn community number in aa:nn formatadditive Add to the existing community 设置commu值为附加,否则为覆盖 internet Internet (well-known community) 默认所有路由都属于该团体local-AS Do not send outside local AS (well-known community)no-advertise Do not advertise to any peer (well-known community)no-export Do not export to next AS (well-known community)none No community attribute下边我们来看一下community的这几个众所周知值的本文为原创博文,no-advertiseno-exportlocal-as配置示例(使用route-map为路由分配community):在R1上为路由11.11.11.0/24分配community 100:11,并且传递给R2,那么R1上配置如下:ip prefix-list 11 permit 11.11.11.0/24route-map test permit 10match ip address prefix-list 11set community 100:11router bgp 100network 11.11.11.0 mask 255.255.255.0neighbor 10.1.12.2 remote-as 200neighbor 10.1.12.2 send-community // 默认community不发送,因此必须配置该命令neighbor 10.1.12.2 route-map test out注意community默认不发送,必须send-community。
h3c BGP路由策略应用本地优先级、团体属性功能的配置

//引入静态路由
import-route static
undo synchronization
//建立BGP邻居,这里是EBGP,用IBGP也是可以的
peer1.1.1.2 as-number 2
#
//设计好的3条静态黑洞路由
ip route-static1.2.0.0 255.255.0.0 NULL0
ip route-static1.2.3.0 255.255.255.0 NULL0
ip route-static2.0.0.0 255.255.0.0 NULL0
#
RTB配置
#
interface GigabitEthernet0/0
port link-mode route
ip address1.1.1.2 255.255.255.252
//对RTA应用入方向的路由策略com
peer1.1.1.1 route-policy com import
#
//路由策略com允许节点10配置
route-policy com permit node 10
//匹配ACL 2000
if-match acl 2000
//修改本地优先级为168
apply local-preference 168
二、组网图:
三、配置步骤:
适用设备和版本:MSR系列、Version 5.20, Release 1206后所有版本。
RTA配置
#
interface GigabitEthernet0/0
port link-mode route
ip address1.1.1.1 255.255.255.252
#
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
BGP community属性网友:怒咆的野狼发布于:2007.05.18 13:11(共有条评论) 查看评论| 我要评论R1R2R3R4R5顺次互联community属性。
这是不同于选路属性的一个属性。
该属性具有以下几个特点;1 community是一个任选可透明传送属性,它可以简化策略的执行。
2 它是cisco的一个专有属性,现在在RFC1997中已被标准化。
3 commnity属性标明一个目的地作为一些目的地团体中的一个成员,这些目的地共享一个或多个共同的特性。
4 community值可以自己定义,另外有几个已经定义好的团体属性:NO_ADVERTISE:表示携带该值的路由不能公布给EBGP和IBGP邻居NO_EXPORT:表示携带该值的路由不能公布给EBGP邻居LOCAL_AS:(NO_EXPORT_SUBCONFED)携带该值的路由可以公布给联盟内的其它子自治系统但不能在构成联盟的AS以外进行公布。
试验步骤如下:配置BGP,在本实验中要建立联邦我们顺便学习一下联邦配置团体属性,让2.2.2.0网络只被R2学习到配置团体属性,让22.22.22.0网络只被R2,R3学习到配置团体属性,让222.222.222.0网络只被R2,R3,R4学习到配置团体属性,让R1不传递2.2.2.0 这条路由二试验配置配置BGPr1#sh run | b r brouter bgp 100no synchronizationnetwork 2.2.2.0 mask 255.255.255.0network 22.22.22.0 mask 255.255.255.0network 222.222.222.0neighbor 12.0.0.2 remote-as 234no auto-summaryr2#sh run | b r brouter bgp 64512no synchronizationbgp confederation identifier 234 /指明联邦号是234neighbor 12.0.0.1 remote-as 100neighbor 23.0.0.3 remote-as 64512 /R3跟它处于联邦内同一个子AS中neighbor 23.0.0.3 next-hop-self /指定下一跳是它自己no auto-summaryr3#sh run | b r brouter bgp 64512no synchronizationbgp confederation identifier 234bgp confederation peers 64513 /指明该联邦内的另一个子AS neighbor 23.0.0.2 remote-as 64512neighbor 34.0.0.4 remote-as 64513 /R4跟它处于联邦内不同子AS之间no auto-summaryr4#sh run | b r brouter bgp 64513no synchronizationbgp confederation identifier 234bgp confederation peers 64512neighbor 34.0.0.3 remote-as 64512neighbor 45.0.0.5 remote-as 500no auto-summaryr5#sh run | b r brouter bgp 500no synchronizationneighbor 45.0.0.4 remote-as 234no auto-summary查看网络r2#sh ip bgpNetwork Next Hop Metric LocPrf Weight Path *> 2.2.2.0/24 12.0.0.1 0 0 100 i *> 22.22.22.0/24 12.0.0.1 0 0 100 i *> 222.222.222.0 12.0.0.1 0 0 100 i r3#sh ip bgpNetwork Next Hop Metric LocPrf Weight Path *>i2.2.2.0/24 23.0.0.2 0 100 0 100 i *>i22.22.22.0/24 23.0.0.2 0 100 0 100 i *>i222.222.222.0 23.0.0.2 0 100 0 100 i在R2上已经修改了下一跳,所以这时下一跳已经是R2自己了。
r4#sh ip bgpNetwork Next Hop Metric LocPrf Weight Path* 2.2.2.0/24 23.0.0.2 0 100 0 (64512) 100 i* 22.22.22.0/24 23.0.0.2 0 100 0 (64512) 100 i* 222.222.222.0 23.0.0.2 0 100 0 (64512) 100 i注意在R4上看,下一跳依然是R2;为什么不是R3呢?因为R3,R4虽然在同一联邦内,但它们在不同的子AS之间,应该是EBGP关系。
EBGP之间传递路由时,下一跳因该是EBGP邻居。
但这里为什么不是呢。
这就是联邦内EBGP与联邦外EBGP的不同之处。
所以现在这些路由的下一跳对于R4来说是不可达的,所以现在路由无法优化,也就无法向R5传递。
现在在R3上修改下一跳r3(config)#router bgp 64512r3(config-router)#neighbor 34.0.0.4 next-hop-selfr4#sh ip bgpNetwork Next Hop Metric LocPrf Weight Path*> 2.2.2.0/24 34.0.0.3 0 100 0 (64512) 100 i*> 22.22.22.0/24 34.0.0.3 0 100 0 (64512) 100 i*> 222.222.222.0 34.0.0.3 0 100 0 (64512) 100 i这时,在R4上看,下一跳已经变成了R3,路由可以优化。
注意在AS路径中可以看到路由经过了子AS 64512r5#sh ip bgpNetwork Next Hop Metric LocPrf Weight Path*> 2.2.2.0/24 45.0.0.4 0 234 100 i*> 22.22.22.0/24 45.0.0.4 0 234 100 i*> 222.222.222.0 45.0.0.4 0 234 100 iR5上也可以收到这些路由了,注意R5的AS路径看不到子AS ,只能看到联邦的总AS号。
因此可以得出这样的结论:联邦内的子AS对于联邦外部来说是隐藏的,不可见的。
到现在为止,所有路由器都可以学习到路由,下面就要应用团体属性来控制路由的传递了。
三配置团体属性,让2.2.2.0网络只被R2学习到这里最合适的community属性应该是:no_advertise 因为它不会向任何EBGP IBGP邻居公布路由。
r1(config)#access-list 1 permit 2.2.2.0 0.0.0.255 /用ACL匹配该路由r1(config)#route-map WY permit 10r1(config-route-map)#match ip add 1r1(config-route-map)#set community no-advertise /设定团体属性r1(config)#route-map WY permit 20 /与ACL一样route-map最后也隐藏了一句deny any ,所以在这里要允许所有,要不然其它两条路由会因为匹配不上而无法从R1传递出去。
r1(config)#router bgp 100r1(config-router)#neighbor 12.0.0.2 route-map WY out /在进程下出方向调用route-mapr1(config-router)#neighbor 12.0.0.2 send-community /让R2传递该社团属性先在R2上进行查看;r2#sh ip bgpNetwork Next Hop Metric LocPrf Weight Path*> 2.2.2.0/24 12.0.0.1 0 0 100 i*> 22.22.22.0/24 12.0.0.1 0 0 100 i*> 222.222.222.0 12.0.0.1 0 0 100 iR2可以学习到该路由在R3上查看r3#sh ip bgpNetwork Next Hop Metric LocPrf Weight Path*>i222.222.222.0 23.0.0.2 0 100 0 100 i可以看到R3已经收不到2.2.2.0这个网络了,往后的路由器也无法收到了。
所以社团属性No_advertise 满足了只让R2学到该路由的需求。
四配置团体属性,让22.22.22.0网络只被R2,R3学习到因为R2,R3处于联邦内同一个子AS,意思是该路由不能传递出这个子AS,所以可以用community属性:LOCAL_ASr1(config)#access-list 2 permit 22.22.22.0 0.0.0.255r1(config)#route-map WY permit 10r1(config-route-map)#match ip add 2r1(config-route-map)#set community local-ASr1(config)#route-map WY permit 20现在进行查看r2#sh ip bgpNetwork Next Hop Metric LocPrf Weight Path*> 2.2.2.0/24 12.0.0.1 0 0 100 i*> 22.22.22.0/24 12.0.0.1 0 0 100 i*> 222.222.222.0 12.0.0.1 0 0 100 iR2可以学习到。
r3#sh ip bgpNetwork Next Hop Metric LocPrf Weight Path*>i2.2.2.0/24 23.0.0.2 0 100 0 100 i*>i222.222.222.0 23.0.0.2 0 100 0 100 iR3也可以学到r4#sh ip bgpNetwork Next Hop Metric LocPrf Weight Path*> 2.2.2.0/24 34.0.0.3 0 100 0 (64512) 100 i*> 22.22.22.0/24 34.0.0.3 0 100 0 (64512) 100 i*> 222.222.222.0 34.0.0.3 0 100 0 (64512) 100 i为什么R4依然可以学习到,难道属性没起作用吗?显然属性没有起作用,这是因为R2向R3传递该路由时没有让R3继承这个属性,所以R4依然可以学习到,现在必须在R2上配置让R3继承这个属性,这样R3向R4传递路由时团体属性才能生效。