BGP(Border Gateway Protocol,边界网关协议)是一种在AS(Autonomous Systems,自治系统)间自动交换无环路路由信息的动态路由协议。
为便于管理网络,网络被分割为多个AS。早期的互联网中,AS间动态交换路由信息使用的是EGP(Exterior Gateway Protocol,外部网关协议),其最早描述于RFC 827,并于1984年在RFC 904中被正式纳入规范。但EGP仅仅是一种简单的网络可达性协议,只适用于树状拓扑网络,无法满足日渐复杂的网络管理需求,因此EGP最终被BGP取代。不同于EGP,BGP可以实现环路避免和路由优选,在路由传递功能上更为高效,并提供了更好的扩展性。
BGP经历了不同的发展阶段,早期发布过三个版本,分别是BGP-1(RFC 1105)、BGP-2(RFC 1163)以及BGP-3(RFC 1267),目前使用的版本是BGP-4(RFC 4271),作为当前自治系统间的标准路由协议被广泛应用。
BGP协议的特性如下:
不同于OSPF、RIP等IGP(Interior Gateway Protocol,内部网关协议)着重于关注发现和计算路由,BGP重点在于控制路由的传播,适用于承载大规模路由的网络。
BGP使用TCP协议作为传输协议,目的端口为179,通过TCP协议的可靠传输机制保证BGP的传输可靠性。
BGP作为距离矢量路由协议,只将本地选举出最优的路由传递给邻居。
说明
本章使用“路由器”指支持路由功能的网络设备。这些网络设备可以是三层交换机、路由器和防火墙等。
运行BGP协议并发送BGP报文的设备称为BGP发言者(Speaker)。
建立了BGP会话连接的BGP Speakers之间被称作BGP对等体(Peer)。多个对等体可以组成对等体组。
AS是一组在同一机构管理并共享相同路由策略的设备。路由设备启用BGP协议,必须要指定本地AS号。AS号是由IANA分配的全球唯一的数字,分为2字节AS号和4字节AS号。
传统的AS号由2个字节组成,范围为1-65535。为解决AS号资源日渐枯竭问题,新定义的AS号使用4个字节表达,AS号的取值范围为1~4294967295。
4字节AS号支持2种方式表示方式:十进制表示和圆点模式。其中十进制表示与传统表示方式一样,将4字节AS号用十进制数表示。而圆点模式与十进制模式的换算关系为:十进制的4字节AS号=x*65536+y。
例如:
十进制表示的AS号65534,用圆点模式表示为65534(小于65536的AS号与十进制表达一样)。
十进制表示的AS号65536,用圆点模式表示为1.0。
十进制表示的AS号65538,用圆点模式表示为1.2。
随着4字节AS号的引入,必将出现只支持2字节AS号的设备和支持4字节AS号的设备之间建立BGP连接的问题。如果与使用4字节AS号的设备通信,那么在仅支持2字节AS号的设备上需要保留AS号23456来填补。
BGP邻居分为两种基本类型:
IBGP(Internal BGP,内部边界网关协议)邻居:相同AS内的BGP会话者之间的邻居关系,称为IBGP邻居;从IBGP邻居学习到的路由称为IBGP路由。IBGP用于完成路由信息在本AS内的过渡。
EBGP(External BGP,外部边界网关协议)邻居:不同AS间的BGP会话者之间邻居关系,称为EBGP邻居;从EBGP邻居学习到的路由称为EBGP路由。EBGP用于完成不同AS间路由信息的交换。
BGP定义了如下五种报文:
OPEN报文:用于在BGP对等体间建立连接。
UPDATE报文:用于在BGP对等体间交换路由信息。
NOTIFICATION报文:用于中断BGP连接。
KEEPALIVE报文:用于保持BGP连接。
ROUTE-REFRESH报文:用于在改变路由策略后请求对等体重新发送路由信息。只有支持路由刷新能力的BGP设备会发送和响应此报文。
以上消息中,除KEEPALIVE报文为周期性发送,其他报文均为事件触发时发送。
BGP Speaker向邻居通告路由时也将通告路由携带的属性,常用的BGP属性包括如下。
指出BGP路由的起源,包含三种取值IGP、EGP和INCOMPLETE:
IGP:值为0,表示始发AS内部的路由信息。
EGP:值为1,表示从EGP获取的路由信息。
INCOMPLETE:值为2,表示通过其他方式学习的路由信息。
反向列出了路由先后经过的自治系统,最后一个AS放置在列表的开始处。
AS_PATH属性的用途如下:
在路由器接收到的路由信息中,如果AS_PATH包含本地AS号,则路由器将会认为该路由存在环路,并将之丢弃。
使用基于AS路径的过滤规则控制路由信息的分发,过滤规则将使用正则表达式对AS路径进行解析。
按照标准RFC 1771实现,BGP进行最优路径选举时并不考虑AS路径长度。但一般情况下,AS路径长度越短,路径优先级越高,所以设备在进行最优路径选举时考虑了AS路径的长度。可以根据实际情况决定在选举最优路径时是否考虑AS路径长度。
指出到达BGP路由的下一跳IP地址。
下一跳属性的变更通常遵守如下规则:
向IBGP对等体发送非本地发起的路由时,设备不更改下一跳属性。
向IBGP对等体发送本地发起的路由时,设备使用与对端建立BGP邻居关系的接口地址作为下一跳。
向EBGP对等体发送路由时,设备使用与对端建立BGP邻居关系的接口地址作为下一跳。
区分到达相同邻居AS的多个出口或入口点,值越小路由优先级越高。MULTI_EXIT_DISC属性在下文简称为MED。
BGP使用MED值作为对从EBGP对等体学习到的路径进行优先级比较的依据之一,MED值越小,路径优先级越高。
缺省情况下,选举最优路径时,只对来自同一AS的对等体的路径比较MED值。
缺省情况下,选举最优路径时,对来自AS联盟内部其他子AS的对等体的路径不进行MED比较。
缺省情况下,如果接收到未设置MED属性的路径,该路径的MED值被认为是0。根据MED值越小,路径优先级越高,该路径的MED达到了最高的优先级。
缺省情况下,选举最优路径时,对于来自不同AS的路径不比较MED属性,将根据接收到的路径的顺序进行比较。
在AS内部区分IBGP路由的优先级,值越大优先级越高。
BGP Speaker将从EBGP对等体接收到的路由发送给IBGP对等体时添加LOCAL_PREF(本地优先级)属性。对于从IBGP对等体学习到的路径,BGP使用LOCAL_PREF作为其优先级比较的依据之一,LOCAL_PREF值越大优先级越高。
ATOMIC_AGGREGATE属性用来告知接收者此路由是经过聚合的。
当BGP Speaker收到两条重叠的路由且其中一条包含的地址是另一条的子集时,通常BGP Speaker会优选更精细的路由。但是,如果BGP Speaker选择更粗略的路由对外发布,此时发布的路由信息需要携带ATOMIC-AGGREGATE属性。收到携带ATOMIC-AGGREGATE属性的路由信息说明更精细的路由信息在发布过程中丢失了。
在进行路由聚合时,对于聚合的路由信息会添加ATOMIC-AGGREGATE属性。
AGGREGATOR属性用于补充ATOMIC_AGGREGATE属性。AGGREGATOR属性包含了发起路由聚合的AS号码和形成聚合路由的BGP发布者的IP地址。
在进行路由聚合时,对于聚合的路由信息,在添加ATOMIC-AGGREGATE属性的同时会添加AGGREGATOR属性。
COMMUNITY(团体)属性是控制路由信息分发的另一种方式。
团体是一组目的地的集合。定义COMMUNITY属性的作用是为了方便实施基于团体的路由策略,从而简化在BGP Speaker上控制路由信息分发的配置。通过团体属性,可以控制路由信息的接收和分发。每个目的地可以属于多个团体,自治系统管理员可以定义一个目的地属于哪些团体。
BGP预定义了四个公共的团体属性值:
Internet:表示Internet团体,所有的路径都属于该团体。
No-export:表示本路径不发布给EBGP对等体。
No-advertise:表示本路径不发布任何一个BGP对等体。
Local-as:表示本路径不发布到本AS外部。当配置联盟时,本路径不发布给其它的自治系统或子自治系统。
缺省情况下,所有的目的地都属于Internet团体,携带在路径的团体属性中。
BGP Speaker可以在学习、发布或者重分发路由时设置、添加或者修改团体属性值。在进行路由聚合时,聚合后的路径将包含所有被聚合的路径的团体属性值。
AIGP(The Accumulated IGP Metric Attribute,累加内部网关协议度量值属性)能够累加路由所经过路径的IGP Metric。BGP使用AIGP属性值进行路由优选更能准确反应路径的开销。AIGP属性值越小,则路由优先级越高。对于携带AIGP属性的路由比不携带AIGP属性的路由优先级高。
路由所携带的AIGP属性,在路由传递过程中,如果路由下一跳发生变动,当修改为自身或者修改为其他值时,需要累加上到达原下一跳地址对应的IGP Metric值。
BGP不能自动发现或学习可达网络,必须将本地AS的可达网络信息注入BGP,BGP才能将这些信息发布给邻居。
有两种基本方式实现向BGP注入本地AS的网络信息:
手动静态配置:将指定范围内的可达网络信息注入BGP。
配置路由重分发:将IGP协议的可达网络信息重分发注入BGP。
BGP具有强大的路由管理功能,通过配置BGP对等体的路由交互策略,可以主动控制从该对等体接收的和向该对等体通告的路由。
将BGP交换来的其他AS的路由信息下发到设备的路由表,则当前路由设备就能够转发其他AS的报文。将BGP交换来的其他AS的路由信息注入到IGP中,由IGP分发至本地AS的其他运行IGP的设备,则这些设备就能够转发其他AS的报文。
通常,互为IBGP邻居的BGP Speaker物理上并非直连,链路上的IGP协议设备学习不到与BGP Speaker相同的路由信息。当AS域边界BGP Speaker将从其他域接收到的数据报文,转发给下一跳IBGP邻居时,报文将经过中间的IGP协议设备,此时可能因IGP设备上没有路由而出现丢包现象。如果要求BGP和IGP保持同步,那么对于将被发往另一个AS的路由信息,必须保证本AS内所有的路由器都学习到该路由信息时,才能将该路由信息发布到另一个AS。大部分情况下,BGP和IGP应保持同步,除了以下两种情况:
不存在穿越本AS的路由信息,例如本AS是一个末梢AS。
本AS内所有的路由器都运行BGP协议,所有的BGP Speaker之间建立全连接关系(BGP Speaker两两建立邻接关系)。
BGP路由更新组(Update-group)功能是一种用于提高向邻居通告路由处理性能的技术。
BGP路由更新组技术将相同配置策略的邻居自动归类为同一个更新组。设备在向邻居发送路由时,基于更新组封装Update报文,并向更新组内的邻居复制发送Update报文,从而实现一次封装多次发送,提高向邻居通告路由的处理性能。
BGP选择最优路由的策略如下:
如果路由表项无效(即下一跳无法到达的表项和处于震荡中的表项),那么不参与最优路由的选择。
否则,如果是通过配置network命令生成的路由,则该路由优先。
否则,首选具有最大Weight的路由(默认本地始发的Weight值为32768,邻居通告的Weight值为0)。
如果路由具有相同Weight,选举LOCAL_PREF属性值高的路由。
如果具有相同本地优先级,则首选来自该路由器的本地BGP路由。
本地路由类型比较,优先级为直连路由>静态路由>BGP生成的聚合路由。
如果本地路由相同,比较AIGP扩展属性,携带AIGP属性的路由优先于没有携带AIGP属性的路由。
如果跳过AIGP属性比较,则比较LS扩展属性:
携带LS属性优先。
IGP Metric较小的优先。
WIDE类型比NARROW类型优先级高。
否则,选举AS长度最短的路由。
否则,选举ORIGIN Code属性值最低的路由。
否则,选择MED值最小的路由。
否则,EBGP路径优先级高于IBGP路径和AS联盟内的路由,IBGP路径和AS联盟内的路由的优先级同样高。
否则,选举到达下一跳的IGP Metric最小的路由。
否则,在从EBGP路由中,选举接收较早的路由。
否则,选举公告该路由的BGP Speaker的Router-ID小的路由。
否则,选举Cluster(群)长度小的路由。
否则,选举邻居地址小的路由。
BGP邻居由用户手动配置指定,建立连接关系的模式有两种:IBGP和EBGP。用户可以通过BGP对等体所在的AS和本BGP Speaker所在的AS来判断BGP Speakers之间建立的连接模式。
BGP Speaker会主动向用户指定的BGP对等体发起TCP连接请求。TCP连接成功后将交互BGP协议报文协商连接参数,协商一致后BGP邻居关系就成功建立。
BGP Speaker会主动向邻居发起TCP连接请求,目的IP是用户指定的对等体IP地址,端口号固定为179。
BGP Speaker同时会侦听本地TCP连接的179端口号,以接收来自对等体的连接请求。
TCP连接建立成功后,BGP Speaker会互相交互OPEN报文,协商BGP连接参数。协商的参数包括:
Version:BGP协议版本号,目前仅支持Version 4。
邻居AS号:确定邻居的AS号是否与本地指定的一致,不一致将拒绝建立连接。
Hold Time:协商BGP连接超时的时间间隔,缺省值为180秒。
邻居能力:协商邻居支持的各种扩展能力,如地址族、路由动态刷新和GR功能等。
BGP Speaker之间周期性地发送Keepalive消息。如果Hold Time超时还没有收到该BGP邻居发出的新的Keepalive报文,则认为该邻居不可达,将断开邻居TCP连接,并尝试重新开启。BGP发送Keepalive的时间间隔为协商后的Hold Time的三分之一,缺省为60秒。
软件支持手动配置BGP协议内部的各种定时器,以灵活应对不同网络环境下的邻居保活和路由管理需求。
BGP邻居保活定时器
BGP使用Keepalive定时器来维持和对等体的有效连接,使用Holdtime定时器来判断对等体是否有效。缺省情况下,Keepalive定时器的值为60秒,Holdtime定时器的值为180秒。当BGP Speakers之间建立BGP连接时,双方将对Holdtime进行协商,选择值更小的Holdtime。Keepalive定时器值选择协商后的Holdtime值的1/3和配置的Keepalive值的较小者。
邻居重连定时器
为降低BGP频繁尝试与连接失败的邻居进行重连对网络带宽的影响,BGP Speaker检测到与邻居建立连接失败之后,将在Connect-Retry定时器到期之后再尝试进行重连。缺省情况下,Connect-Retry定时器的值为15秒。
路由通告定时器
为减少路由更新报文对网络带宽的影响,BGP Speaker在检测到网络拓扑发生变动后,并不立即将路由更新通告给邻居,而是采用定时更新的机制,将所有发生变化的路由信息一起通告给邻居设备。
多路径负载均衡,指到达同一网络的路径存在多条,数据报文从这些路径中均衡转发。在路由表中的表现为一条路由存在多个下一跳。
根据等价路由的类型,BGP多路径负载均衡可分为如下两种:
EBGP负载均衡:从EBGP邻居到的路由实现负载均衡。
IBGP负载均衡:从IBGP邻居学到的路由实现负载均衡。
缺省情况下,当GP路由表里存在多条到达同一网络的路径时,BGP会从中计算出一条优先级最高的路由。如果存在多条路由优先级相同且都为最优,BGP仍然会通过比较规则选出唯一的路由,并将此路由通知给转发面,控制数据流转发。启动多路径负载均衡功能后,BGP除了会计算出唯一的最优路由,还会将与之优先级相同的路径列为等价路由,然后将最优路由与等价路由一起通知给转发面,从而实现负载均衡。
路由等价的条件是路由基本属性相同、优先级也相同,即按照BGP最优路径选择规则,在进行Router-ID比较之前,路径优先级相同。
AS_PATH宽松比较
缺省情况下,路由等价的条件要求路由的AS-PATH属性必须完全相等。如此苛刻的条件在某些环境下无法满足用户负载均衡的需求,此时建议启用AS-PATH宽松比较模式。在AS-APTH宽松比较模式里,在满足其他路由等价条件下,只要路由的AS-PATH长度和联盟AS-PATH长度分别相等,即可满足路由等价的条件。
Router-ID多路径比较
缺省情况下,路由等价的条件并不需要来自同一台设备(即路由来源的Router-ID不需要一样)。开启Router-ID多路径比较功能后,只有来自于相同Router-ID的路由才能形成等价。
非等价负载均衡
缺省情况下,所形成负载均衡的路由都是等价路由。开启非等价负载均衡功能后,可在路由中携带Link-Bandwidth(链路带宽)属性来携带链路带宽信息,用于形成非等价路由。
路由反射器是一种减少自治系统内IBGP对等体连接数量的方法。
根据BGP路由通告原则,要求一个AS内的所有BGP Speaker将建立全连接关系(BGP Speaker两两建立邻接关系)。当AS内的BGP Speaker数量过多,将增加BGP Speaker的资源开销,同时也给网络管理员增加了配置任务的工作量和复杂度,降低了网络的扩展性能。
将一台BGP Speaker设置为路由反射器,其将本自治系统内的IBGP对等体分为两类:客户端和非客户端。
在AS内实现路由反射器,其规则如下:
配置路由反射器,并指定其客户端,路由反射器和其客户端形成一个群。路由反射器和客户端之间将建立连接关系。
一个群内路由反射器的客户端不应该同群外的其他BGP Speakers建立连接关系。
在AS内,非客户端的IBGP对等体之间建立完全连接关系,非客户端的IBGP对等体包括以下几种情况:一个群内的多个路由反射器之间;群内的路由反射器和群外不参与路由反射器功能的BGP Speaker(通常这些BGP Speaker不支持路由反射器功能);群内的路由反射器和其他群的路由反射器之间。
路由反射器接收到一条路由的处理规则如下:
从EBGP Speaker接收到的路由更新,将发送给所有的客户端和非客户端。
从客户端接收到的路由更新,将发送其他客户端和所有非客户端。
从IBGP非客户端接收到的路由更新,将发送给其所有客户端。
联盟是另一种减少自治系统内IBGP对等体连接数量的方法。
将一个自治系统划分为多个子自治系统,并通过设置一个统一的联盟ID(即联盟AS号)将这些子自治系统组成一个联盟。对联盟外部来说,整个联盟仍然认为是一个AS,且只有联盟的AS号对外可见。在联盟内部,子自治系统内部的BGP Speakers之间仍然建立完全IBGP对等体连接,子自治系统间的BGP Speaker之间建立EBGP连接。虽然在子自治系统的BGP Speakers之间建立的是EBGP连接,但交换信息时,对于NEXT_HOP、MED以及LOCAL_PREF等路径属性信息仍然保持不变。
在大规模的网络中,BGP路由表规模庞大,将会给运行BGP的设备造成较大的负担。BGP支持CIDR(Classless Inter-Domain Routing,无类别域间路由),所以允许创建聚合表项,以减小BGP路由表的大小。只有当聚合范围内存在有效的路径时,软件才将BGP聚合表项添加到BGP路由表中。目前设备支持手动聚合,可以控制是否保留聚合地址范围内路径的AS路径信息以及是否只公告聚合后的路径。
路由在被认为有效和无效之间来回变化时,称为路由振荡。路由振荡常引起不稳定的路由在网络中传播,从而导致网络的不稳定性。BGP路由衰减是一种减少路由振荡的方法,通过监控来自EBGP Peer的路由信息来减少可能的路由振荡。
BGP的路由衰减使用如下术语:
Route Flap(路由振荡):路由在有效和无效之间来回变化。
Penalty(惩罚值):每一次路由振荡,启动路由衰减的BGP Speaker为该路由增加一次惩罚值,该值累计直到超过抑制上限。
Suppress Limit(抑制上限):当路由的惩罚值超过该值时,路由被抑制。
Half-life-time(半衰期):惩罚值减为一半的所经过的时间。
Reuse Limit(重新启用值):当路由的惩罚值低于该值时,路由抑制解除。
Max-suppress-time(最大抑制时间):路由能被抑制的最长时间。
对每一次路由振荡,BGP Speaker对该路由进行一次惩罚(累加到惩罚值中),当惩罚值达到抑制上限,路由将被抑制。在半衰期到达时,惩罚值减为一半。当惩罚值减到重新启用值时,路由重新被激活。路由被抑制的最长时限为最大抑制时间值。
缺省情况下,软件对于路由撤消增加1000惩罚值,对于路由更新增加500惩罚值。
GR(Graceful Restart,优雅重启)是为了实现在协议的重新启动过程中数据转发不间断。在管理板主备切换过程中,GR功能使网络拓扑保持稳定,维持转发表,保障关键业务不中断。
BGP GR不是一个单独的个体过程,由Restarter和Helper两种角色协作完成。
Restarter执行重启,具有在路由控制面出现故障时保持路由转发面继续工作的能力。
Helper为Restarter的BGP邻居,协助Restarter完成优雅重启。
为了实现优雅重,BGP在OPEN消息中增加了一种用来向邻居表示支持GR的能力字段,称为Graceful Restart Capability。在初始化BGP连接时,邻居双方将协商GR能力。
在BGP的Update报文中,新增加EOR(End-of-RIB,路由更新结束标志),用于表明路由信息向邻居更新完毕。
BGP GR交互过程
(1)初始时BGP建立邻居关系,通过OPEN消息中的GR能力字段协商各自的GR能力。
(2)某个时刻,Restarter发生重启,BGP会话断开。Helper检测到连接断开,继续保持Restarter的路由有效,但标记为Stale(老化未更新)。
(3)Restarter完成重启。
(4)与Helper重建连接。
(5)Restarter等待Helper发送路由更新信息以及EOR标志。
(6)Restarter接收到所有邻居的EOR标志后,执行路由计算,更新路由表项,并开始向Helper发送更新路由。
(7)Helper接收到更新路由后,取消这些路由的Stale标志,Helper在接收到Restarter的EOR标志后,删除所有仍标记为Stale的路由(这些路由没有被更新),执行路由计算并更新路由表项。整个GR过程完成。
BGP GR扩展定义了几个重要的定时器:
Restart-Timer
该时间值由GR Restarter通告给GR Helper,表示GR Restarter希望GR Helper在与GR Restarter重新建立连接之前的最长等待时间。用户可以通过命令bgp graceful-restart restart-time修改该时间值。
Wait-For-EOR Timer
GR Restarter等待所有GR Helper的EOR标志的最长时间。在接收到所有GR Helper的EOR标志或者Wait-For-EOR定时器超时后,将执行路由优选计算,更新路由表项。用户可以通过命令bgp update-delay修改该时间值。
StalePath Timer
GR-Helper在恢复与GR Restarter建立连接后,等待接收Restarter的EOR标志的最长时间。在这段时间内Helper将保持Restarter的原始路由有效,在接收到EOR标志或者StalePath定时器结束后,将清除仍然标记为Stale的路由表项。用户可以通过命令bgp graceful-restart stalepath-time修改该时间值。
NSR(None-Stop-Routing,不间断路由)是为了实现管理板主备切换时,在协议的重新启动过程中路由不间断。在主备切换过程中,NSR功能使网络拓扑保持稳定,维持邻居状态,维持转发表,保障关键业务不中断。
不同于BGP GR,BGP NSR不需要邻居设备辅助完成。
主从切换时,BGP邻居间不断开,维持连接状态。
邻居不感知本端的重启行为,重启端恢复过程使用GR技术。
启用BGP NSR功能的邻居,不需要邻居双方协商GR能力,不需要邻居协助,不存在互通性问题。
BMP(BGP Monitor Protocol,BGP监控协议)是一种监控设备上BGP协议运行情况的协议。它关注BGP对等体的状况和对等体表项的接收和发送,以及对等体的各类统计信息。
BGP Speaker会主动向用户指定的BMP server发起TCP连接请求。TCP连接成功后将通告BMP报文给BMP server。BGP Speaker会主动向BMP server发起TCP连接请求,其中目的IP是用户指定的BMP server IP地址,端口号为用户指定的端口号。
正则表达式按照一定的规则来匹配字符串,用来评估文本数据并返回一个真值或假值,判断表达式能否正确的描述该数据。
BGP路径属性中使用的正则表达式,其特殊字符的用法如下表所示。
正则表达式中特殊字符用法
字符 |
符号 |
特殊意义 |
---|---|---|
句号 |
. |
匹配任意单字符 |
星号 |
* |
匹配字符串中的零个或者任意序列 |
加号 |
+ |
匹配字符串中的一个或者任意序列 |
问号 |
? |
匹配字符串中的零个或者一个符号 |
加字号 |
^ |
匹配字符串的开始 |
美元号 |
$ |
匹配字符串的结束 |
下划线 |
_ |
匹配逗号、括号、字符串的开始和结束、空格 |
方括号 |
[ ] |
匹配一定范围中的单个字符 |
RFC 1105:Border Gateway Protocol (BGP)
RFC 1163:Border Gateway Protocol (BGP)
RFC 1267:Border Gateway Protocol 3 (BGP-3)
RFC 1771:A Border Gateway Protocol 4 (BGP-4)
RFC 2918:Route Refresh Capability for BGP-4
RFC 4271:A Border Gateway Protocol 4 (BGP-4)
RFC 4273:Definitions of Managed Objects for BGP-4
RFC 4360:PrBGP Extended Communities Attribute
RFC 4486:Proposed Standard: Subcodes for BGP Cease Notification Message
RFC 4724:Proposed Standard: Graceful Restart Mechanism for BGP
RFC 4760:Draft Standard: Multiprotocol Extensions for BGP-4
RFC 4893:BGP Support for Four-octet AS Number Space
RFC 5396:Textual Representation of Autonomous System (AS) Numbers
RFC 5492:Draft Standard: Capabilities Advertisement with BGP-4
RFC 6198:Requirements for the Graceful Shutdown of BGP Sessions
RFC 7313:Enhanced Route Refresh Capability for BGP-4
RFC 7311:The Accumulated IGP Metric Attribute for BGP
配置BGP基础功能
配置BGP版本
启动BGP协议
配置BGP邻居
(可选)配置BGP IPv6地址族
(可选)配置BGP对等体组
(可选)配置4字节AS号的圆点表达模式
(可选)向BGP注入本地AS的网络信息
(可选)从BGP获知其他AS的可达网络
(可选)配置BGP容量保护
(可选)配置平滑关闭BGP连接
(可选)配置BGP的软复位
(可选)配置Scope配置模式
(可选)配置BGP的路由更新机制
(可选)配置BGP定时器
(可选)配置大规模的BGP网络。以下所有配置任务均为可选配置,请根据实际情况选择。
配置路由反射器
配置AS联盟
配置路由聚合
配置路由衰减
(可选)配置BGP路由选择和负载分担。以下所有配置任务均为可选配置,请根据实际情况选择。
配置BGP多路径负载均衡
配置BGP路由只递归主机路由
配置BGP邻居出方向环路检测
配置BGP ADD-PATH
配置BGP整机重启发布最低优先级路由
配置AS_PATH属性
配置MED属性
配置AIGP属性
配置LOCAL_PREF属性
配置扩展团体属性
配置BGP选则最优路径
(可选)配置BGP控制发布和接收路由。以下所有配置任务均为可选配置,请根据实际情况选择。
配置BGP路由过滤规则
配置BGP路由发送的时间间隔和数量
配置BGP修改发布的路由信息
配置BGP处理接收的路由信息
配置BGP快速撤销指定路由
配置BGP延迟通告路由信息
(可选)配置BGP安全功能。以下所有配置任务均为可选配置,请根据实际情况选择。
配置MD5认证
配置BGP邻居GTSM安全检查
配置BGP Keychain认证
(可选)配置BGP可靠性。以下所有配置任务均为可选配置,请根据实际情况选择。
配置BFD For BGP
配置BGP GR
配置BGP NSR
配置BGP会话保持
配置EBGP邻居快速检测
配置BGP关联链路状态组
(可选)配置BGP拓展功能。以下所有配置任务均为可选配置,请根据实际情况选择。
配置BMP监控
配置BGP的管理距离
BGP基础功能配置任务如下:
配置BGP版本
启动BGP协议
配置BGP邻居
(可选)配置BGP IPv6地址族
(可选)配置BGP对等体组
(可选)配置4字节AS号的圆点表达模式
(可选)向BGP注入本地AS的网络信息
(可选)从BGP获知其他AS的可达网络
(可选)配置BGP容量保护
(可选)配置平滑关闭BGP连接
(可选)配置BGP的软复位
(可选)配置Scope配置模式
(可选)配置BGP的路由更新机制
(可选)配置BGP定时器
TCP连接建立成功后,BGP Speaker会互相交互OPEN报文,协商BGP连接参数,包括BGP版本。目前仅支持BGP 4。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置指定BGP对等体使用的BGP协议版本号。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } version 4
在配置BGP功能前,需要开启BGP协议并配置本自治系统号。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
(可选)配置运行BGP协议时使用的设备ID。
bgp router-id ipv4-address
缺省情况下,设备ID首选该设备的环回接口,如果不存在环回接口则选用该设备的Router-ID。
(可选)配置缺省地址族为IPv4单播地址族。
bgp default ipv4-unicast
缺省情况下,缺省地址族为IPv4单播地址族。
(可选)配置设备在不开启Debug功能的情况下记录BGP的状态变化信息。
bgp log-neighbor-changes
缺省情况下,设备在不开启Debug功能的情况下记录BGP的状态变化信息。
(可选)关闭BGP的TCP源地址检查功能。
bgp tcp-source-check disable
缺省情况下,TCP源地址检查功能处于开启状态。
配置BGP Speaker成为邻居。
IBGP邻居如果非直连,需要配置IGP或静态路由协议实现邻居之间路由可达。
EBGP邻居如果非直连,需要配置邻居ebgp-multihop参数。
指定建立邻居的源接口必须是本地有效的接口或IP地址。
使用命令exit-address-family退出BGP的地址族配置模式。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
(可选)用来配置BGP邻居超限告警。
bgp maximum-neighbor maximum-neighbor-numbers warning-only
缺省情况下,未配置邻居超限告警。
(可选)开启邻居地址族能力检测功能。
bgp notify unsupport-capability
缺省情况下,邻居地址族能力检测功能处于关闭状态。
(可选)进入到相应的地址族配置模式,如有需要针对某一类地址族进行配置,请选择其中一项进行配置。
进入IPv4 Unicast配置模式。
address-family ipv4 [ unicast ]
进入IPv4 VRF配置模式。
address-family ipv4 vrf vrf-name
进入IPv6 Unicast配置模式。
address-family ipv6 [ unicast ]
进入IPv6 VRF配置模式。
address-family ipv6 vrf vrf-name
创建BGP邻居。当配置的AS号与本地AS号相同,则建立IBGP邻居;当配置的AS号与本地AS号不同,则建立EBGP邻居。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } remote-as as-number
缺省情况下,BGP Speaker未指定任何邻居。
(可选)配置指定对等体(组)的描述性语句。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } description text
缺省情况下,未配置指定对等体(组)的描述性语句。
(可选)创建与邻居进行TCP连接的源接口或IP地址。IBGP邻居间推荐使用环回接口,EBGP邻居间推荐使用直连接口。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } update-source { interface-type interface-number | address }
缺省情况下,BGP将根据邻居的IP地址自动选择TCP连接的源IP,一般采用本地报文出接口的IP地址。
(可选)设置邻居TCP报文TTL(Time To Live,生存时间)。TTL值越大,则支持到邻居的间隔跳数越大。当TTL为1时,要求BGP邻居设备必须直接相连。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } ebgp-multihop [ ttl ]
缺省情况下,IBGP邻居的TCP报文TTL为255,EBGP邻居为1。
(可选)配置BGP发起邻居建立TCP连接的模式。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } transport connection-mode { active-only | both | passive-only }
缺省情况下,BGP邻居同时支持主动及被动方式建立TCP连接。
(可选)激活邻居地址族能力。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } activate
缺省情况下,在BGP配置模式下创建的邻居只激活了IPv4 Unicast地址族能力。
配置BGP协议交互IPv6路由,实现跨AS域的IPv6网络互访。
一般情况,BGP需要采用IPv6地址建立邻居,来实现IPv6路由交互。
使用IPv6链路本地地址与邻居建立对等体连接时,地址的表述形式为Linklocal地址%接口名,例如FE80::1%GigabitEthernet0/1。
特殊场景下,例如6PE(IPv6 Provider Edge Router,IPv6供应商边缘路由器)功能,BGP同样支持在IPv4地址的邻居上交互IPv6路由。
基于BGP IPv6业务相关的配置,都需要在BGP IPv6地址族模式下配置。
IPv6地址的邻居用来交互IPv6路由,但在BGP模式下配置邻居时,会自动激活邻居IPv4 Unicast地址族能力,因此建议用户手动关闭IPv4 Unicast地址族能力。
使用命令exit-address-family退出BGP的地址族配置模式。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
创建BGP邻居。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } remote-as as-number
配置BGP IPv4地址族模式。
address-family ipv4 unicast
创建关闭BGP邻居IPv4地址族能力。
no neighbor { neighbor-ipv4-address | peer-group-name } activate
缺省情况下,IPv4地址族能力处于开启状态。
配置BGP IPv6地址族模式。
address-family ipv6 unicast
创建BGP邻居IPv6地址族能力。
neighbor { neighbor-ipv6-address | peer-group-name } activate
缺省情况下,IPv6地址族能力处于关闭状态。
(可选)配置BGP通告IPv6路由。
network network-ipv6-address/prefix-length [ route-map route-map-name ] [ backdoor ]
缺省情况下,BGP协议未配置网段路由信息。
(可选)配置在向BGP IPv6链路本地对等体(组)发送IPv6路由信息时使用链路本地地址填充全局地址下一跳。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } global-nexthop-replace-local
缺省情况下,向BGP IPv6链路本地地址对等体(组)发送IPv6路由信息时不使用链路本地地址填充全局地址下一跳。
同一对等体组内的BGP Speaker具有相同的更新策略,从而简化配置,提高运行效率。
对等体组的成员继承对等体组的所有配置。允许对等体组的每个成员单独配置从而取代对等体组的统一配置,但这些单独配置的信息不包含影响输出更新的配置信息(例如neighbor distribute-list、neighbor route-map和neighbor filter-list)。
不能将不同地址族的邻居放入同一个对等体组中,也不能将IBGP和EBGP放入同一个对等体组中。
使用命令exit-address-family退出BGP的地址族配置模式。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
(可选)进入到相应的地址族配置模式,如有需要针对某一类地址族进行配置,请选择其中一项进行配置。
进入IPv4 Unicast配置模式。
address-family ipv4 [ unicast ]
进入IPv4 VRF配置模式。
address-family ipv4 vrf vrf-name
进入IPv6 Unicast配置模式。
address-family ipv6 [ unicast ]
进入IPv6 VRF配置模式。
address-family ipv6 vrf vrf-name
创建对等体组。
neighbor peer-group-name peer-group
配置指定BGP Speaker为BGP对等体组的成员。
neighbor neighbor-ipv4-address | neighbor-ipv6-address peer-group peer-group-name
配置支持4字节AS号的设备使用圆点模式表达。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置BGP 4字节AS使用圆点模式显示方式。
BGP不会自动发现或学习可达网络,需要将本地AS的可达网络信息注入BGP,之后BGP才能将这些信息发布给邻居。
有两种方式可以向BGP注入本地AS的网络信息:
手动静态配置:将指定范围内的可达网络信息注入BGP。
配置路由重分发:将IGP协议的可达网络信息重分发注入BGP。
网络信息同步功能建议保持开启状态,关闭后可能造成路由黑洞。
使用命令exit-address-family退出BGP的地址族配置模式。
进入特权模式。
enable
进入全局配置模式。
configure terminal
router bgp redistribute [ vrf vrf-name ] address-family { ipv4 unicast | ipv6 unicast } protocol-type [ metric metric-value | route-map-name map-tag ] *
缺省情况下,未配置重分发其它路由协议的路由信息到所有BGP实例。
启动BGP协议,进入BGP配置模式。
router bgp as-number
bgp redistribute unspecified instance ignore
缺省情况下,BGP实例应用非指定实例重分发。
(可选)进入到相应的地址族配置模式,如有需要针对某一类地址族进行配置,请选择其中一项进行配置。
进入IPv4 Unicast配置模式。
address-family ipv4 [ unicast ]
进入IPv4 VRF配置模式。
address-family ipv4 vrf vrf-name
进入IPv6 Unicast配置模式。
address-family ipv6 [ unicast ]
进入IPv6 VRF配置模式。
address-family ipv6 vrf vrf-name
配置路由表项以静态方式加入BGP路由表并通告给对等体。
network network-number [ mask mask ] [ route-map route-map-name ] [ backdoor ]
缺省情况下,未配置路由表项以静态方式加入BGP路由表并通告给对等体。
(可选)配置设备在和本地路由同步后才通告network命令配置的路由信息。
network synchronization
缺省情况下,设备在和本地路由同步后才会通告network命令配置的路由信息。
配置路由重分发。以下所有配置命令均为可选配置,请根据实际情况选择。
redistribute protocol-type [ metric metric-value | route-map map-tag ] *
缺省情况下,未配置重分发其它路由协议的路由信息到BGP实例中。
配置重分发IS-IS路由协议的路由信息到BGP实例中。
redistribute isis [ isis-tag ] [ { level-1 | level-1-2 | level-2 } | metric metric-value | route-map map-tag ] *
缺省情况下,未配置重分发IS-IS路由协议的路由信息到BGP实例中。
配置重分发OSPF路由协议的路由信息到BGP实例中。
redistribute ospf process-id [ match { { external | { external 1 | external 2 }* } | internal | { nssa-external | { nssa-external 1 | nssa-external 2 } * } } * | metric metric-value | route-map map-tag ] *
缺省情况下,未配置重分发OSPF路由协议的路由信息到BGP实例中。
配置开启将其他协议的多个下一跳路由注入到BGP协议中。
bgp sourced-paths protocol-type all
缺省情况下,多个下一跳注入功能处于关闭状态。
(可选)配置BGP中重分发路由时使用手动配置的Metric值。
default-metric metric-value
缺省情况下,BGP重分发路由时采用路由自带的Metric值。
将BGP获取的其他AS的路由信息下发到本设备的路由表后,本设备就能够转发发往其他AS的报文。
将BGP获取的其他AS的路由信息注入到IGP中,通过IGP通告本地AS的其他设备,这些设备就能够转发发往其他AS的报文。
通常情况下,互为IBGP邻居的BGP Speaker物理上并不直接相连,间隔在中间的IGP协议设备可能会学习不到与BGP Speaker相同的路由信息。当AS域边界BGP Speaker将从其他域接收到的数据报文,转发给下一跳IBGP邻居时,报文将经过中间的IGP协议设备,此时就可能因IGP设备上没有路由而丢包。BGP和IGP的同步是为了防止这种路由黑洞现象。如果要求BGP和IGP保持同步,那么对于将被发往另一个AS的路由信息,必须保证本AS内所有的路由设备都学习到该路由信息时,才能将该路由信息发布到另一个AS。
在以下两种情况下,用户可以取消同步机制以保证路由信息的快速收敛:
不存在穿越本AS的路由信息(一般情况下此AS是一个末梢AS);
本AS内所有的路由器都运行BGP协议,所有的BGP Speaker之间建立全连接关系(BGP Speaker两两建立邻接关系)。
配置路由图。关于配置路由图的详细介绍,请参见“路由策略”。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
控制BGP下发到核心路由表的路由信息。
table-map route-map-name
缺省情况下,BGP不修改所有下发到核心路由表的路由信息的属性。
配置BGP允许将从IBGP邻居收到的路由重分发给IGP协议。
bgp redistribute-internal
缺省情况下,BGP允许将从IBGP邻居收到的路由重分发给IGP协议。
(可选)开启BGP和IGP路由信息同步功能。
synchronization
缺省情况下,BGP和IGP路由信息同步功能处于关闭状态。
(可选)配置BGP向外发布重分发的默认路由。
default-information originate
缺省情况下,BGP不会向外发布重分发的默认路由。
BGP路由数量条目数往往较多,容易造成设备容量过载,特别是对于内存配置较低的设备,容量问题更为突出。对BGP容量进行保护可以避免设备由于整体资源过度消耗进入非预见性状态。对BGP的容量保护包括两个部分:
限制BGP路由条目数量
限制BGP路由条目可以通过限制BGP地址族下最大路由条目数和BGP邻居的最大学习路由条目数实现。
内存不足进入OVERFLOW状态
BGP进入OVERFLOW状态后将会丢弃新学到的路由,该行为能够有效保证内存不再增长。如果BGP地址族进入OVERFLOW状态,由于丢弃了新学到的路由,可能会引起整网出现路由环路现象。为了降低这种现象出现的概率,BGP会生成一条指向NULL接口的默认路由,该路由在OVERFLOW状态下将一直存在。
对于新学习的路由,若该路由不是当前路由表中的某条非默认路由的精细路由,则系统将丢弃该路由,使内存能够维持在一个相对稳定的状态。系统选择性地丢弃路由是为了保证整体网络不出现路由环路现象。BGP进入OVERFLOW状态是相对安全的。
可以使用clear bgp { addressfamily | all }命令复位BGP会话,清除BGP地址族OVERFLOW状态。
如果配置了no overflow memory-lack命令,BGP在内存不足时将不会进入OVERFLOW状态,可能会造成内存资源继续消耗。当内存消耗超过软件允许的范围时,BGP将断开所有邻居,并删除所有学到的路由。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置BGP在内存不足时进入OVERFLOW状态。
overflow memory-lack
缺省情况下,BGP在内存不足时将会进入OVERFLOW状态。
开启BGP全局或指定VRF路由条目限制功能。
bgp maximum-prefix maximum-prefix-numbers [ vrf vrf-name ]
缺省情况下,BGP全局或指定VRF路由条目限制功能处于关闭状态。
配置从指定BGP对等体接收前缀数目的限制。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } maximum-prefix maximum-prefix-value [ maximum-prefixthreshold ] [ restart-time restart-time | warning-only [ suppress ] ]
缺省情况下,未配置从指定BGP对等体接收前缀数目的限制。
进入到相应的地址族配置模式,请选择其中一项进行配置。
进入IPv4 Unicast配置模式。
address-family ipv4 [ unicast ]
进入IPv4 VRF配置模式。
address-family ipv4 vrf vrf-name
进入IPv6 Unicast配置模式。
address-family ipv6 [ unicast ]
进入IPv6 VRF配置模式。
address-family ipv6 vrf vrf-name
配置地址族下路由信息库前缀的最大条目数限制。
maximum-prefix maximum-prefix-number
缺省情况下,不限制地址族下路由信息库的前缀的最大条目数。
在网络中,用户对设备进行隔离升级等类似操作时,由RFC 6198定义了一种BGP连接平滑关闭的功能,要求BGP邻居在业务不断流或断流时间极短的前提下关闭连接。
本特性采用“Make-Before-Break”的方式来进行BGP连接关闭,从而来保证在此期间业务不断流或者断流时间极少。其步骤如下:
向邻居设备通告优先级最低的路由(LOCAL_PREF属性值为0或MED属性值为4294967295),并且携带知名的Gshut Community,使邻居设备进行路由更新,其流量预先切换到备份链路或其他等价链路上。
在延迟一定时间之后,断开与邻居设备间的BGP连接。
其断开BGP连接的延迟时间可手工指定或自动计算。自动计算是以每秒1K条路由的时间标准进行延迟。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置平滑关闭BGP实例下的所有连接。
bgp shutdown graceful [ community community-value ] [ delay delay-time ]
缺省情况下,未关闭BGP实例下所有连接。
创建BGP邻居。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } remote-as as-number
配置平滑关闭BGP邻居的连接。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } shutdown graceful [ community value ] [ delay time ]
缺省情况下,BGP邻居的连接未关闭。
只要路由策略(包括neighbor distribute-list、neighbor route-map、neighbor prefix-list和neighbor filter-list)发生改变,就必须提供有效的方法使得新的路由策略能够实施。传统的方法是通过配置BGP的软复位,在不关闭BGP会话连接的情况下,使新的路由策略得以实施。当输出路由策略发生变化时,BGP软复位会将本BGP Speaker的所有路由信息重新向邻居通告。
如果输入路由策略发生变化,其操作将比输出路由策略变化更复杂。这是因为输出路由策略实施在本BGP Speaker的路由信息表上,输入路由策略是实施在从BGP Peer接收来的路由信息上,出于节约内存考虑,本地BGP Speaker并不保留原始的从BGP Peer接收来的路由信息。如果确实修改了输入路由策略,并且邻居设备支持路由刷新功能,可通过配置软复位向邻居发送路由刷新请求。邻居设备接收到请求后会重新通告所有路由信息;或者配置为指定的每个BGP对等体在本BGP Speaker上保存一份原始的路由信息,为随后修改输入路由策略提供原始路由信息依据。
进入特权模式。
enable
clear bgp ipv4 unicast [ vrf vrf-name ] { * | as-number | neighbor-ipv4-address | neighbor-ipv6-address } soft ]out
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } soft-reconfiguration inbound
缺省情况下,不保存指定BGP对等体发来的原始路由信息。
通过配置Scope配置模式,可以基于VRF对BGP进行配置。在Scope配置模式下配置的命令仅在对应的VRF生效。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置进入Scope配置模式,将VRF关联到BGP。
scope vrf vrf-name
BGP有两种路由更新机制:定时扫描更新和事件触发更新。
定时扫描更新
BGP内部使用定时器定时启动扫描机制,更新路由表。
事件触发更新
当用户配置BGP导致BGP配置命令发生变化,或者BGP路由的下一跳发生变化时,触发BGP启动扫描机制,更新路由表。
BGP下一跳触发更新功能是一种降低BGP收敛时间的方法。该功能对路由的下一跳监控的方式进行优化,使BGP在网络拓扑稳定的情况下路由的收敛速度加快。当BGP和邻居建立连接之后,会自动监控从邻居学来的路由下一跳。当下一跳在核心路由表中发生变化时,BGP会收到下一跳变化的通告,更新BGP路由表。这种优化措施通过减少下一跳变化的检测时间,提升BGP路由的收敛性能。
本功能是基于地址族配置的,可以在IPv4/IPv6/IPv4 VRF/IPv6 VRF地址族模式下配置本功能。
当配置BGP路由更新机制为事件触发机制时,要求关闭同步开关(配置no synchronization命令)并开启BGP下一跳触发更新功能。
bgp nexthop trigger delay命令和bgp scan-time命令控制同一个定时器,所以当BGP路由更新机制为定时扫描更新时,如果配置bgp nexthop trigger delay命令时指定的时间大于60秒,该命令将不起作用,原因是扫描定时器总是在下一跳触发更新的延时时间之前触发。
在网络不稳定的情况下,特别是存在大量路由的环境中,下一跳信息频繁变化,配置BGP下一跳触发更新功能会导致不必要的路由计算,加剧CPU资源的消耗。因此在这种环境下,建议关闭此功能。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置BGP协议定时扫描的时间间隔。
bgp scan-time scan-time
BGP协议定时扫描的时间间隔为60秒。
(可选)进入到相应的地址族配置模式,如有需要针对某一类地址族进行配置,请选择其中一项进行配置。
进入IPv4 Unicast配置模式。
address-family ipv4 [ unicast ]
进入IPv4 VRF配置模式。
address-family ipv4 vrf vrf-name
进入IPv6 Unicast配置模式。
address-family ipv6 [ unicast ]
进入IPv6 VRF配置模式。
address-family ipv6 vrf vrf-name
配置BGP的路由更新机制为事件触发更新。请依次执行以下命令。
bgp scan-rib disable
缺省情况下,BGP协议使用定时扫描的方式更新路由表。
开启下一跳触发更新功能。
bgp nexthop trigger enable
缺省情况下,下一跳地址跟踪功能处于开启状态。
bgp nexthop trigger delay delay-time
缺省情况下,BGP路由在下一跳变化时更新路由表的延时为5秒。
通过手动配置BGP协议内部的定时器,可以灵活应对不同网络环境下的邻居保活需求。
Holdtime和Keepalive定时器
BGP使用Keepalive定时器来维持和对等体的有效连接,使用Holdtime定时器来判断对等体是否有效。当BGP对等体之间建立BGP连接时,双方将对Holdtime进行协商,将会选择其中更小的Holdtime值。而Keepalive定时器值将为协商后的Holdtime的1/3和配置的Keepalive的值中的较小者。
邻居重连定时器
为降低BGP频繁尝试与连接失败的邻居进行重连对网络带宽的影响,BGP对等体检测到与邻居建立连接失败之后,将启动一个邻居重连定时器,在时器到期之后再尝试进行重连。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置BGP定时器时长。
timers bgp keepalive-time holetime [ minimum-holdtime ]
缺省情况下,BGP发送Keepalive消息的时间间隔为60秒,保持时间为180秒,不限制邻居通告的最小Hold-time。
配置与指定BGP对等体建立BGP连接时使用的Keepalive、Hold-Time和Connect-Retry定时器的时长。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } timers { keepalive-interval holdtime [ minimum-holdtime ] | connect connect-retry }
缺省情况下,与BGP对等体建立BGP连接时,Keepalive定时器时长为60秒,Hold-Time定时器时长为180秒,Connect-Retry定时器时长为15秒。
bgp timer accuracy-control
缺省情况下,BGP内部定时器严格执行功能处于关闭状态。
大规模的BGP网络配置任务如下。所有配置任务均为可选配置,请根据实际情况选择。
配置路由反射器
配置AS联盟
配置路由聚合
配置路由衰减
配置IBGP环境下的路由反射器,实现在客户机之间反射路由信息以减少BGP邻居连接数量。
如果在某个地址族下进行配置,反射器只在该地址族下生效,将不会被其他地址族所继承。
为了配置方便,只需要对作为反射器的设备进行配置,客户机设备并不需要配置本端成为客户机。
当一个AS域内部署了多个反射群时,必须为这些反射群设定不同的反射群标识符。
使用命令exit-address-family退出BGP的地址族配置模式。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
创建BGP邻居。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } remote-as as-number
配置本端为路由反射器,对应的BGP邻居为路由反射客户端。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } route-reflector-client
(可选)开启设备的客户端之间路由反射功能。
bgp client-to-client reflection
缺省情况下,客户端之间路由反射功能处于开启状态。
(可选)设置BGP反射群标识符。
bgp cluster-id cluster-id
缺省情况下,BGP反射群标识符直接继承BGP的Router-ID。
bgp route-reflector attribute-change
缺省情况下,不允许路由反射器修改路由属性。
根据RFC 4456规范,为防止出现路由环路,BGP路由反射器在反射路由时不能修改路由属性,但当用户对网络流量路径重新进行规划时,就会需要更改相关路由属性。用户可以配置命令实现在路由反射器上修改路由属性(包含Route-map和Nexthop-self)。
在大型BGP组网中,配置BGP联盟可以将AS分割为多个子自治系统,有效减少IBGP邻居连接数量,从而让AS变得更具管理性。
联盟内部的子AS(Member AS)建议采用私有AS号,私有AS号范围为64512~65535。
联盟子AS内部,各BGP Speaker必须保证全连接,也可在子AS内部进一步配置路由反射器代替。
联盟子AS之间要建立EBGP邻居关系。
联盟中的所有BGP Speaker都必须与联盟的某一个子AS相关联。
BGP联盟成员必须配置与本地建立联盟EBGP关系的所有成员AS。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置BGP联盟ID,BGP本地设定的AS(通过router bgp as-number命令指定的AS)变为该联盟内部的私有AS,对其他AS域不可见。
bgp confederation identifier as-number
缺省情况下,BGP Speaker未设置联盟ID。
配置BGP联盟成员,指定的AS和本地AS就属于同一个联盟。
bgp confederation peers as-number&<1-n>
缺省情况下,BGP未设置联盟成员。
将一条或多条精细的BGP路由,聚合成一条网络掩码长度较短的BGP路由。
缺省情况下BGP同时公告聚合前后的所有路径信息。如果用户只希望公告聚合后的路径信息,请配置aggregate-address summary-only命令。
通过配置命令aggregate-address聚合路由时,只要有路由落入配置的地址范围内,这条聚合路由就立即生效。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置BGP的聚合路由表项。
aggregate-address { ipv4-address mask | prefix } [ advertise-map route-map-name | as-set | attribute-map route-map-name | summary-only | suppress-map route-map-name ] *
缺省情况下,未配置BGP的聚合路由表项。
BGP路由衰减是一种减少路由振荡的方法,通过监控来自EBGP对等体的路由信息来减少可能的路由振荡。对每一次路由振荡,BGP Speaker对该路由进行一次惩罚(累加到惩罚值中),当惩罚值达到抑制上限,路由将被抑制。在半衰期到达时,惩罚值减为一半,当惩罚值减到重新启用值时,路由重新被激活。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
开启路由衰减功能并设置衰减参数。
bgp dampening [ half-life [ reusing suppressing maximun-supress-time ] [ withdrawal-ignore ] | route-map route-map-name ]
缺省情况下,路由衰减功能处于关闭状态。
BGP路由选择和负载分担配置任务如下。所有配置任务均为可选配置,请根据实际情况选择。
配置BGP多路径负载均衡
配置BGP路由只递归主机路由
配置BGP邻居出方向环路检测
配置BGP ADD-PATH
配置BGP整机重启发布最低优先级路由
配置AS_PATH属性
配置MED属性
配置AIGP属性
配置LOCAL_PREF属性
配置扩展团体属性
配置BGP选则最优路径
实现IBGP路由多路径负载均衡。
从IBGP邻居学习到的路由,必须优先级相同(不比较Router-ID)。
不支持IBGP路由与EBGP路由形成等价路由。
所有下一跳都必须携带有Link-Bandwidth属性才会生成非等价路由,否则不会形成非等价负载均衡。
向IBGP邻居发送Link bandwidth扩展团体属性时,需要先开启发送扩展团体属性功能。
指定邻居的路由发给IBGP邻居时携带Link bandwidth属性的功能只对单跳EBGP邻居生效。
使用命令exit-address-family退出BGP的地址族配置模式。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
(可选)进入到相应的地址族配置模式,如有需要针对某一类地址族进行配置,请选择其中一项进行配置。
进入IPv4 Unicast配置模式。
address-family ipv4 [ unicast ]
进入IPv4 VRF配置模式。
address-family ipv4 vrf vrf-name
进入IPv6 Unicast配置模式。
address-family ipv6 [ unicast ]
进入IPv6 VRF配置模式。
address-family ipv6 vrf vrf-name
创建BGP邻居。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } remote-as as-number
配置BGP负载均衡,对于联盟EBGP多路径及本地VRF互导路由等价,可使用maximum-paths ebgp进行配置。
maximum-paths { ebgp | ibgp } maximum-paths-number
缺省情况下,BGP负载均衡处于关闭状态。
(可选)配置开启发送扩展团体属性功能,以保证将Link bandwidth扩展团体属性在邻居间的传递。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } send-community [ both | standard | extended ]
缺省情况下,在IPv4 Unicast/VRF、IPv6 Unicast/VRF地址族不会同时配置向此BGP邻居通告团体属性。
(可选)开启非等价负载均衡功能,根据Link bandwidth扩展团体属性来生成非等价路由。
bgp dmzlink-bw
缺省情况下,非等价负载均衡处于关闭状态。
(可选)开启指定邻居的路由发给IBGP邻居时携带Link bandwidth属性的功能。
neighbor { peer-address | peer-group-name } dmzlink-bw
缺省情况下,对指定邻居的路由中携带Link bandwidth属性功能处于关闭状态。
BGP路由默认采用最优匹配的方式进行路由递归,可能递归到默认路由或错误的网段路由,造成出口或下一跳错误。当开启BGP路由只递归主机路由功能后,BGP路由只递归到32位IPv4主机路由或128位IPv6主机路由上。该功能应用于使用Loopback接口建立的IBGP或多跳EBGP邻居学习到的路由。
当开启BGP路由只递归主机路由功能后,IBGP或多跳EBGP的路由将会以精确匹配的方式查询下一跳地址的有效性,并且IBGP或多跳EBGP路由在安装到FIB(Forward Information dataBase,转发信息库)时将会以精确匹配的方向进行路由递归。例如192.168.2.0/24的IBGP路由,其下一跳为1.1.1.1,则只有当1.1.1.1/32的路由存在时,192.168.2.0/24 IBGP路由的下一跳地址才是合法有效的,并且安装到FIB的路由出口为1.1.1.1/32路由对应的出口。
此功能仅对IBGP或多跳EBGP生效,对于直连EBGP路由或路由下一跳为直连地址,此功能无效。
设备所建立的IBGP或多跳EBGP邻居需要使用环回口地址来创建,否则不能开启此功能。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置BGP路由只递归主机路由。
bgp recursion host
缺省情况下,BGP路由以最优匹配的方式进行递归。
在从邻居接收路由时,BGP协议默认对BGP路由进行环路检测。如果BGP路由携带的AS Path属性中带有本地AS,则会过滤此BGP路由。邻居出方向环路检测功能,是在向邻居发送路由过程中提前对路由进行环路检测,过滤掉环路的路由。
当需要向EBGP邻居发送路由时,预先判断BGP路由所携带的AS Path属性中是否存在邻居的AS号。如果已经存在,则说明此路由已经环路,不会向此EBGP邻居发送路由。
此功能只对于EBGP邻居有效。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
创建BGP邻居。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } remote-as as-number
配置BGP邻居出方向环路检测。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } as-loop-check out
缺省情况下,邻居未开启出方向环路检测功能。
BGP ADD-PATH(Additional Paths,附加路径)属性用于实现从一个IBGP邻居接收多个相同前缀的路由。缺省情况下,当BGP从同一对等体接收到相同前缀的路由时,会用最新的路由信息替换掉之前收到的路由信息,即把从同一个邻居接收到的相同前缀的路由都认为是同一个表项。引入BGP ADD-PATH功能后,BGP会为ADD-PATH邻居发布的路由增加一个Path-id的字段。设备通过判断路由信息前缀、邻居Path-id来确定是否属于同一个路由。当接收到的路由属于不同路由时,添加到新的表项中,从而获取到了同一邻居相同前缀的多个路由。
通过配置bgp additional-paths select选择特定类型的ADD-PATH备选路由。当选择的ADD-PATH备选路由类型同需要发布的ADD-PATH备选路由类型不一致时,不发布ADD-PATH备选路由,只发布最优路由。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
开启ADD-PATH备选路由优选功能。
bgp additional-paths select { all | best number | ecmp }
创建BGP邻居。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } remote-as as-number
缺省情况下,ADD-PATH功能处于关闭状态。设置向对等体发布ADD-PATH备选路由,设置当ADD-PATH协商成功的情况下向对等体发布特定类型的ADD-PATH备选路由。
neighbor { peer-address | peer-group-name } advertise additional-paths { all | best number | ecmp }
缺省情况下,BGP不向邻居发布ADD-PATH备选路由。
开启指定对等体ADD-PATH能力。
neighbor { peer-address | peer-group-name } additional-paths { send [receive] | receive }
缺省情况下,指定对等体ADD-PATH能力处于关闭状态。
默认情况下,整机重启邻居建立后,BGP对等体就可以通告路由给邻居。但在某些情况下,比如启机时存在大量邻居或大量路由,由于硬件写入表项慢,此时存在邻居已经学完路由开始转发流量时,本端却还没有完成硬件表项的写入,造成流量转发不通。因此在整机重启之后将BGP向外发布的路由调整为最低优先级,使得在有其他路由的情况下不优选经过本端的路由。
BGP整机重启发布最低优先级路由使得在整机重启邻居建立起来后,向邻居通告最低优先级的路由。对于EBGP邻居来说,路由的MED值调整为4294967295。对于IBGP邻居来说,路由的LOCAL_PREF值调整为0。当确认ARP表项已下发完成及硬件转发表项安装完成后,可以通过配置clear bgp advertise lowest-priority on-startup恢复发布路由的优先级。如果用户未显示配置恢复发布路由的优先级,在一定时间之后,设备将自动恢复发布路由的优先级。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
bgp advertise lowest-priority on-startup [ recover-time ]
缺省情况下,BGP不修改发布路由的优先级。
AS_PATH反向列出了路由先后经过的自治系统。通过配置不同的AS_PATH属性可以实现灵活的路由选择。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
(可选)进入到相应的地址族配置模式,如有需要针对某一类地址族进行配置,请选择其中一项进行配置。
进入IPv4 Unicast配置模式。
address-family ipv4 [ unicast ]
进入IPv4 VRF配置模式。
address-family ipv4 vrf vrf-name
进入IPv6 Unicast配置模式。
address-family ipv6 [ unicast ]
进入IPv6 VRF配置模式。
address-family ipv6 vrf vrf-name
创建BGP邻居。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } remote-as as-number
(可选)配置设备检查UPDATE报文的AS_PATH路径段第一个AS编号。
bgp enforce-first-as
缺省情况下,设备检查UPDATE报文的AS_PATH路径段第一个AS编号。
(可选)配置BGP路由对AS_PATH属性中的AS号个数的限制。
bgp maxas-limit maxas-limit-number
缺省情况下,不限制路由AS_PATH属性的AS个数。
(可选)配置BGP邻居Local AS。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } local-as as-number [ no-prepend [ replace-as [ dual-as ] ] ]
缺省情况下,没有为任何对等体配置Local AS,对等体的本地AS为BGP的真实AS。
当本地BGP真实AS发生变化时,不需要改变对等体设备的BGP配置,即可实现BGP连接的建立。该功能用于大型网络的AS迁移及合并,可以保证不影响其他互联AS中设备的配置。
(可选)配置删除发往指定的EBGP对等体的路由的AS路径属性中记录的私有AS号。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } remove-private-as [ force [ ignore-remote-as ] ] [ replace-as ]
缺省情况下,未配置删除发往指定的EBGP对等体的路由的AS路径属性中记录的私有AS号。
MED属性用于判断流量进入AS时的最佳路由。当BGP Speaker通过不同EBGP对等体得到多条目的地址相同但下一跳不同的路由时,如果其它条件都相同,则软件在选择最优路由时将优先选择MED值较小的路由。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
开启BGP总是比较MED的功能。
bgp always-compare-med
缺省情况下,总是比较MED功能处于关闭状态。
(可选)配置来自相同AS的对等体的路径优先比较MED值。
bgp deterministic-med
缺省情况下,未配置来自相同AS的对等体的路径优先比较MED值。
AIGP属性能够累加路由所经过路径的IGP Metric。BGP使用AIGP属性值进行路由优选,AIGP属性值越小,则路由优先级越高。
缺省情况下,BGP路由不携带AIGP属性。可通过配置路由图的set aigp-metric命令为路由设置AIGP属性。
对匹配Match规则的路由指定AIGP权重属性。详情请参见“路由策略”。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
开启BGP邻居的AIGP功能。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } aigp [ send med ]
缺省情况下,BGP邻居的AIGP功能处于关闭状态。
BGP Speaker将从EBGP对等体接收到的路由发送给IBGP对等体时,将会添加LOCAL_PREF属性。BGP在选取最优路径时会比较LOCAL_PREF,LOCAL_PREF值越大则优先级越高。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置缺省的LOCAL_PREF属性值。
bgp default local-preference local-preference-value
缺省情况下,LOCAL_PREF值为100。
扩展团体属性是BGP团体属性针对某些特定业务的扩展。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置BGP向EBGP邻居通告路由时允许附加非传输扩展团体属性。
bgp advertise non-transitive extcommunity
缺省情况下,BGP向EBGP邻居通告路由时不携带非传输扩展团体属性。
BGP选则最优路径时,需要比较部分路由属性。通过配置命令可以控制软件比较路由属性时的策略。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
以下均为可选步骤,请根据实际情况选择配置。
配置选举最优路径时不比较AIGP Metric值。
bgp bestpath aigp ignore
缺省情况下,选择最优路径时比较AIGP Metric值。
配置选举最优路径时不比较AS路径的长度。
bgp bestpath as-path ignore
缺省情况下,选择最优路径时比较AS路径长度。
配置BGP多路径负载的AS_PATH宽松比较。
bgp bestpath as-path multipath-relax
缺省情况下,未配置BGP多路径负载的AS_PATH宽松比较。
配置选举最优路径时允许比较联盟的AS_PATH路径长度。
bgp bestpath compare-confed-aspath
缺省情况下,选择最优路径时不比较来自同一个联盟内部EBGP路由的AS_PATH,而是根据其他条件来进行路由优选。
配置选举最优路径时比较路径的Router ID。
bgp bestpath compare-routerid
缺省情况下,选择最优路径时,如果两条从不同EBGP对端设备接收的路径所有路径属性都相同,则认为先收到的路径为最优路径。
配置选举最优路径时不比较下一跳的IGP Metric值。
bgp bestpath igp-metric ignore
缺省情况下,选择最优路径时比较下一跳IGP Metric值。
配置选举最优路径时比较来自AS联盟内部对等体的路径的MED。
bgp bestpath med confed [ missing-as-worst ]
缺省情况下,选举最优路径时不比较AS联盟内部对等体的路径的MED值。
配置选举最优路径时将没有设置MED属性的路径的优先级设置为最低。
bgp bestpath med missing-as-worst
缺省情况下,选举最优路径时将没有设置MED属性的路径的优先级设置为最高。
开启BGP多路径负载的Router ID比较功能。
bgp bestpath multipath-compare-routerid
缺省情况下,BGP多路径负载的Router ID比较功能处于关闭状态。
BGP控制发布和接受路由配置任务如下。所有配置任务均为可选配置,请根据实际情况选择。
配置BGP路由过滤规则
配置BGP路由发送的时间间隔和数量
配置BGP修改发布的路由信息
配置BGP处理接收的路由信息
配置BGP快速撤销指定路由
配置BGP延迟通告路由信息
配置路由过滤策略可实现仅对外发布指定的路由,或是仅接收指定的路由。BGP支持配置多种路由过滤策略。
若命令参数涉及路由图,则需要先配置路由图。关于配置路由图的详细介绍,请参见“路由策略”。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置对于发出路由使用全局路由策略匹配。
bgp advertise-map route-map-name
缺省情况下,向邻居发送路由时未使用全局路由策略进行匹配。
配置对接收或发出的路由使用路由匹配。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } route-map map-tag { in | out }
缺省情况下,未配置对接收或发出的路由使用路由匹配。
配置在同指定BGP对等体收发路由信息时根据ACL实施路由策略。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } distribute-list { access-list-name | access-list-number } { in | out }
缺省情况下,未配置在同指定BGP对等体收发路由信息时根据ACL实施路由策略。
配置选择性地通告被路由聚合抑制的路由信息。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } unsuppress-map map-tag
配置允许BGP Speaker向对等体(组)公告缺省路由。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } default-originate [ route-map map-tag ]
缺省情况下,不允许BGP Speaker向对等体(组)公告缺省路由。
配置允许接收包含本设备AS号的UPDATE报文。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } allowas-in [ occurrence-number ]
缺省情况下,允许接收包含本设备AS号的UPDATE报文。
配置指定BGP对等体所属的Domain分组内不抑制明细路由。
配置指定BGP对等体所属的Domain分组。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } domain domain-name
缺省情况下,未配置指定BGP对等体所属的Domain分组。
配置指定BGP对等体所属的Domain分组内不抑制明细路由。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } domain-unsuppress
缺省情况下,未配置指定BGP对等体所属的Domain分组内不抑制明细路由。
通过配置BGP路由发送的时间间隔和数量,可以调整BGP Speaker对外发布路由的速度。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置发送BGP路由更新的时间间隔。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } advertisement-interval advertisement-interval
缺省情况下,对于IBGP连接,发送BGP路由更新的时间间隔为0秒,对于EBGP连接为30秒。
配置向指定对等体通告本地始发BGP路由的时间间隔。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } as-origination-interval seconds
缺省情况下,向指定对等体通告本地始发BGP路由的时间间隔为1秒。
软件支持通过配置命令在BGP发布路由时携带指定信息或是修改发布路由中的指定信息。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置邻居的源站点属性值。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } soo soo-value
缺省情况下,未配置邻居的源站点属性值。
配置PE覆盖一个站点的AS号。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } as-override
缺省情况下,未配置PE覆盖一个站点的AS号。
配置向指定BGP对等体分发路由时的下一条信息。以下配置步骤互斥,请选择其中一项进行配置。
配置在向指定BGP对等体分发路由时将路由信息的下一跳设置为本设备。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } next-hop-self
缺省情况下,向EBGP对等体通告路由时下一跳设置为本BGP Speaker,向IBGP对等体通告路由时不修改下一跳。
配置指明向对等体(组)发送路由时不修改下一跳信息。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } next-hop-unchanged
缺省情况下,向EBGP对等体发送路由会改变下一跳为本BGP Speaker,向IBGP对等体通告路由时不修改下一跳。
软件支持通过配置命令指定BGP处理接收的路由信息的行为。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置在向指定BGP对等体分发路由和从指定对等体接收路由时不对对等体收发的路由信息进行私有的PIC处理。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } pic-disable
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } weight weight-value
缺省情况下,未配置指定BGP对等体的权重值,此时从邻居学到的路由权重值初始为0,本地生成的路由权重值初始为32768。
随着IP技术的高速发展,以及各种复杂业务的应用,对网络的要求越来越高。客户对特定路由可能需要对其进行快速的收敛,快速撤销指定路由可以满足客户对特定路由优先撤销的需求。
缺省情况下,路由的撤销顺序按在路由表中的顺序进行优选计算处理。快速撤销指定路由会将满足条件的路由加入到高优先级的队列中以实现指定路由的优先处理,进而达到快速撤销指定路由的目的。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
(可选)进入到相应的地址族配置模式,如有需要针对某一类地址族进行配置,请选择其中一项进行配置。
进入IPv4 Unicast配置模式。
address-family ipv4 [ unicast ]
进入IPv4 VRF配置模式。
address-family ipv4 vrf vrf-name
进入IPv6 Unicast配置模式。
address-family ipv6 [ unicast ]
进入IPv6 VRF配置模式。
address-family ipv6 vrf vrf-name
创建BGP邻居。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } remote-as as-number
配置BGP快速撤销指定路由。
bgp fast-withdraw { access-list { access-list-number | access-list-name } | prefix-list prefix-list-name | route-map route-map-name }
缺省情况下,快速撤销指定路由功能处于关闭状态。
配置允许BGP Speaker向对等体(组)快速撤消缺省路由。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } default-fast-withdraw
缺省情况下,BGP Speaker不向对等体(组)快速撤消缺省路由。
整机重启延迟通告
整机重启邻居建立起来后,BGP对等体就可以通告路由给邻居。但在某些情况下,比如启机时存在大量邻居或大量路由,由于硬件写入表项慢,存在邻居已经学完路由开始转发流量,本端还没有完成硬件表项写入的情况,造成流量转发不通。
BGP整机重启延迟通告功能是指整机重启且BGP邻居关系建立后,设备不是立即向邻居通告路由,而是等待一段时间后再进行路由通告。该功能不影响邻居的其他行为,如路由接收。同时,如果允许部分路由不受整机延迟的影响,可以配置Prefix-list策略来匹配这部分路由,提供路由通告的灵活性。
Delay-time用于配置向邻居通告路由的等待时间,Startup-time用于配置启机时间。在Startup-time之内,BGP收到的路由每过Delay-time才向邻居发送路由信息。超过Startup-time时间后,路由通告恢复为默认行为。
首次路由延迟通告
BGP邻居间相互协商达到Established状态,将会互相发送Update报文。如果本端配置了BGP首次路由延迟通告,则从指定邻居收到的路由,本端将延时指定时间之后再向其他邻居发送。
启机延迟通告与首次路由延迟通告功能同时开启的情况下,启机延迟通告的优先级较高。
无论是启机延迟通告还是首次路由延迟通告,都不对BGP GR产生影响,即BGP GR通告路由不受这两个时间的影响。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
开启BGP整机重启时延迟通告路由功能。
bgp initial-advertise-delay { delay-time [ startup-time ] [ wait-for-controller ] | prefix-list prefix-list-name }
缺省情况下,BGP整机重启时延迟通告路由功能处于关闭状态。
配置BGP Speaker第一次向邻居发送更新消息前的最大延迟时间。
bgp update-delay delay-time
缺省情况下,BGP Speaker第一次向邻居发送更新消息前的最大延迟时间为120秒。
BGP安全功能配置任务如下。所有配置均为可选配置,请根据实际情况选择。
配置MD5认证
配置BGP邻居GTSM安全检查
配置BGP Keychain认证
在指定BGP Speaker之间建立TCP连接时使用MD5认证密码,如果认证失败,则不进行TCP连接建立。
建立BGP连接的BGP Speaker必须设置相同的密码,否则无法建立邻居。
设置MD5认证命令后,BGP Speaker将重新建立BGP连接。
同一个邻居的认证密码只能设置一个。
使用命令exit-address-family退出BGP的地址族配置模式。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
(可选)进入到相应的地址族配置模式,如有需要针对某一类地址族进行配置,请选择其中一项进行配置。
进入IPv4 Unicast配置模式。
address-family ipv4 [ unicast ]
进入IPv4 VRF配置模式。
address-family ipv4 vrf vrf-name
进入IPv6 Unicast配置模式。
address-family ipv6 [ unicast ]
进入IPv6 VRF配置模式。
address-family ipv6 vrf vrf-name
创建BGP邻居。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } remote-as as-number
配置BGP邻居的TCP连接MD5加密。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } password [ 0 | 7 ] password-string
缺省情况下,BGP连接未经过MD5加密。
网络设备在控制面处理IP报文时会消耗一定的CPU资源。如果攻击者向一台设备不间断地发送伪造的BGP报文,设备收到这些报文后,发现是发送给本机的报文,在未辨别其是否合法的情况下直接上送控制面处理,设备将会因为处理这些报文浪费大量的CPU资源。
配置BGP GTSM安全检查可保护设备不受CPU利用类型的攻击。GTSM安全检查将会确认IP报文头中的TTL值是否在预先指定的范围内。如果不在指定范围内,则认为报文是非法的,设备将直接丢弃此报文。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置BGP邻居GTSM安全检查。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } ttl-security hops hop-count
Keychain认证支持定义一系列的密钥链,每个密钥可以定义各自生效时间段、认证加密算法和密钥值等。在不同时间段配置不同密钥生效,能够提高通信的安全性。
配置密钥链。详情请参见“密钥”。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
开启指定BGP对等体(组)的Keychain认证功能。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } key-chain key-chain-name
缺省情况下,BGP对等体(组)的Keychain认证功能处于关闭状态。
BGP可靠性配置任务如下。所有配置均为可选配置,请根据实际情况选择。
配置BFD For BGP
配置BGP GR
配置BGP NSR
配置BGP会话保持
配置EBGP邻居快速检测
配置BGP关联链路状态组
配置BGP与BFD联动,实现快速检测网络故障,快速切换到其它备份线路,提高用户的网络体验。
使用命令exit-address-family退出BGP的地址族配置模式。
配置BFD For BGP前,需要确保邻居对应的接口下BFD会话参数已经配置。配置REUP的链路状态组。详情请参见“可靠性配置指南”中的“BFD”。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
(可选)进入到相应的地址族配置模式,如有需要针对某一类地址族进行配置,请选择其中一项进行配置。
进入IPv4 Unicast配置模式。
address-family ipv4 [ unicast ]
进入IPv4 VRF配置模式。
address-family ipv4 vrf vrf-name
进入IPv6 Unicast配置模式。
address-family ipv6 [ unicast ]
进入IPv6 VRF配置模式。
address-family ipv6 vrf vrf-name
创建BGP邻居。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } remote-as as-number
配置BGP与BFD联动,检测特定邻居的变化。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } fall-over bfd
缺省情况下,BFD功能处于关闭状态。
为了实现在协议的重新启动过程中数据转发不间断,实现高可靠性网络部署。
BGP GR功能要成功部署,需要依赖邻居设备支持作为GR Helper。
IBGP环境下,需要同时配置IGP协议GR。
开启BGP GR后,需要重置BGP邻居连接才能生效。
BGP配置模式下开启GR功能后,会自动打开所有地址族的GR功能。
使用命令exit-address-family退出BGP的地址族配置模式。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置BGP GR。
bgp graceful-restart
缺省情况下,GR处于开启状态。
(可选)配置BGP GR重启定时器。
bgp graceful-restart restart-time restart-time
缺省情况下,定时器值为120秒。
(可选)配置BGP GR路由老化定时器。
bgp graceful-restart stalepath-time time
缺省情况下,老化定时器值值360秒。
(可选)配置等待所有BGP GR的EOR标志的最长时间最长时间。
bgp update-delay delay
缺省情况下,EOR标志的最长时间为120秒。
(可选)关闭BGP指定地址族的GR功能。
bgp graceful-restart disable
缺省情况下,当全局BGP GR功能打开时,BGP各地址族下的GR功能处于开启状态。
在管理板主备切换过程中,NSR功能使网络拓扑保持稳定,维持邻居状态,维持转发表,保障关键业务不中断。
BGP NSR功能要成功部署,需要依赖设备支持双引擎冗余热备份功能。
开启BGP NSR后,会重置BGP邻居连接以生效。
基于邻居NSR命令等同于bgp nsr命令,本功能将会开启所有邻居的NSR功能。
基于邻居NSR命令即将废弃,不建议使用。
当邻居启用BGP NSR时,会重置邻居连接,开启邻居的TCP NSS(None-Stop-Service,不间断服务),开始备份相关邻居以及路由信息到从板。因此在BGP Speaker已经处于Established状态时再开启NSR功能,会引起邻居重建,导致邻居震荡。建议在对等体建立完成前开启NSR功能。
NSR功能不会作用于未成功建立BGP连接的邻居,即BGP连接若未达到Established状态时,邻居不会执行NSR操作。只有达到Established状态的邻居,才会进行NSR相关的备份操作。
支持BGP NSR功能并不意味着设备支持作为重启端执行BGP的NSR切换,执行BGP的NSR切换还依赖于设备的硬件能力,NSR设备要求支持双引擎冗余热备份功能。
当前BGP NSR在BGP或TCP备份未完成的情况下可能出现切换失败的情况。当出现NSR切换失败时,路由仍可通过BGP GR进行恢复,因此建议将BGP NSR及BGP GR功能同时开启。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置BGP的NSR功能。
bgp nsr
缺省情况下,NSR功能处于关闭状态。
(可选)开启指定BGP对等体(组)的NSR功能。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } ha-mode nsr [ stable-mode ]
缺省情况下,BGP对等体(组)的NSR功能处于关闭状态。
对于支持BGP功能的设备,某个地址族的路由错误会影响其他地址组的路由稳定性:设备从邻居接收UPDATE报文时,一旦检测出多协议路由属性错误,设备将会断开BGP会话,造成该邻居所有地址族的路由发生震荡。
会话保持功能使得BGP在地址族的路由属性发生错误后,仅删除本地址族与邻居相关的所有路由信息,而对于BGP会话和其他地址族将无任何影响,增强了BGP协议的稳定性。
Recovery-time用于配置自动恢复路由的等待时间,该选项要求邻居必须支持Route-Refresh(路由刷新)能力。在Recovery-time之后,BGP将向该邻居发送地址族的Route-Refresh消息,同时向该邻居重新通告该地址族的所有路由信息。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置BGP协议在检测出多协议路由属性出现错误时不断开BGP会话。
bgp mp-error-handle session-retain [ refresh-timer refresh-timer ]
缺省情况下,BGP协议在检测出多协议路由属性出现错误时会断开BGP会话。
在配置了EBGP邻居快速检测后,设备在直连的EBGP邻居建立连接所使用的网络接口失效时,将会迅速关闭BGP会话连接。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
开启EBGP邻居快速链路检测功能。
bgp fast-external-fallover
缺省情况下,EBGP邻居快速链路检测功能处于开启状态。
REUP(Rapid Ethernet Uplink Protection,快速以太网上链保护)提供一个快速上行链路保护功能。在双上行组网方式中,REUP用来保证链路的正常通信,阻塞冗余链路,避免链路环路,起到快速备份的作用。REUP通过配置链路状态组的下行接口和上行接口,把多个下行接口的链路状态绑定到多个上行链路的接口状态上。当组内所有的上行链路都发生故障,则强制关闭组内所有下行链路的接口。但实际场景中,可能出现上行接口状态无异常,但通过上行接口建立的BGP连接已经断开的情况。此时REUP不会关闭下行链路,设备仍然需要处理下行链路的流量。由于BGP连接已断开,设备上已经没有对应的路由表项,那么设备将会丢弃这部分流量。如果设备能够在识别到BGP连接断开时,自动关闭下行链路接口,就不需要再处理下行链路的流量了。
配置BGP关联链路状态组后,如果关联此链路状态组的BGP邻居全部断开了连接,则设备会自动关闭链路状态组中的所有下行接口,避免处理流量时浪费设备资源。
配置REUP的链路状态组。详情请参见“可靠性配置指南”中的“REUP”。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置BGP对等体(组)关联链路状态跟踪组。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } link state group link-state-group-number
缺省情况下,未配置BGP对等体(组)关联链路状态跟踪组。
(可选)配置解除BGP邻居关联的链路状态跟踪组下联口违例的延迟时间。
bgp link-state-group up-delay delay-time
缺省情况下,解除BGP邻居关联的链路状态跟踪组下联口违例的延迟时间为5秒。
BGP拓展功能配置任务如下。所有配置任务均为可选配置,请根据实际情况选择。
配置BMP监控
配置BGP的管理距离
配置增强VPN路由导入
实现BGP协议受BMP Server监控, 关注BGP对等体的状况和对等体表项的接收和发送,以及对等体的各类统计信息。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置邻居受指定的BMP服务器监控。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } bmp-active { all | server server-number&<1-8> }
退回全局配置模式。
exit
配置创建BMP Server实例。
bmp server server-number
配置BMP Server的地址和端口号。
address [ bmp-server-ipv4-address | bmp-server-ipv6-address ] port port-number
缺省情况下,BMP模式下没有配置BMP Sever的地址和端口号。
配置与BMP server建立TCP连接的出接口。
update-source interface-type interface-number
缺省情况下,将根据BMP Server的IP地址自动选择TCP连接的出接口,一般采用本地报文的出接口。
配置与BMP Server建立TCP连接所属的VRF。
vrf vrf-name
缺省情况下,将在默认的VRF下与BMP Server建立TCP连接。
(可选)配置与BMP Server重新建立TCP连接的时间间隔。
failure-retry-delay time
缺省情况下,将根据初始的30秒逐渐递增与BMP服务器重连的时间间隔。
(可选)配置与BMP实例的描述。
description text
缺省情况下,没有对BMP实例的描述。
配置监控从对等体接收的应用路由策略后的路由。
adj-rib-in post-policy
缺省情况下,BMP Server不监控从BGP对等体接收的应用路由策略后的路由信息。
配置监控从对等体接收的未经更改的路由信息。
adj-rib-in pre-policy
缺省情况下,BMP Server不监控从BGP对等体接收的未经更改的路由信息。
配置监控发给对等体的应用路由策略后的路由。
adj-rib-out post-policy
缺省情况下,BMP Server不监控向BGP对等体发送的应用路由策略后的路由信息。
配置BGP对等体受BMP Server监控。
neighbor { neighbor-ipv4-address | neighbor-ipv6-address | peer-group-name } bmp-active { all | server server-number [ server-number [ server-number ] ] }
缺省情况下,BGP对等体不受BMP Server监控。
配置BMP Server监控BGP报文
route mirroring
缺省情况下,BMP Sever不会开启发送route mirroring报文。
配置BMP Server发送状态统计信息的时间间隔。
stats-reporting-period time
缺省情况下,当受监控对等体的状态统计信息发生变化时会延迟一定时间向BMP Server发送状态统计信息。
(可选)配置BMP实例的最大缓存报文字节数。
buffer-size buffer-size-maximum
管理距离用于评价各种路由来源的可信度。管理距离越小,路由越优。
BGP的管理距离
管理距离表示一个路由信息源的可信度,其范围是从1~255。管理距离的值越大,其可信度越低。BGP对所学习到的路由信息的不同来源设定不同的管理距离,分为External-distance(外部管理距离)、Internal-distance(内部管理距离)和Local-distance(本地管理距离)三类:
External-distance:从EBGP Peers学习到路由的管理距离。
Internal-distance:从IBGP Peers学习到路由的管理距离。
Local-distance:从Peers学习到,但被认为存在可以从IGP学习到更优的路由的管理距离,通常这些路由通过network backdoor命令表示。
后门路由
如果希望优先选择IGP的某一条路由,而避免使用EBGP的这一条路由信息,可以将这条路由设置为后门路由。缺省情况下,从建立EBGP连接的BGP Speaker学习到的路由信息的管理距离为20。network backdoor命令将这些网络信息的管理距离设置为200,使得从IGP学习到的相同的网络信息拥有更高的优先级。从IGP学习到的路由信息认为是后门网络,并不对外公告。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
配置BGP路由的管理距离。
distance bgp external-distance internal-distance local-distance
缺省情况下,BGP从EBGP对等体学习到路由的管理距离为20,从IBGP对等体学习到路由的管理距离为200。
配置后门路由。
network network-number [ mask mask ] [ route-map map-tag ] backdoor
缺省情况下,未配置后门路由。
缺省情况下,VRF间路由互相导入、L3VPN远端路由导入VRF或者EVPN路由导入到IP路由表时,只导入优选下一跳的路由。配置了增强VPN路由导入后,可将所有下一跳路由或等价下一跳路由导入。导入的路由可以实现ECMP多路径。
不支持IBGP路由与EBGP路由形成等价路由。
不支持IBGP路由与EBGP路由形成等价路由。
进入特权模式。
enable
进入全局配置模式。
configure terminal
启动BGP协议,进入BGP配置模式。
router bgp as-number
(可选)进入到相应的地址族配置模式,如有需要针对某一类地址族进行配置,请选择其中一项进行配置。
进入IPv4 Unicast配置模式。
address-family ipv4 [ unicast ]
进入IPv4 VRF配置模式。
address-family ipv4 vrf vrf-name
进入IPv6 Unicast配置模式。
address-family ipv6 [ unicast ]
进入IPv6 VRF配置模式。
address-family ipv6 vrf vrf-name
配置路由导入策略。
import path selection { all | bestpath | multipath }
缺省情况下,只导入优选路由。
可以通过show命令行查看功能配置后的运行情况以验证配置效果。
可以通过执行clear命令来清除各类信息。
注意
在设备运行过程中执行clear命令,可能因为重要信息丢失而导致业务中断。
可以通过debug命令行列举输出的各种调试信息。
注意
输出调试信息,会占用系统资源。使用完毕后,请立即关闭。
BGP监视与维护
BGP Speaker之间分别建立IBGP邻居、EBGP邻居实现基本组网。
在所有设备上开启BGP协议,按图1-2中所示设定AS号(略)。
在Device A、Device B和Device C上配置环回口,通过该环回口建立IBGP邻居。
在Device C和Device D通过直连接口建立EBGP邻居。
在Device C上创建IBGP对等体组。
配置Loopback,对接口下配置IP地址。
# Device A配置。
Device A# configure terminal
Device A(config)# interface loopback 0
Device A(config-if-Loopback 0)# ip address 10.1.1.1 255.255.255.255
Device A(config-if-Loopback 0)# exit
Device A(config)# interface GigabitEthernet 0/1
Device A(config-if-GigabitEthernet 0/1)# ip address 192.168.1.1 255.255.255.0
Device A(config-if-GigabitEthernet 0/1)# exit
# Device B配置。
Device B# configure terminal
Device B(config)# interface loopback 0
Device B(config-if-Loopback 0)# ip address 10.1.1.2 255.255.255.255
Device B(config-if-Loopback 0)# exit
Device B(config)# interface GigabitEthernet 0/1
Device B(config-if-GigabitEthernet 0/1)# ip address 192.168.2.2 255.255.255.0
Device B(config-if-GigabitEthernet 0/1)# exit
# Device C配置。
Device C# configure terminal
Device C(config)# interface loopback 0
Device C(config-if-Loopback 0)# ip address 10.1.1.3 255.255.255.255
Device C(config-if-Loopback 0)# exit
Device C(config)# interface GigabitEthernet 0/1
Device C(config-if-GigabitEthernet 0/1)# ip address 192.168.1.3 255.255.255.0
Device C(config-if-GigabitEthernet 0/1)# exit
Device C(config)# interface GigabitEthernet 0/2
Device C(config-if-GigabitEthernet 0/2)# ip address 192.168.2.3 255.255.255.0
Device C(config-if-GigabitEthernet 0/2)# exit
Device C(config)# interface GigabitEthernet 0/3
Device C(config-if-GigabitEthernet 0/3)# ip address 192.168.3.3 255.255.255.0
Device C(config-if-GigabitEthernet 0/3)# exit
# Device D配置。
Device D# configure terminal
Device D(config)# interface GigabitEthernet 0/1
Device D(config-if-GigabitEthernet 0/1)# ip address 192.168.3.4 255.255.255.0
Device D(config-if-GigabitEthernet 0/1)# exit
配置启动BGP,并将环回口作为邻居接口。
# Device A配置。
Device A(config)# router bgp 65536
Device A(config-router)# neighbor 10.1.1.3 remote-as 65536
Device A(config-router)# neighbor 10.1.1.3 update-source loopback 0
# Device B配置。
Device B(config)# router bgp 65536
Device B(config-router)# neighbor 10.1.1.3 remote-as 65536
Device B(config-router)# neighbor 10.1.1.3 update-source loopback 0
# Device C配置。
Device C(config)# router bgp 65536
Device C(config-router)# neighbor ibgp-group peer-group
Device C(config-router)# neighbor ibgp-group remote-as 65536
Device C(config-router)# neighbor ibgp-group update-source loopback 0
Device C(config-router)# neighbor 10.1.1.1 peer-group ibgp-group
Device C(config-router)# neighbor 10.1.1.2 peer-group ibgp-group
Device C(config-router)# neighbor 192.168.3.4 remote-as 65537
# Device D配置。
Device D(config)# router bgp 65537
Device D(config-router)# neighbor 192.168.3.3 remote-as 65536
# Device A使用show ip bgp neighbor命令查看BGP邻居状态。通过查看对应邻居信息中BGP state显示的BGP邻居状态可以确认设备是否成功和邻居建立BGP连接,Established表示连接已经成功建立,Active表示邻居已激活但尚未建立连接。
Device A# show ip bgp neighbor
BGP neighbor is 10.1.1.3, remote AS 65536, local AS 65536, internal link
BGP version 4, remote router ID 10.1.1.3
BGP state = Established, up for 00:00:05
Last read 00:00:04, hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Four-octets ASN Capability: advertised and received
Address family IPv4 Unicast: advertised and received
Received 2 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:1
refresh message:0 dynamic cap:0 notifications:0
Sent 2 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:1
refresh message:0 dynamic cap:0 notifications:0
Route refresh request: received 0, sent 0
Minimum time between advertisement runs is 0 seconds
Update source is Loopback 0
For address family: IPv4 Unicast
BGP table version 1, neighbor version 1
Index 0, Offset 0, Mask 0x1
0 accepted prefixes
0 announced prefixes
Connections established 1; dropped 0
Local host: 10.1.1.1, Local port: 1039
Foreign host: 10.1.1.3, Foreign port: 179
Nexthop: 10.1.1.1
Nexthop global: ::
Nexthop local: ::
BGP connection: non shared network
Last Reset: 00:00:09, due to BGP Notification received
Notification Error Message: (Cease/Other Configuration Change.)
# Device B使用show命令查看BGP邻居状态。
Device B# show ip bgp neighbor
BGP neighbor is 10.1.1.3, remote AS 65536, local AS 65536, internal link
BGP version 4, remote router ID 10.1.1.3
BGP state = Established, up for 00:00:07
Last read 00:00:05, hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Four-octets ASN Capability: advertised and received
Address family IPv4 Unicast: advertised and received
Received 2 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:1
refresh message:0 dynamic cap:0 notifications:0
Sent 2 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:1
refresh message:0 dynamic cap:0 notifications:0
Route refresh request: received 0, sent 0
Minimum time between advertisement runs is 0 seconds
Update source is Loopback 0
For address family: IPv4 Unicast
BGP table version 1, neighbor version 1
Index 0, Offset 0, Mask 0x1
0 accepted prefixes
0 announced prefixes
Connections established 1; dropped 0
Local host: 10.1.1.2, Local port: 1041
Foreign host: 10.1.1.3, Foreign port: 179
Nexthop: 10.1.1.2
Nexthop global: ::
Nexthop local: ::
BGP connection: non shared network
Last Reset: 00:00:08, due to BGP Notification received
Notification Error Message: (Cease/Other Configuration Change.)
# Device C使用show命令查看BGP邻居状态。
Device C# show ip bgp neighbor
BGP neighbor is 10.1.1.1, remote AS 65536, local AS 65536, internal link
Member of peer-group ibgp-group for session parameters
BGP version 4, remote router ID 10.1.1.1
BGP state = Established, up for 00:01:13
Last read 00:01:11, hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Four-octets ASN Capability: advertised and received
Address family IPv4 Unicast: advertised and received
Received 3 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:2
refresh message:0 dynamic cap:0 notifications:0
Sent 3 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:2
refresh message:0 dynamic cap:0 notifications:0
Route refresh request: received 0, sent 0
Minimum time between advertisement runs is 0 seconds
Update source is Loopback 0
For address family: IPv4 Unicast
BGP table version 1, neighbor version 1
Index 1, Offset 0, Mask 0x2
ibgp-group peer-group member
0 accepted prefixes
0 announced prefixes
Connections established 1; dropped 0
Local host: 10.1.1.3, Local port: 179
Foreign host: 10.1.1.1, Foreign port: 1039
Nexthop: 10.1.1.3
Nexthop global: ::
Nexthop local: ::
BGP connection: non shared network
BGP neighbor is 10.1.1.2, remote AS 65536, local AS 65536, internal link
Member of peer-group ibgp-group for session parameters
BGP version 4, remote router ID 10.1.1.2
BGP state = Established, up for 00:01:17
Last read 00:01:08, hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Four-octets ASN Capability: advertised and received
Address family IPv4 Unicast: advertised and received
Received 3 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:2
refresh message:0 dynamic cap:0 notifications:0
Sent 3 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:2
refresh message:0 dynamic cap:0 notifications:0
Route refresh request: received 0, sent 0
Minimum time between advertisement runs is 0 seconds
Update source is Loopback 0
For address family: IPv4 Unicast
BGP table version 1, neighbor version 1
Index 1, Offset 0, Mask 0x2
ibgp-group peer-group member
0 accepted prefixes
0 announced prefixes
Connections established 1; dropped 0
Local host: 10.1.1.3, Local port: 179
Foreign host: 10.1.1.2, Foreign port: 1041
Nexthop: 10.1.1.3
Nexthop global: ::
Nexthop local: ::
BGP connection: non shared network
BGP neighbor is 192.168.3.4, remote AS 65536, local AS 65536, internal link
Member of peer-group ibgp-group for session parameters
BGP version 4, remote router ID 192.168.3.4
BGP state = Established, up for 00:01:01
Last read 00:01:00, hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Four-octets ASN Capability: advertised and received
Address family IPv4 Unicast: advertised and received
Received 3 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:2
refresh message:0 dynamic cap:0 notifications:0
Sent 3 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:2
refresh message:0 dynamic cap:0 notifications:0
Route refresh request: received 0, sent 0
Minimum time between advertisement runs is 0 seconds
Update source is Loopback 0
For address family: IPv4 Unicast
BGP table version 1, neighbor version 1
Index 1, Offset 0, Mask 0x2
ibgp-group peer-group member
0 accepted prefixes
0 announced prefixes
Connections established 1; dropped 0
Local host: 192.168.3.3, Local port: 179
Foreign host: 192.168.3.4, Foreign port: 1018
Nexthop: 192.168.3.3
Nexthop global: ::
Nexthop local: ::
BGP connection: non shared network
# Device D使用show命令查看BGP邻居状态。
Device D# show ip bgp neighbor
BGP neighbor is 192.168.3.3, remote AS 65536, local AS 65536, internal link
Member of peer-group ibgp-group for session parameters
BGP version 4, remote router ID 10.1.1.3
BGP state = Established, up for 00:01:01
Last read 00:00:58, hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Four-octets ASN Capability: advertised and received
Address family IPv4 Unicast: advertised and received
Received 3 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:2
refresh message:0 dynamic cap:0 notifications:0
Sent 3 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:2
refresh message:0 dynamic cap:0 notifications:0
Route refresh request: received 0, sent 0
Minimum time between advertisement runs is 0 seconds
Update source is Loopback 0
For address family: IPv4 Unicast
BGP table version 1, neighbor version 1
Index 1, Offset 0, Mask 0x2
ibgp-group peer-group member
0 accepted prefixes
0 announced prefixes
Connections established 1; dropped 0
Local host: 192.168.3.4, Local port: 1018
Foreign host: 192.168.3.3, Foreign port: 179
Nexthop: 192.168.3.4
Nexthop global: ::
Nexthop local: ::
BGP connection: non shared network
Device A的配置文件
!
interface GigabitEthernet 0/1
no switchport
ip address 192.168.1.1 255.255.255.0
!
interface Loopback 0
ip address 10.1.1.1 255.255.255.255
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.3 remote-as 65536
neighbor 10.1.1.3 update-source Loopback 0
address-family ipv4
neighbor 10.1.1.3 activate
exit-address-family
!
Device B的配置文件
!
interface GigabitEthernet 0/1
no switchport
ip address 192.168.2.2 255.255.255.0
!
interface Loopback 0
ip address 10.1.1.2 255.255.255.255
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.3 remote-as 65536
neighbor 10.1.1.3 update-source Loopback 0
address-family ipv4
neighbor 10.1.1.3 activate
exit-address-family
!
Device C的配置文件
!
interface GigabitEthernet 0/1
no switchport
ip address 192.168.1.3 255.255.255.0
!
interface GigabitEthernet 0/2
no switchport
ip address 192.168.2.3 255.255.255.0
!
interface GigabitEthernet 0/3
no switchport
ip address 192.168.3.3 255.255.255.0
!
interface Loopback 0
ip address 10.1.1.3 255.255.255.255
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor ibgp-group peer-group
neighbor ibgp-group remote-as 65536
neighbor ibgp-group update-source Loopback 0
neighbor 10.1.1.1 peer-group ibgp-group
neighbor 10.1.1.2 peer-group ibgp-group
neighbor 192.168.3.4 remote-as 65537
address-family ipv4
no neighbor ibgp-group activate
neighbor 192.168.3.4 activate
exit-address-family
!
Device D的配置文件
!
interface GigabitEthernet 0/1
no switchport
ip address 192.168.1.3 255.255.255.0
!
router bgp 65537
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
address-family ipv4
exit-address-family
!
未启用IGP协议,本地Loopback地址与IBGP邻居的Loopback地址无法互通,导致邻居无法建立。
EBGP邻居非直连时未设置ebgp-multihop,TCP无法建立连接。
为TCP连接建立实现MD5加密,保障数据传输安全性。
在所有设备上开启BGP协议,按图1-3中所示设定AS号(略)。
在Device B和Device C上配置环回口,通过该环回口建立IBGP邻居(略)。
在Device A和Device B通过直连接口建立EBGP邻居。
在Device A、Device B和Device C上分别为各自的邻居设置相应的密码。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 65537
Device A(config-router)# neighbor 192.168.1.2 remote-as 65536
Device A(config-router)# neighbor 192.168.1.2 password 7 ebgpneighbor
# Device B配置。
Device B# configure terminal
Device B(config)# router bgp 65536
Device B(config-router)# neighbor 10.1.1.2 remote-as 65536
Device B(config-router)# neighbor 10.1.1.2 update-source loopback 0
Device B(config-router)# neighbor 10.1.1.2 password ibgpneighbor
Device B(config-router)# neighbor 192.168.1.1 remote-as 65537
Device B(config-router)# neighbor 192.168.1.1 password 7 ebgpneighbor
# Device C配置。
Device C# configure terminal
Device C(config)# router bgp 65536
Device C(config-router)# neighbor 10.1.1.1 remote-as 65536
Device C(config-router)# neighbor 10.1.1.1 update-source loopback 0
Device C(config-router)# neighbor 10.1.1.1 password ibgpneighbor
# Device A使用show ip bgp neighbors命令查看BGP邻居状态。
Device A# show ip bgp neighbors
BGP neighbor is 192.168.1.2, remote AS 65536, local AS 65537, external link
BGP version 4, remote router ID 10.1.1.1
BGP state = Established, up for 00:04:54
Last read , hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Four-octets ASN Capability: advertised and received
Address family IPv4 Unicast: advertised and received
Received 7 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:6
refresh message:0 dynamic cap:0 notifications:0
Sent 7 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:6
refresh message:0 dynamic cap:0 notifications:0
Route refresh request: received 0, sent 0
Minimum time between advertisement runs is 30 seconds
For address family: IPv4 Unicast
BGP table version 1, neighbor version 0
Index 1, Offset 0, Mask 0x2
0 accepted prefixes
0 announced prefixes
Connections established 2; dropped 1
Local host: 192.168.1.1, Local port: 1026
Foreign host: 192.168.1.2, Foreign port: 179
Nexthop: 192.168.1.1
Nexthop global: ::
Nexthop local: ::
BGP connection: non shared network
Last Reset: 00:04:54, due to BGP Notification sent
Notification Error Message: (Cease/Administratively Reset.)
# Device B使用show ip bgp neighbors命令查看BGP邻居状态。
Device B# show ip bgp neighbors
BGP neighbor is 10.1.1.2, remote AS 65536, local AS 65536, internal link
BGP version 4, remote router ID 10.1.1.2
BGP state = Established, up for 00:04:01
Last read , hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Four-octets ASN Capability: advertised and received
Address family IPv4 Unicast: advertised and received
Received 8 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:7
refresh message:0 dynamic cap:0 notifications:0
Sent 8 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:7
refresh message:0 dynamic cap:0 notifications:0
Route refresh request: received 0, sent 0
Minimum time between advertisement runs is 30 seconds
For address family: IPv4 Unicast
BGP table version 1, neighbor version 0
Index 1, Offset 0, Mask 0x2
0 accepted prefixes
0 announced prefixes
Connections established 2; dropped 1
Local host: 10.1.1.1, Local port: 179
Foreign host: 10.1.1.2, Foreign port: 1038
Nexthop: 10.1.1.1
Nexthop global: ::
Nexthop local: ::
BGP connection: non shared network
Last Reset: 00:05:27, due to BGP Notification received
Notification Error Message: (Cease/Administratively Reset.)
BGP neighbor is 192.168.1.1, remote AS 65537, local AS 65536, external link
BGP version 4, remote router ID 192.168.1.1
BGP state = Established, up for 00:05:27
Last read , hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Four-octets ASN Capability: advertised and received
Address family IPv4 Unicast: advertised and received
Received 8 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:7
refresh message:0 dynamic cap:0 notifications:0
Sent 8 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:7
refresh message:0 dynamic cap:0 notifications:0
Route refresh request: received 0, sent 0
Minimum time between advertisement runs is 30 seconds
For address family: IPv4 Unicast
BGP table version 1, neighbor version 0
Index 1, Offset 0, Mask 0x2
0 accepted prefixes
0 announced prefixes
Connections established 2; dropped 1
Local host: 192.168.1.2, Local port: 179
Foreign host: 192.168.1.1, Foreign port: 1026
Nexthop: 192.168.1.2
Nexthop global: ::
Nexthop local: ::
BGP connection: non shared network
Last Reset: 00:05:27, due to BGP Notification received
Notification Error Message: (Cease/Administratively Reset.)
# Device C使用show ip bgp neighbors命令查看BGP邻居状态。
Device C# show ip bgp neighbors
BGP neighbor is 10.1.1.1, remote AS 65536, local AS 65536, internal link
BGP version 4, remote router ID 10.1.1.1
BGP state = Established, up for 00:04:01
Last read , hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Four-octets ASN Capability: advertised and received
Address family IPv4 Unicast: advertised and received
Received 8 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:7
refresh message:0 dynamic cap:0 notifications:0
Sent 8 messages, 0 notifications, 0 in queue
open message:1 update message:0 keepalive message:7
refresh message:0 dynamic cap:0 notifications:0
Route refresh request: received 0, sent 0
Minimum time between advertisement runs is 30 seconds
For address family: IPv4 Unicast
BGP table version 1, neighbor version 0
Index 1, Offset 0, Mask 0x2
0 accepted prefixes
0 announced prefixes
Connections established 2; dropped 1
Local host: 10.1.1.2, Local port: 1038
Foreign host: 10.1.1.1, Foreign port: 179
Nexthop: 10.1.1.2
Nexthop global: ::
Nexthop local: ::
BGP connection: non shared network
Last Reset: 00:05:27, due to BGP Notification received
Notification Error Message: (Cease/Administratively Reset.)
Device A的配置文件
!
router bgp 65537
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.1.2 remote-as 65536
neighbor 192.168.1.2 password 7 ebgpneighbor
address-family ipv4
neighbor 192.168.1.2 activate
exit-address-family
!
Device B的配置文件
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.2 remote-as 65536
neighbor 10.1.1.2 update-source Loopback 0
neighbor 10.1.1.2 password ibgpneighbor
neighbor 192.168.1.1 remote-as 65537
neighbor 192.168.1.1 password 7 ebgpneighbor
address-family ipv4
neighbor 10.1.1.2 activate
neighbor 192.168.1.1 activate
exit-address-family
!
Device C的配置文件
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.1 remote-as 65536
neighbor 10.1.1.1 update-source Loopback 0
neighbor 10.1.1.1 password ibgpneighbor
address-family ipv4
neighbor 10.1.1.1 activate
exit-address-family
!
BGP邻居两边MD5加密认证密码不一致。
在BGP Speaker较多的组网中,通过配置有反射器简化路由信息的管理和同步,让路由传递更高效。
在所有设备上开启BGP协议,按图1-4中所示设定AS号(略)。
在所有设备上配置环回口,通过该环回口按图中所示连接线建立IBGP邻居(略)。
在Device RR上配置路由反射,同时指定Device A、Device B、Device C和Device D为反射客户端。
配置BGP邻居,通告网络信息。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 65536
Device A(config-router)# neighbor 10.1.1.5 remote-as 65536
Device A(config-router)# neighbor 10.1.1.5 update-source loopback 0
Device A(config-router)# network 192.168.1.0 mask 255.255.255.0
# Device B配置。
Device B# configure terminal
Device B(config)# router bgp 65536
Device B(config-router)# neighbor 10.1.1.5 remote-as 65536
Device B(config-router)# neighbor 10.1.1.5 update-source loopback 0
# Device C配置。
Device C# configure terminal
Device C(config)# router bgp 65536
Device C(config-router)# neighbor 10.1.1.5 remote-as 65536
Device C(config-router)# neighbor 10.1.1.5 update-source loopback 0
# Device D配置。
Device D# configure terminal
Device D(config)# router bgp 65536
Device D(config-router)# neighbor 10.1.1.5 remote-as 65536
Device D(config-router)# neighbor 10.1.1.5 update-source loopback 0
配置反射器。
# Device RR配置。
Device RR# configure terminal
Device RR(config)# router bgp 65536
Device RR(config-router)# neighbor 10.1.1.1 remote-as 65536
Device RR(config-router)# neighbor 10.1.1.1 update-source loopback 0
Device RR(config-router)# neighbor 10.1.1.1 route-reflector-client
Device RR(config-router)# neighbor 10.1.1.2 remote-as 65536
Device RR(config-router)# neighbor 10.1.1.2 update-source loopback 0
Device RR(config-router)# neighbor 10.1.1.2 route-reflector-client
Device RR(config-router)# neighbor 10.1.1.3 remote-as 65536
Device RR(config-router)# neighbor 10.1.1.3 update-source loopback 0
Device RR(config-router)# neighbor 10.1.1.3 route-reflector-client
Device RR(config-router)# neighbor 10.1.1.4 remote-as 65536
Device RR(config-router)# neighbor 10.1.1.4 update-source loopback 0
Device RR(config-router)# neighbor 10.1.1.4 route-reflector-client
# Device RR查看BGP邻居状态。
Device RR# show ip bgp summary
BGP router identifier 10.1.1.5, local AS number 65536
BGP table version is 1
0 BGP AS-PATH entries
0 BGP Community entries
1 BGP Prefix entries (Maximum-prefix:4294967295)
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.1.1.1 4 65536 8 9 1 0 0 00:05:11 1
10.1.1.2 4 65536 9 9 1 0 0 00:05:24 0
10.1.1.3 4 65536 8 7 1 0 0 00:05:10 0
10.1.1.4 4 65536 9 8 1 0 0 00:05:14 0
Device RR# show ip bgp
BGP table version is 1, local router ID is 10.1.1.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale, b - backup entry
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*>i192.168.1.0 10.1.1.1 0 100 0 i
Total number of prefixes 1
# Device D使用show ip bgp summary命令查看BGP详细信息。
Device D# show ip bgp summary
BGP router identifier 10.1.1.4, local AS number 65536
BGP table version is 1
0 BGP AS-PATH entries
0 BGP Community entries
1 BGP Prefix entries (Maximum-prefix:4294967295)
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.1.1.5 4 65536 8 9 1 0 0 00:05:20 1
Device D# show ip bgp
BGP table version is 1, local router ID is 10.1.1.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale, b - backup entry
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i192.168.1.0 10.1.1.1 0 100 0 i
Total number of prefixes 1
Device A的配置文件
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.5 remote-as 65536
neighbor 10.1.1.5 update-source Loopback 0
address-family ipv4
network 192.168.1.0
neighbor 10.1.1.5 activate
exit-address-family
!
Device B的配置文件
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.5 remote-as 65536
neighbor 10.1.1.5 update-source Loopback 0
address-family ipv4
neighbor 10.1.1.5 activate
exit-address-family
!
Device C的配置文件
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.5 remote-as 65536
neighbor 10.1.1.5 update-source Loopback 0
address-family ipv4
neighbor 10.1.1.5 activate
exit-address-family
!
Device D的配置文件
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.5 remote-as 65536
neighbor 10.1.1.5 update-source Loopback 0
address-family ipv4
neighbor 10.1.1.5 activate
exit-address-family
!
Device RR的配置文件
!
router bgp 65536
bgp confederation identifier 100
bgp confederation peers 65537
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.1 remote-as 65536
neighbor 10.1.1.1 update-source Loopback 0
neighbor 10.1.1.2 remote-as 65536
neighbor 10.1.1.2 update-source Loopback 0
neighbor 10.1.1.3 remote-as 65536
neighbor 10.1.1.3 update-source Loopback 0
neighbor 10.1.1.4 remote-as 65536
neighbor 10.1.1.4 update-source Loopback 0
address-family ipv4
network 192.168.1.0
neighbor 10.1.1.1 activate
neighbor 10.1.1.1 route-reflector-client
neighbor 10.1.1.2 activate
neighbor 10.1.1.2 route-reflector-client
neighbor 10.1.1.3 activate
neighbor 10.1.1.3 route-reflector-client
neighbor 10.1.1.4 activate
neighbor 10.1.1.4 route-reflector-client
exit-address-family
!
通过配置BGP联盟解决网络中的IBGP连接过多导致维护资源庞大问题。
BGP联盟配置组网图
配置设备接口IP地址(略)。
在Device A和Device B上配置BGP协议,AS号为65536,并配置IBGP邻居关系。
在Device C和Device D上配置BGP协议,AS号为65537,并配置成IBGP邻居关系。
在Device BR1和Device E上配置BGP协议,AS号为65538,并配置成IBGP邻居关系。
在Device A、Device B、Device C、Device D、Device E和Device BR1上配置联盟标识100。
在Device A上配置联盟成员65537,并配置C为EBGP邻居,对端AS号为65537。
在Device C上配置联盟成员65536和65538,并配置A为EBGP邻居、对端AS号65536,配置Device BR1为EBGP邻居、对端AS号65538。
在Device BR1上配置联盟成员65537;并配置C为EBGP邻居、对端AS号为65537,Device BR2为EBGP邻居、对端AS号200。
在Device BR2上配置BGP协议,AS号为200,并配置Device BR1为EBGP邻居,对端AS号为100。
配置IBGP邻居、EBGP邻居以及通告网络信息。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 65536
Device A(config-router)# neighbor 10.1.1.2 remote-as 65536
Device A(config-router)# neighbor 10.1.1.2 update-source loopback 0
Device A(config-router)# neighbor 10.1.1.3 remote-as 65537
Device A(config-router)# neighbor 10.1.1.3 ebgp-multihop 2
Device A(config-router)# neighbor 10.1.1.3 update-source loopback 0
Device A(config-router)# network 192.168.1.0 mask 255.255.255.0
# Device B配置。
Device B# configure terminal
Device B(config)# router bgp 65536
Device B(config-router)# neighbor 10.1.1.1 remote-as 65536
Device B(config-router)# neighbor 10.1.1.1 update-source loopback 0
# Device C配置。
Device C# configure terminal
Device C(config)# router bgp 65537
Device C(config-router)# neighbor 10.1.1.1 remote-as 65536
Device C(config-router)# neighbor 10.1.1.1 update-source loopback 0
Device C(config-router)# neighbor 10.1.1.1 ebgp-multihop 2
Device C(config-router)# neighbor 10.1.1.4 remote-as 65537
Device C(config-router)# neighbor 10.1.1.4 update-source loopback 0
Device C(config-router)# neighbor 10.1.1.5 remote-as 65538
Device C(config-router)# neighbor 10.1.1.5 update-source loopback 0
Device C(config-router)# neighbor 10.1.1.5 ebgp-multihop 2
# Device D配置。
Device D# configure terminal
Device D(config)# router bgp 65537
Device D(config-router)# neighbor 10.1.1.3 remote-as 65537
Device D(config-router)# neighbor 10.1.1.3 update-source loopback 0
# E设备配置。
Device E# configure terminal
Device E(config)# router bgp 65538
Device E(config-router)# neighbor 10.1.1.5 remote-as 65538
Device E(config-router)# neighbor 10.1.1.5 update-source loopback 0
# Device BR1设备配置。
Device BR1# configure terminal
Device BR1(config)# router bgp 65538
Device BR1(config-router)# neighbor 10.1.1.3 remote-as 65537
Device BR1(config-router)# neighbor 10.1.1.3 update-source loopback 0
Device BR1(config-router)# neighbor 10.1.1.3 ebgp-multihop 2
Device BR1(config-router)# neighbor 10.1.1.6 remote-as 65538
Device BR1(config-router)# neighbor 10.1.1.6 update-source loopback 0
Device BR1(config-router)# neighbor 192.168.6.7 remote-as 200
# Device BR2设备配置。
Device BR2# configure terminal
Device BR2(config)# router bgp 200
Device BR2(config-router)# neighbor 192.168.6.5 remote-as 100
Device BR2(config-router)# network 192.168.6.0 mask 255.255.255.0
配置联盟成员。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 65536
Device A(config-router)# bgp confederation identifier 100
Device A(config-router)# bgp confederation peers 65537
# Device C设备配置。
Device C# configure terminal
Device C(config)# router bgp 65537
Device C(config-router)# bgp confederation identifier 100
Device C(config-router)# bgp confederation peers 65536 65538
# Device BR1设备配置。
Device BR1# configure terminal
Device BR1(config)# router bgp 65538
Device BR1(config-router)# bgp confederation identifier 100
Device BR1(config-router)# bgp confederation peers 65537
# Device A查看BGP信息。
Device A# show ip bgp summary
BGP router identifier 10.1.1.1, local AS number 65536
BGP table version is 1
1 BGP AS-PATH entries
0 BGP Community entries
1 BGP Prefix entries (Maximum-prefix:4294967295)
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.1.1.2 4 65536 3 3 1 0 0 00:00:05 0
10.1.1.3 4 65537 3 3 1 0 0 00:00:06 1
Total number of neighbors 1
Device A# show ip bgp
BGP table version is 1, local router ID is 10.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale, b - backup entry
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* 192.168.6.0 192.168.6.7 0 100 0 (65537 65538) 200 i
Total number of prefixes 1
# Device BR1查看BGP信息。
Device BR1# show ip bgp summary
BGP router identifier 10.1.1.5, local AS number 200
BGP table version is 2
2 BGP AS-PATH entries
0 BGP Community entries
2 BGP Prefix entries (Maximum-prefix:4294967295)
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.1.1.3 4 65537 3 3 2 0 0 00:00:10 1
10.1.1.6 4 65538 3 3 2 0 0 00:00:08 0
192.168.6.7 4 200 3 3 2 0 0 00:00:05 1
Total number of neighbors 1
Device BR1# show ip bgp
BGP table version is 1, local router ID is 10.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale, b - backup entry
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* 192.168.1.0 10.1.1.1 0 100 0 (65537 65536) i
*> 192.168.6.0 192.168.6.7 0 100 0 200 i
Total number of prefixes 1
# Device BR2查看BGP信息。
Device BR2# show ip bgp summary
BGP router identifier 192.168.6.7, local AS number 200
BGP table version is 1
1 BGP AS-PATH entries
0 BGP Community entries
1 BGP Prefix entries (Maximum-prefix:4294967295)
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
192.168.6.5 4 100 3 3 1 0 0 00:00:05 1
Total number of neighbors 1
Device BR2# show ip bgp
BGP table version is 1, local router ID is 10.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale, b - backup entry
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 192.168.1.0 192.168.6.5 0 100 0 (65537 65538) 200 i
Total number of prefixes 1
DeviceA的配置文件
!
router bgp 65536
bgp confederation identifier 100
bgp confederation peers 65537
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.2 remote-as 65536
neighbor 10.1.1.2 update-source Loopback 0
neighbor 10.1.1.3 remote-as 65537
neighbor 10.1.1.3 ebgp-multihop 2
neighbor 10.1.1.3 update-source Loopback 0
address-family ipv4
network 192.168.1.0
neighbor 10.1.1.2 activate
neighbor 10.1.1.3 activate
exit-address-family
!
Device B的配置文件
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.1 remote-as 65536
neighbor 10.1.1.1 update-source Loopback 0
address-family ipv4
neighbor 10.1.1.1 activate
exit-address-family
!
Device C的配置文件
!
router bgp 65537
bgp confederation identifier 100
bgp confederation peers 65536 65538
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.1 remote-as 65536
neighbor 10.1.1.1 ebgp-multihop 2
neighbor 10.1.1.1 update-source Loopback 0
neighbor 10.1.1.4 remote-as 65537
neighbor 10.1.1.4 update-source Loopback 0
neighbor 10.1.1.5 remote-as 65538
neighbor 10.1.1.5 ebgp-multihop 2
neighbor 10.1.1.5 update-source Loopback 0
address-family ipv4
neighbor 10.1.1.1 activate
neighbor 10.1.1.4 activate
neighbor 10.1.1.5 activate
exit-address-family
!
Device D的配置文件
!
router bgp 65537
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.3 remote-as 65537
neighbor 10.1.1.3 update-source Loopback 0
address-family ipv4
neighbor 10.1.1.3 activate
exit-address-family
!
Device E的配置文件
!
router bgp 65538
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.5 remote-as 65538
neighbor 10.1.1.5 update-source Loopback 0
address-family ipv4
neighbor 10.1.1.5 activate
exit-address-family
!
Device BR1的配置文件
!
router bgp 65538
bgp confederation identifier 100
bgp confederation peers 65537
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.3 remote-as 65537
neighbor 10.1.1.3 ebgp-multihop 2
neighbor 10.1.1.3 update-source Loopback 0
neighbor 10.1.1.6 remote-as 65538
neighbor 10.1.1.6 update-source Loopback 0
neighbor 192.168.6.7 remote-as 200
address-family ipv4
neighbor 10.1.1.3 activate
neighbor 10.1.1.6 activate
neighbor 192.168.6.7 activate
exit-address-family
!
Device BR2的配置文件
!
router bgp 200
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.6.5 remote-as 100
address-family ipv4
network 192.168.6.0
neighbor 192.168.6.5 activate
exit-address-family
!
未配置BGP联盟邻居。
联盟子AS内部未保证全连接。
当存在两条到达同一目的地网段的路由时,通过配置负载均衡可以充分利用网络带宽资源。
在所有设备上开启BGP协议,按图1-6中所示设定AS号(略)。
在Device A与B、Device A与C上分别通过直连接口建立IBGP邻居(略)。
在Device B与Device D、Device C与Device E上分别通过直连接口建立EBGP邻居(略)。
在Device D和Device E上注入相同路由。
在Device A上配置IBGP负载均衡,并打开AS-PATH宽松比较模式。
配置Device A路由信息,并在D和E上重分发直连路由信息。
# Device A配置。
Device A# configure terminal
Device A(config)# ip route 10.3.0.0 255.255.0.0 10.1.1.2
Device A(config)# ip route 10.4.0.0 255.255.0.0 10.2.1.2
# Device D配置。
Device D# configure terminal
Device D(config)# router bgp 65531
Device D(config-router)# redistribute connected
# E设备配置。
Device E# configure terminal
Device E(config)# router bgp 65532
Device E(config-router)# redistribute connected
A上配置AS-PATH宽松比较模式下的负载均衡。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 65530
Device A(config-router)# maximum-paths ibgp 2
Device A(config-router)# bgp bestpath as-path multipath-relax
# Device A查看BGP信息。
Device A# show ip bgp summary
BGP router identifier 10.2.1.1, local AS number 65530
BGP table version is 9
2 BGP AS-PATH entries
0 BGP Community entries
3 BGP Prefix entries (Maximum-prefix:4294967295)
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
172.16.23.140 4 65530 29 25 8 0 0 00:18:48 2
172.16.23.141 4 65530 24 21 8 0 0 00:17:58 2
Device A# show ip bgp
BGP table version is 9, local router ID is 10.2.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*>i10.3.0.0/16 10.3.1.1 0 100 0 65531 ?
*>i10.4.0.0/16 10.4.1.1 0 100 0 65532 ?
* i10.5.0.0/16 10.3.1.1 0 100 0 65531 ?
*>i 10.4.1.1 0 100 0 65532 ?
Total number of prefixes 3
Device A# show ip bgp 10.5.0.0
BGP routing table entry for 10.5.0.0/16
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Not advertised to any peer
65532
10.4.1.1 from 10.2.1.2 (172.16.24.1)
Origin incomplete, metric 0, localpref 100, valid, internal, multipath, best
Last update: Mon Mar 21 03:45:14 2011
65531
10.3.1.1 from 10.1.1.2 (172.16.25.1)
Origin incomplete, metric 0, localpref 100, valid, internal, multipath
Last update: Mon Mar 21 03:45:14 2011
Device A# show ip route
Codes: C - connected, S - static, R - RIP, B - BGP
O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default
Gateway of last resort is no set
C 10.1.0.0/16 is directly connected, FastEthernet 0/0
C 10.1.1.1/32 is local host.
C 10.2.0.0/16 is directly connected, FastEthernet 0/1
C 10.2.1.1/32 is local host.
S 10.3.0.0/16 [1/0] via 10.1.1.2
S 10.4.0.0/16 [1/0] via 10.2.1.2
B 10.5.0.0/16 [200/0] via 10.3.1.1, 00:27:56
[200/0] via 10.4.1.1, 00:27:56
Device A的配置文件
!
router bgp 65530
bgp bestpath as-path multipath-relax
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
address-family ipv4
maximum-paths ibgp 2
exit-address-family
!
ip route 10.3.0.0 255.255.0.0 10.1.1.2
ip route 10.4.0.0 255.255.0.0 10.2.1.2
!
Device D的配置文件
!
router bgp 65531
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
address-family ipv4
redistribute connected
exit-address-family
!
Deivce E的配置文件
!
router bgp 65532
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
address-family ipv4
redistribute connected
exit-address-family
!
多跳BGP路径优先级不一致,导致无法负载均衡。
撤销指定的路由信息。
BGP快速撤销指定路由组网图
在所有设备上开启BGP协议(略)。
在Device A和Device B间建立BGP邻居关系(略)。
在Device A上配置ACL规则。
在Device A上配置快速撤销指定路由。
配置ACL规则,允许地址1.1.1.1。
# Device A配置
Device A# configure terminal
Device A(config)# ip access-list standard 1
Device A(config-std-nacl)# permit 1.1.1.1 0.0.0.0
Device A(config-std-nacl)# exit
配置快速撤销指定路由1.1.1.1。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 65530
Device A(config-router)# neighbor 192.168.1.2 remote-as 65531
Device A(config-router)# bgp fast-withdraw access-list 1
# Device A查看BGP路由信息。
Device A# show run router bgp
router bgp 65530
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.1.2 remote-as 65531
address-family ipv4
bgp fast-withdraw access-list 1
neighbor 192.168.1.2 activate
exit-address-family
Device A的配置文件
!
ip access-list standard 1
10 permit host 1.1.1.1
!
router bgp 65530
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.1.2 remote-as 65531
address-family ipv4
bgp fast-withdraw access-list 1
neighbor 192.168.1.2 activate
exit-address-family
!
当本地BGP的真实AS发生变化时,通过与对等体设备之间虚拟一个新的AS 23,使得不需要改变对等体设备的 BGP。
BGP Local-AS组网图
在Device A和Device B之间建立EBGP邻居,并指定该EBGP邻居Local-AS 23。
在Device B上创建EBGP邻居与A建立连接。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 3600
Device A(config-router)# neighbor 57.50.1.1 remote-as 5750
Device A(config-router)# neighbor 57.50.1.1 update-source loopback 0
Device A(config-router)# neighbor 57.50.1.1 ebgp-multihop 255
Device A(config-router)# neighbor 57.50.1.1 local-as 23 no-prepend replace-as dual-as
# Device B配置
Device B# configure terminal
Device B(config)# router bgp 5750
Device B(config-router)# neighbor 36.0.1.1 remote-as 23
Device B(config-router)# neighbor 36.0.1.1 update-source loopback 0
Device B(config-router)# neighbor 36.0.1.1 ebgp-multihop 255
# Device A查看BGP邻居状态。
Device A# show ip bgp neighbors 57.50.1.1
BGP neighbor is 57.50.1.1, remote AS 5750, local AS 23(using Peer's Local AS, no-prepend, replace-as, dual-as), external link
BGP version 4, remote router ID 0.0.0.0
BGP state = Idle
Last read, hold time is 180, keepalive interval is 60 seconds
Received 0 messages, 0 notifications, 0 in queue
open message:0 update message:0 keepalive message:0
refresh message:0 dynamic cap:0 notifications:0
Sent 0 messages, 0 notifications, 0 in queue
Device A的配置文件
!
router bgp 3600
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 57.50.1.1 remote-as 5750
neighbor 57.50.1.1 local-as 23 no-prepend replace-as dual-as
neighbor 57.50.1.1 ebgp-multihop 255
neighbor 57.50.1.1 update-source Loopback 0
address-family ipv4
neighbor 57.50.1.1 activate
exit-address-family
!
Device B的配置文件
!
router bgp 5750
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 36.0.1.1 remote-as 23
neighbor 36.0.1.1 ebgp-multihop 255
neighbor 36.0.1.1 update-source Loopback 0
address-family ipv4
neighbor 36.0.1.1 activate
exit-address-family
!
保障在协议重新启动过程中,实现数据转发不间断。
在所有设备上开启BGP协议,按图1-9中所示设定AS号(略)。
在Device B、Device C和Device D上配置环回口,通过该环回口建立IBGP邻居(略)。
在Device A、Device A通过直连接口建立EBGP邻居(略)。
在Device A、Device B、Device C、Device D上开启BGP GR功能。
# Device A配置。
Device A# configure terminal
Device A(config)# router ospf 1
Device A(config-router)# graceful-restart
Device A(config-router)# exit
Device A(config)# router bgp 200
Device A(config-router)# bgp graceful-restart
# Device B配置。
Device B# configure terminal
Device B(config)# router ospf 1
Device B(config-router)# graceful-restart
Device B(config-router)# exit
Device B(config)# router bgp 100
Device B(config-router)# bgp graceful-restart
# Device C配置。
Device C# configure terminal
Device C(config)# router ospf 1
Device C(config-router)# graceful-restart
Device C(config-router)# exit
Device C(config)# router bgp 100
Device C(config-router)# bgp graceful-restart
# Device D配置。
Device D# configure terminal
Device D(config)# router ospf 1
Device D(config-router)# graceful-restart
Device D(config-router)# exit
Device D(config)# router bgp 100
Device D(config-router)# bgp graceful-restart
# Device B使用show ip ospf命令查看OSPF路由状态。
Device B# show ip ospf
Routing Process "ospf 1" with ID 10.0.0.2
Process uptime is 4 minutes
Process bound to VRF default
Conforms to RFC2328, and RFC1583Compatibility flag isenabled
Supports only single TOS(TOS0) routes
Supports opaque LSA
This router is an ASBR (injecting external routing information)
SPF schedule delay 5 secs, Hold time between two SPFs 10 secs
LsaGroupPacing: 240 secs
Number of incomming current DD exchange neighbors 0/5
Number of outgoing current DD exchange neighbors 0/5
Number of external LSA 4. Checksum 0x0278E0
Number of opaque AS LSA 0. Checksum 0x000000
Number of non-default external LSA 4
External LSA database is unlimited.
Number of LSA originated 6
Number of LSA received 2
Log Neighbor Adjency Changes : Enabled
Graceful-restart enabled
Graceful-restart helper support enabled
Number of areas attached to this router: 1
Area 0 (BACKBONE)
# Device B使用show ip bgp neighbors命令查看BGP邻居状态。
Device B# show ip bgp neighbors
BGP neighbor is 192.168.195.183, remote AS 200, local AS 100, external link
Using BFD to detect fast fallover - BFD session state up
BGP version 4, remote router ID 10.0.0.1
BGP state = Established, up for 00:06:37
Last read 00:06:37, hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Address family IPv4 Unicast: advertised and received
Graceful restart: advertised and received
Remote Restart timer is 120 seconds
Address families preserved by peer:
None
Device A的配置文件
router bgp 200
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
address-family ipv4
exit-address-family
!
router ospf 1
graceful-restart
!
Device B的配置文件
router bgp 100
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
address-family ipv4
exit-address-family
!
router ospf 1
graceful-restart
!
Device C的配置文件
router bgp 100
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
address-family ipv4
exit-address-family
!
router ospf 1
graceful-restart
!
Device D的配置文件
router bgp 100
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
address-family ipv4
exit-address-family
!
router ospf 1
graceful-restart
!
IGP协议未开启GR。
BGP邻居设备未开启GR。
在不同AS下交互IPv6路由信息。
在所有设备上开启BGP协议,按图1-10中所示设定AS号(略)。
配置BGP邻居,关闭邻居IPv4地址族能力,并激活IPv6地址族能力。
配置BGP通告IPv6路由。
配置BGP并激活IPv6地址族。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 65530
Device A(config-router)# neighbor 100::1 remote-as 65531
Device A(config-router)# address-family ipv4
Device A(config-router-af)# no neighbor 100::1 activate
Device A(config-router-af)# exit-address-family
Device A(config-router)# address-family ipv6
Device A(config-router-af)# neighbor 100::1 activate
# Device B配置。
Device B# configure terminal
Device B(config)# router bgp 65531
Device B(config-router)# neighbor 100::2 remote-as 65530
Device B(config-router)# address-family ipv4
Device B(config-router-af)# no neighbor 100::2 activate
Device B(config-router-af)# exit-address-family
Device B(config-router)# address-family ipv6
Device B(config-router-af)# neighbor 100::2 activate
配置通告IPv6网络信息。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 65530
Device A(config-router)# address-family ipv6
Device A(config-router-af)# network 30::1/128
# Device A查看BGP邻居状态。
Device A# show bgp ipv6 unicast summary
BGP router identifier 1.1.1.1, local AS number 65530
BGP table version is 1
1 BGP AS-PATH entries
0 BGP Community entries
1 BGP Prefix entries (Maximum-prefix:4294967295)
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
100::1 4 65531 4 6 1 0 0 00:01:49 0
Total number of neighbors 1
# Device B查看BGP邻居状态。
Device B# show bgp ipv6 unicast
BGP table version is 4, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale, b - backup entry
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 30::1/128 100::2 0 0 65530 i
Total number of prefixes 1
Device A的配置文件
!
router bgp 65530
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 100::1 remote-as 65531
address-family ipv4
no neighbor 100::1 activate
exit-address-family
address-family ipv6
network 30::1/128
neighbor 100::1 activate
exit-address-family
!
Device B的配置文件
!
router bgp 65531
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 100::2 remote-as 65530
address-family ipv4
no neighbor 100::2 activate
exit-address-family
address-family ipv6
neighbor 100::2 activate
exit-address-family
!
BGP邻居未激活IPv6地址族能力。
非6PE场景下,使用了IPv4地址建立邻居交互IPv6路由。
支持2字节AS号的路由器和支持4字节AS号的路由器(采用2字节AS号)建立BGP连接。
支持2字节AS号的路由器和支持4字节AS号的路由器(采用4字节AS号)建立BGP连接。
支持4字节AS号的路由器之间建立BGP连接,一个采用2字节AS号,另外一个用4字节AS号。
在所有设备上开启BGP协议,按图1-11中所示设定AS号(略)。
配置BGP邻居。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 64496
Device A(config-router)# neighbor 172.18.1.2 remote-as 64497
Device A(config-router)# neighbor 172.18.2.3 remote-as 23456
Device A(config-router)# end
# Device B配置。
Device B# configure terminal
Device B(config)# router bgp 64497
Device B(config-router)# neighbor 172.18.1.1 remote-as 64496
Device B(config-router)# neighbor 172.18.3.3 remote-as 1.2
Device B(config-router)# bgp asnotation dot
Device B(config-router)# end
# Device C配置。
Device C# configure terminal
Device C(config)# router bgp 1.2
Device C(config-router)# neighbor 172.18.2.1 remote-as 64496
Device C(config-router)# neighbor 172.18.3.2 remote-as 64497
Device C(config-router)# end
# Device A查看BGP邻居状态。
Device A# show ip bgp summary
BGP router identifier 172.18.1.1, local AS number 64496
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down Statd
172.18.1.2 4 64497 7 7 1 0 0 00:03:04 0
172.18.2.3 4 23456 4 4 1 0 0 00:00:15 0
# Device B查看BGP邻居状态。
Device B# show ip bgp summary
BGP router identifier 172.18.3.2, local AS number 64497
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down Statd
172.18.1.1 4 64496 7 7 1 0 0 00:00:04 0
172.18.3.2 4 1.2 4 4 1 0 0 00:00:16 0
Device A的配置文件
!
router bgp 64496
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 172.18.1.2 remote-as 64497
neighbor 172.18.2.3 remote-as 23456
address-family ipv4
neighbor 172.18.1.2 activate
neighbor 172.18.2.3 activate
exit-address-family
!
Device B的配置文件
!
router bgp 64497
bgp asnotation dot
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 172.18.1.1 remote-as 64496
neighbor 172.18.3.3 remote-as 1.2
address-family ipv4
neighbor 172.18.1.1 activate
neighbor 172.18.3.3 activate
exit-address-family
!
Device C的配置文件
!
router bgp 65538
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 172.18.2.1 remote-as 64496
neighbor 172.18.3.2 remote-as 64497
address-family ipv4
neighbor 172.18.2.1 activate
neighbor 172.18.3.2 activate
exit-address-family
!
配置以IPv6本地链路地址作为邻居更新地址。
在所有设备上开启BGP协议,接口下配置IPv6本地链路地址,按图1-12中所示设定AS号(略)。
配置BGP邻居,关闭邻居IPv4地址族能力,并激活IPv6地址族能力。
配置BGP通告IPv6路由。
开启IPv6地址族能力,并关闭IPv4地址族。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 65530
Device A(config-router)# neighbor fe80:100::1%Gi0/1 remote-as 65531
Device A(config-router)# address-family ipv4
Device A(config-router-af)# no neighbor fe80:100::1%Gi0/1 activate
Device A(config-router-af)# exit-address-family
Device A(config-router)# address-family ipv6
Device A(config-router-af)# neighbor fe80:100::1%Gi0/1 activate
Device A(config-router-af)# network 30::1/128
# Device B配置。
Device B# configure terminal
Device B(config)# router bgp 65531
Device B(config-router)# neighbor fe80:100::2%Gi0/1 remote-as 65530
Device B(config-router)# address-family ipv4
Device B(config-router-af)# no neighbor fe80:100::2%Gi0/1 activate
Device B(config-router-af)# exit-address-family
Device B(config-router)# address-family ipv6
Device B(config-router-af)# neighbor fe80:100::2%Gi0/1 activate
配置IPv6地址通告。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 65530
Device A(config-router)# address-family ipv6
Device A(config-router-af)# network 30::1/128
# Device A查看BGP邻居状态。
Device A# show bgp ipv6 unicast summary
BGP router identifier 1.1.1.1, local AS number 65530
BGP table version is 1
1 BGP AS-PATH entries
0 BGP Community entries
1 BGP Prefix entries (Maximum-prefix:4294967295)
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
fe80:100::1%Gi0/1 4 65531 4 6 1 0 0 00:01:49 0
Total number of neighbors 1
# Device B查看BGP邻居状态。
Device B# show bgp ipv6 unicast
BGP table version is 4, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale, b - backup entry
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 30::1/128 fe80:100::2 0 0 65530 i
Total number of prefixes 1
Device A的配置文件
!
router bgp 65530
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor fe80:100::1%Gi0/1 remote-as 65531
address-family ipv4
no neighbor fe80:100::1%Gi0/1 activate
exit-address-family
address-family ipv6
network 30::1/128
neighbor fe80:100::1%Gi0/1 activate
exit-address-family
!
Device B的配置文件
!
router bgp 65531
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor fe80:100::2%Gi0/1 remote-as 65530
address-family ipv4
no neighbor fe80:100::2%Gi0/1 activate
exit-address-family
address-family ipv6
neighbor fe80:100::2%Gi0/1 activate
exit-address-family
!
邻居配置时使用IPv6本地链路地址指定邻居关系,但是本地配置时未指定更新源为配置该IPv6本地链路地址的接口。
两端只有一端使用了IPv6本地链路地址建立邻居关系。
通过配置NSR实现数据倒换转发不中断。
在所有设备上开启BGP协议,按图1-13中所示设定AS号(略)。
在Device A、Device B上通过直连接口建立EBGP邻居。
在Device A上开启BGP NSR功能。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 65530
Device A(config-router)# neighbor 192.168.1.2 remote-as 65530
Device A(config-router)# neighbor 192.168.1.2 ha-mode nsr
# Device A查看BGP邻居状态。
Device A# show ip bgp neighbors
BGP neighbor is 192.168.1.2, remote AS 65530, local AS 65531, external link
Using BFD to detect fast fallover - BFD session state up
BGP version 4, remote router ID 2.2.2.2
BGP state = Established, up for 00:06:37
Last read 00:06:37, hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Address family IPv4 Unicast: advertised and received
Graceful restart: advertised and received
Remote Restart timer is 120 seconds
Address families preserved by peer:
None
# Device B查看BGP邻居状态。
Device B# show ip bgp neighbors
BGP neighbor is 192.168.1.1, remote AS 65530, local AS 65531, external link
Using BFD to detect fast fallover - BFD session state up
BGP version 4, remote router ID 1.1.1.1
BGP state = Established, up for 00:06:37
Last read 00:06:37, hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Address family IPv4 Unicast: advertised and received
Graceful restart: advertised and received
Remote Restart timer is 120 seconds
Address families preserved by peer:
None
Device A的配置文件
!
router bgp 65530
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
bgp nsr
neighbor 192.168.1.2 remote-as 65530
address-family ipv4
neighbor 192.168.1.2 activate
exit-address-family
!
未配置IGP协议。
BGP邻居设备未开启NSR。
对于非直连的BGP路由情况下,实现递归主机路由。
BGP路由只递归主机路由功能组网图
在所有设备上开启BGP协议,按图中所示设定AS号(略)。
在Device A和Device B上通过环回口建立多跳EBGP邻居(略)。
在Device A和Device B上开启BGP路由只递归主机路由功能。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 65530
Device A(config-router)# bgp recursion host
# Device B配置。
Device B# configure terminal
Device B(config)# router bgp 65531
Device B(config-router)# bgp recursion host
Deviec A的配置文件
!
router bgp 65530
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
address-family ipv4
bgp recursion host
exit-address-family
!
Deviec B的配置文件
!
router bgp 65531
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
address-family ipv4
bgp recursion host
exit-address-family
!
在设备所建立的IBGP或多跳EBGP邻居没有使用Loopback地址来建立的前提下,开启此功能会导致BGP路由无法查找到匹配下一跳地址的主机路由,造成BGP路由下一跳无效、路由无法优选的结果。
防止收到AS-PATH中带有此邻居AS号的路由信息,实现环路检测。
在所有设备上开启BGP协议,按图1-15中所示设定AS号(略)。
在Device A与Device C,Device B与Device C之间建立EBGP邻居(略)。
在Device C上对于Device A及Device B的邻居开启出方向环路检测功能。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 65536
Device A(config-router)# neighbor 192.168.1.2 remote-as 65537
Device A(config-router)# neighbor 192.168.1.2 as-loop-check out
Device A(config-router)# neighbor 192.168.2.2 remote-as 65537
Device A(config-router)# neighbor 192.168.2.2 as-loop-check out
# Device B配置。
Device B# configure terminal
Device B(config)# router bgp 65537
Device B(config-router)# neighbor 192.168.2.1 remote-as 65536
Device B(config-router)# neighbor 192.168.3.2 remote-as 65537
# Device C配置。
Device C# configure terminal
Device C(config)# router bgp 65537
Device C(config-router)# neighbor 192.168.1.1 remote-as 65536
Device C(config-router)# neighbor 192.168.3.1 remote-as 65537
# Device A查看BGP邻居状态。
Device A# show ip bgp neighbors 192.168.2.2
BGP neighbor is 192.168.2.2, remote AS 65537, local AS 65536, external link
Using as path loop detection in announcing route
BGP version 4, remote router ID 192.168.2.2
BGP state = Established, up for 00:06:37
Last read 00:06:37, hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Address family IPv4 Unicast: advertised and received
Graceful restart: advertised and received
Remote Restart timer is 120 seconds
Address families preserved by peer:
None
······
Device A的配置文件
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.1.2 remote-as 65537
neighbor 192.168.2.2 remote-as 65537
address-family ipv4
neighbor 192.168.1.2 activate
neighbor 192.168.1.2 as-loop-check out
neighbor 192.168.2.2 activate
neighbor 192.168.2.2 as-loop-check out
exit-address-family
!
!
router bgp 65537
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.2.1 remote-as 65536
neighbor 192.168.3.2 remote-as 65537
address-family ipv4
neighbor 192.168.2.1 activate
neighbor 192.168.3.2 activate
exit-address-family
!
Device C的配置文件
!
router bgp 65537
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.1.1 remote-as 65536
neighbor 192.168.3.1 remote-as 65537
address-family ipv4
neighbor 192.168.1.1 activate
neighbor 192.168.3.1 activate
exit-address-family
!
实现平滑关闭BGP链接,在经过一定时间(根据所发布的路由个数自动计算或指定的delay time时间)主动与邻居断开BGP连接,降低对网络的影响。
在所有设备上开启BGP协议,按图1-16中所示设定AS号(略)。
在Device A与Device C,Device B与Device C之间建立EBGP邻居(略)。
Device A上配置平滑关闭BGP实例下的所有连接。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 65536
Device A(config-router)# neighbor 192.168.1.2 remote-as 65537
Device A(config-router)# neighbor 192.168.1.2 as-loop-check out
Device A(config-router)# neighbor 192.168.2.2 remote-as 65537
Device A(config-router)# neighbor 192.168.2.2 as-loop-check out
# Device B配置。
Device B# configure terminal
Device B(config)# router bgp 65537
Device B(config-router)# neighbor 192.168.2.1 remote-as 65536
Device B(config-router)# neighbor 192.168.3.2 remote-as 65537
# Device C配置。
Device C# configure terminal
Device C(config)# router bgp 65537
Device C(config-router)# neighbor 192.168.1.1 remote-as 65536
Device C(config-router)# neighbor 192.168.3.1 remote-as 65537
Device C(config-router)# bgp shutdown graceful
# Device C查看BGP邻居状态。
Device C(config)#show ip bgp neighbor 192.168.1.1
For address family: IPv4 Unicast
BGP neighbor is 192.168.1.1, remote AS 65536, local AS 65537, external link
Administratively graceful shut down
BGP version 4, remote router ID 0.0.0.0
BGP state = Idle
Last read , hold time is 30, keepalive interval is 1 seconds
Configured hold time is 30, keepalive interval is 1 seconds
Received 0 messages, 0 notifications, 0 in queue
open message:0 update message:0 keepalive message:0
refresh message:0 dynamic cap:0 notifications:0
Sent 0 messages, 0 notifications, 0 in queue
open message:0 update message:0 keepalive message:0
refresh message:0 dynamic cap:0 notifications:0
Route refresh request: received 0, sent 0
Minimum time between advertisement runs is 30 seconds
Update source is Loopback 0
For address family: IPv4 Unicast
BGP table version 1, neighbor version 0
Index 1, Offset 0, Mask 0x2
0 accepted prefixes
0 announced prefixes
Connections established 0; dropped 0
BGP neighbor may be up to 255 hops away.
Sock_fd: -1
Last Reset: , due to BGP Notification received
Notification Error Message: (Cease/Other Configuration Change.)
Device A的配置文件
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.1.2 remote-as 65537
neighbor 192.168.2.2 remote-as 65537
address-family ipv4
neighbor 192.168.1.2 activate
neighbor 192.168.1.2 as-loop-check out
neighbor 192.168.2.2 activate
neighbor 192.168.2.2 as-loop-check out
exit-address-family
!
Device B的配置文件
!
router bgp 65537
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.2.1 remote-as 65536
neighbor 192.168.3.2 remote-as 65537
address-family ipv4
neighbor 192.168.2.1 activate
neighbor 192.168.3.2 activate
exit-address-family
!
Device C的配置文件
!
router bgp 65537
bgp shutdown graceful
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.1.1 remote-as 65536
neighbor 192.168.3.1 remote-as 65537
address-family ipv4
neighbor 192.168.1.1 activate
neighbor 192.168.3.1 activate
exit-address-family
!
Device A通过VRF vpn1及vpn2接口分别连接两个网络,通过Device A来实现跨VRF的互访。
多路径VRF互导组网图
配置VRF以及VRF静态路由。
配置VRF地址族。
配置将VRF静态路由注入BGP。
配置开启多路径静态路由注入BGP。
配置BGP ECMP。
配置所有路径的路由进行VRF互导。
配置VRF及VRF路由。
# Device A配置。
Device A# configure terminal
Device A(config)# ip vrf vpn1
Device A(config-vrf)# rd 200:1
Device A(config-vrf)# route-target both 100:100
Device A(config-vrf)# exit
Device A(config)# ip vrf vpn2
Device A(config-vrf)# rd 300:1
Device A(config-vrf)# route-target both 100:100
Device A(config-vrf)# exit
Device A(config)# interface GigabitEthernet 0/1
Device A(config-if-GigabitEthernet 0/1)# ip vrf forwarding vpn1
Device A(config-if-GigabitEthernet 0/1)# ip address 44.1.1.2 255.255.255.0
Device A(config-if-GigabitEthernet 0/1)# exit
Device A(config)# interface GigabitEthernet 0/2
Device A(config-if-GigabitEthernet 0/2)# ip vrf forwarding vpn1
Device A(config-if-GigabitEthernet 0/2)# ip address 45.1.1.2 255.255.255.0
Device A(config-if-GigabitEthernet 0/2)# exit
Device A(config)# interface GigabitEthernet 0/3
Device A(config-if-GigabitEthernet 0/3)# ip vrf forwarding vpn2
Device A(config-if-GigabitEthernet 0/3)# ip address 46.1.1.2 255.255.255.0
Device A(config-if-GigabitEthernet 0/3)# exit
Device A(config)# interface GigabitEthernet 0/4
Device A(config-if-GigabitEthernet 0/4)# ip vrf forwarding vpn2
Device A(config-if-GigabitEthernet 0/4)# ip address 47.1.1.2 255.255.255.0
Device A(config-if-GigabitEthernet 0/4)# exit
Device A(config)# ip route vrf vpn1 100.1.1.1 255.255.255.255 44.1.1.1
Device A(config)# ip route vrf vpn1 100.1.1.1 255.255.255.255 45.1.1.1
Device A(config)# ip route vrf vpn2 200.1.1.1 255.255.255.255 46.1.1.1
Device A(config)# ip route vrf vpn2 200.1.1.1 255.255.255.255 47.1.1.1
# Device B配置。
Device B# configure terminal
Device B(config)# ip vrf vpn1
Device B(config-vrf)# rd 200:1
Device B(config-vrf)# route-target both 100:100
Device B(config-vrf)# exit
Device B(config)# interface GigabitEthernet 0/1
Device B(config-if-GigabitEthernet 0/1)# ip vrf forwarding vpn1
Device B(config-if-GigabitEthernet 0/1)# ip address 44.1.1.1 255.255.255.0
Device B(config-if-GigabitEthernet 0/1)# exit
Device B(config)# interface GigabitEthernet 0/2
Device B(config-if-GigabitEthernet 0/2)# ip vrf forwarding vpn1
Device B(config-if-GigabitEthernet 0/2)# ip address 45.1.1.1 255.255.255.0
Device B(config-if-GigabitEthernet 0/2)# exit
Device B(config)# ip route vrf vpn1 100.1.1.2 255.255.255.255 44.1.1.2
Device B(config)# ip route vrf vpn1 100.1.1.2 255.255.255.255 45.1.1.2
# Device C配置。
Device C# configure terminal
Device C(config)# ip vrf vpn2
Device C(config-vrf)# rd 300:1
Device C(config-vrf)# route-target both 100:100
Device C(config-vrf)# exit
Device C(config)# interface GigabitEthernet 0/1
Device C(config-if-GigabitEthernet 0/1)# ip vrf forwarding vpn2
Device C(config-if-GigabitEthernet 0/1)# ip address 46.1.1.1 255.255.255.0
Device C(config-if-GigabitEthernet 0/1)# exit
Device C(config)# interface GigabitEthernet 0/2
Device C(config-if-GigabitEthernet 0/2)# ip vrf forwarding vpn2
Device C(config-if-GigabitEthernet 0/2)# ip address 47.1.1.1 255.255.255.0
Device C(config-if-GigabitEthernet 0/2)# exit
Device C(config)# ip route vrf vpn2 200.1.1.2 255.255.255.255 46.1.1.2
Device C(config)# ip route vrf vpn2 200.1.1.2 255.255.255.255 47.1.1.2
配置多路径静态路由注入BGP,进行VRF互导。
# Device A配置。
Device A# configure terminal
Device A(config)# router bgp 100
Device A(config-router)# address-family ipv4 vrf vpn1
Device A(config-router-af)# redistribute static
Device A(config-router-af)# maximum-paths ebgp 32
Device A(config-router-af)# bgp sourced-paths static all
Device A(config-router-af)# import path selection all
Device A(config-router-af)# exit-address-family
Device A(config-router)# address-family ipv4 vrf vpn2
Device A(config-router-af)# redistribute static
Device A(config-router-af)# maximum-paths ebgp 32
Device A(config-router-af)# bgp sourced-paths static all
Device A(config-router-af)# import path selection all
Device A(config-router-af)# exit-address-family
# Device A查看VRF路由。
Device A# show ip route vrf vpn1
Routing Table: vpn1
Codes: C - Connected, L - Local, S - Static
R - RIP, O - OSPF, B - BGP, I - IS-IS, V - Overflow route
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
SU - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
IA - Inter area, A - Arp to host
* - candidate default
Gateway of last resort is no set
C 44.1.1.0/24 is directly connected, GigabitEthernet 0/1
C 44.1.1.2/32 is local host.
C 45.1.1.0/24 is directly connected, GigabitEthernet 0/2
C 45.1.1.2/32 is local host.
S 100.1.1.1/32 [1/0] via 44.1.1.1
[1/0] via 45.1.1.1
B 200.1.1.1/32 [20/0] via 47.1.1.1, 02:32:01
[20/0] via 46.1.1.1, 02:32:01
Device A# show ip route vrf vpn2
Routing Table: vpn2
Codes: C - Connected, L - Local, S - Static
R - RIP, O - OSPF, B - BGP, I - IS-IS, V - Overflow route
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
SU - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
IA - Inter area, A - Arp to host
* - candidate default
Gateway of last resort is no set
C 46.1.1.0/24 is directly connected, GigabitEthernet 0/3
C 46.1.1.2/32 is local host.
C 47.1.1.0/24 is directly connected, GigabitEthernet 0/4
C 47.1.1.2/32 is local host.
B 100.1.1.1/32 [20/0] via 45.1.1.1, 03:27:07
[20/0] via 44.1.1.1, 03:27:07
S 200.1.1.1/32 [1/0] via 46.1.1.1
[1/0] via 47.1.1.1
Device A的配置文件
!
ip vrf vpn1
rd 200:1
route-target both 100:100
!
ip vrf vpn2
rd 300:1
route-target both 100:100
!
interface GigabitEthernet 0/1
no switchport
ip vrf forwarding vpn1
ip address 44.1.1.2 255.255.255.0
!
interface GigabitEthernet 0/2
no switchport
ip vrf forwarding vpn1
ip address 45.1.1.2 255.255.255.0
!
interface GigabitEthernet 0/3
no switchport
ip vrf forwarding vpn2
ip address 46.1.1.2 255.255.255.0
!
interface GigabitEthernet 0/4
no switchport
ip vrf forwarding vpn2
ip address 47.1.1.2 255.255.255.0
!
router bgp 100
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
address-family ipv4
exit-address-family
!
address-family ipv4 vrf vpn1
maximum-paths ebgp 32
bgp sourced-paths static all
import path selection all
redistribute static
exit-address-family
!
address-family ipv4 vrf vpn2
maximum-paths ebgp 32
bgp sourced-paths static all
import path selection all
redistribute static
exit-address-family
!
ip route vrf vpn1 100.1.1.1 255.255.255.255 44.1.1.1
ip route vrf vpn1 100.1.1.1 255.255.255.255 45.1.1.1
ip route vrf vpn2 200.1.1.1 255.255.255.255 46.1.1.1
ip route vrf vpn2 200.1.1.1 255.255.255.255 47.1.1.1
!
Device B的配置文件
!
ip vrf vpn1
rd 200:1
route-target both 100:100
!
interface GigabitEthernet 0/1
no switchport
ip vrf forwarding vpn1
ip address 44.1.1.1 255.255.255.0
!
interface GigabitEthernet 0/2
no switchport
ip vrf forwarding vpn1
ip address 45.1.1.1 255.255.255.0
!
ip route vrf vpn1 100.1.1.2 255.255.255.255 44.1.1.2
ip route vrf vpn1 100.1.1.2 255.255.255.255 45.1.1.2
!
Device C的配置文件
!
ip vrf vpn2
rd 300:1
route-target both 100:100
!
interface GigabitEthernet 0/1
no switchport
ip vrf forwarding vpn2
ip address 46.1.1.1 255.255.255.0
!
interface GigabitEthernet 0/2
no switchport
ip vrf forwarding vpn2
ip address 47.1.1.1 255.255.255.0
!
ip route vrf vpn2 200.1.1.2 255.255.255.255 46.1.1.2
ip route vrf vpn2 200.1.1.2 255.255.255.255 47.1.1.2
!
Device A与Device B建立的BGP对等体受BMP Server监控。
BMP监控组网图
配置BGP基础功能(略)。
配置BMP Server实例相关信息(地址、端口号、监控路由类型)。
配置BGP对等体受BMP server监控。
配置BMP server实例相关信息。
# Device A配置。
Device A# configure
Device A(config)# bmp server 1
Device A(config-bmpsrvr)# address 11.1.1.2 port 12345
Device A(config-bmpsrvr)# update-source gigabitEthernet 0/1
Device A(config-bmpsrvr)# adj-rib-in post-policy
配置BGP对等体受BMP server监控。
# Device A配置。
Device A(config)# router bgp 100
Device A(config-router)# neighbor 10.1.1.2 remote-as 100
Device A(config-router)# neighbor 10.1.1.2 bmp-active server 1
# Device A查看BGP信息。
Device A# show bgp all summary
For address family: IPv4 Unicast
BGP router identifier 11.1.1.1, local AS number 100
BGP table version is 1
1 BGP AS-PATH entries
0 BGP Community entries
25 BGP Prefix entries (Maximum-prefix:262144)
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.1.1.2 4 100 0 0 0 0 0 05:36:32 23
Device A# show bgp bmp neighbor
Neighbor CfgSvr# ActSvr#
10.1.1.2 1 1
Device A# show bgp bmp summary
ID Host Port State Time NBRs
1 11.1.1.2 12345 Established 05:36:12 1
Device A的配置文件
!
router bgp 100
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 10.1.1.2 remote-as 100
neighbor 10.1.1.2 bmp-active server 1
address-family ipv4
neighbor 10.1.1.2 activate
exit-address-family
!
bmp server 1
address 11.1.1.2 port 12345
update-source GigabitEthernet 0/1
adj-rib-in post-policy
!
在设备支持发布多条相同前缀的路由给邻居时,通过定义ADD-PATH使得多条链路形成负载分担或备份,增加网络链路的可靠性。
如图1-19中,配置Device A、Device B、Device C、Device D和Device RR之间的互联地址,Device A、Device B、Device C和Device RR之间配置IBGP邻居,Device RR为BGP路由反射器,配置Device B和Device D、Device C和Device D为EBGP邻居。
Device D上配置Loopback地址,并发布到BGP中。
Device RR上配置ADD-PATH发布能力,Device A上配置ADD-PATH接收能力。
配置Device A、Device B、Device C、Device D的BGP基本功能及接口IP地址。
# Device A配置。
Device A# configure terminal
Device A(config)# interface GigabitEthernet 0/1
Device A(config-if-GigabitEthernet 0/1)# ip address 192.168.1.1 255.255.255.0
Device A(config-if-GigabitEthernet 0/1)# exit
Device A(config)# router bgp 65536
Device A(config-router)# neighbor 192.168.1.5 remote-as 65536
Device A(config-router)# neighbor 192.168.1.5 additional-paths receive
# Device B配置。
Device B# configure terminal
Device B(config)# interface GigabitEthernet 0/1
Device B(config-if-GigabitEthernet 0/1)# ip address 192.168.2.2 255.255.255.0
Device B(config-if-GigabitEthernet 0/1)# exit
Device B(config)# interface GigabitEthernet 0/2
Device B(config-if-GigabitEthernet 0/2)# ip address 192.168.4.2 255.255.255.0
Device B(config-if-GigabitEthernet 0/2)# exit
Device B(config)# router bgp 65536
Device B(config-router)# neighbor 192.168.2.5 remote-as 65536
Device B(config-router)# neighbor 192.168.4.4 remote-as 65535
# Device C配置。
Device C# configure terminal
Device C(config)# interface GigabitEthernet 0/1
Device C(config-if-GigabitEthernet 0/1)# ip address 192.168.3.3 255.255.255.0
Device C(config-if-GigabitEthernet 0/1)# exit
Device C(config)# interface GigabitEthernet 0/2
Device C(config-if-GigabitEthernet 0/2)# ip address 192.168.5.3 255.255.255.0
Device C(config-if-GigabitEthernet 0/2)# exit
Device C(config)# router bgp 65536
Device C(config-router)# neighbor 192.168.3.5 remote-as 65536
Device C(config-router)# neighbor 192.168.5.4 remote-as 65535
# Device D配置。
Device D# configure terminal
Device D(config)# interface loopback 0
Device D(config-if-Loopback 0)# ip address 10.1.1.4 255.255.255.255
Device D(config-if-Loopback 0)# exit
Device D(config)# interface GigabitEthernet 0/1
Device D(config-if-GigabitEthernet 0/1)# ip address 192.168.4.4 255.255.255.0
Device D(config-if-GigabitEthernet 0/1)# exit
Device D(config)# interface GigabitEthernet 0/1
Device D(config-if-GigabitEthernet 0/1)# ip address 192.168.5.4 255.255.255.0
Device D(config-if-GigabitEthernet 0/1)# exit
Device D(config)# router bgp 65535
Device D(config-router)# neighbor 192.168.4.2 remote-as 65536
Device D(config-router)# neighbor 192.168.5.3 remote-as 65536
Device D(config-router)# network 10.1.1.4 mask 255.255.255.255
# Device RR配置。
Device RR# configure terminal
Device RR(config)# interface loopback 0
Device RR(config-if-Loopback 0)# ip address 10.1.1.5 255.255.255.255
Device RR(config-if-Loopback 0)# exit
Device RR(config)# interface GigabitEthernet 0/1
Device RR(config-if-GigabitEthernet 0/1)# ip address 192.168.1.5 255.255.255.0
Device RR(config-if-GigabitEthernet 0/1)# exit
Device RR(config)# interface GigabitEthernet 0/2
Device RR(config-if-GigabitEthernet 0/2)# ip address 192.168.2.5 255.255.255.0
Device RR(config-if-GigabitEthernet 0/2)# exit
Device RR(config)# interface GigabitEthernet 0/3
Device RR(config-if-GigabitEthernet 0/3)# ip address 192.168.3.5 255.255.255.0
Device RR(config-if-GigabitEthernet 0/3)# exit
Device RR(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.2
Device RR(config)#ip route 192.168.5.0 255.255.255.0 192.168.3.3
Device RR(config)# router bgp 65536
Device RR(config-router)# neighbor 192.168.1.1 remote-as 65536
Device RR(config-router)# neighbor 192.168.1.1 route-reflector-client
Device RR(config-router)# neighbor 192.168.2.2 remote-as 65536
Device RR(config-router)# neighbor 192.168.2.2 route-reflector-client
Device RR(config-router)# neighbor 192.168.3.3 remote-as 65536
配置反射器RR的ADD-PATH规则。
# Device RR配置。
Device RR# configure terminal
Device RR(config)# router bgp 65536
Device RR(config-router)# bgp additional-paths select best 2
Device RR(config-router)# neighbor 192.168.1.1 advertise additional-paths best 2
Device RR(config-router)# neighbor 192.168.1.1 additional-paths send
# Device RR查看BGP邻居状态。
Device RR# show ip bgp
BGP table version is 3, local router ID is 10.1.1.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale, b - backup entry, a additional-path
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* ia10.1.1.4/32 192.168.4.4 0 100 0 65535 i
*>i 192.168.5.4 0 100 0 65535 i
Total number of prefixes 2
# Device A使用show命令查看BGP邻居状态。
Device A# show ip bgp
BGP table version is 2, local router ID is 192.168.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale, b - backup entry, a additional-path
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i 10.1.1.4/32 192.168.5.4 0 100 0 65535 i
* i 192.168.4.4 0 100 0 65535 i
Total number of prefixes 2
Device A的配置文件
!
interface GigabitEthernet 0/1
no switchport
ip address 192.168.1.1 255.255.255.0
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.1.5 remote-as 65536
address-family ipv4
neighbor 192.168.1.5 activate
neighbor 192.168.1.5 additional-paths receive
exit-address-family
!
Device B的配置文件
!
interface GigabitEthernet 0/1
no switchport
ip address 192.168.2.2 255.255.255.0
!
interface GigabitEthernet 0/2
no switchport
ip address 192.168.4.2 255.255.255.0
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.2.5 remote-as 65536
neighbor 192.168.4.4 remote-as 65535
address-family ipv4
neighbor 192.168.2.5 activate
neighbor 192.168.4.4 activate
exit-address-family
!
Device C的配置文件
!
interface GigabitEthernet 0/1
no switchport
ip address 192.168.3.3 255.255.255.0
!
interface GigabitEthernet 0/2
no switchport
ip address 192.168.5.3 255.255.255.0
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.3.5 remote-as 65536
neighbor 192.168.5.4 remote-as 65535
address-family ipv4
neighbor 192.168.3.5 activate
neighbor 192.168.5.4 activate
exit-address-family
!
Device C的配置文件
!
interface GigabitEthernet 0/1
no switchport
ip address 192.168.4.4 255.255.255.0
!
interface GigabitEthernet 0/2
no switchport
ip address 192.168.5.4 255.255.255.0
!
interface Loopback 0
ip address 10.1.1.4 255.255.255.255
!
router bgp 65535
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.4.2 remote-as 65536
neighbor 192.168.5.3 remote-as 65536
address-family ipv4
network 10.1.1.4 mask 255.255.255.255
neighbor 192.168.4.2 activate
neighbor 192.168.5.3 activate
exit-address-family
!
Device RR的配置文件
!
interface GigabitEthernet 0/1
no switchport
ip address 192.168.1.5 255.255.255.0
!
interface GigabitEthernet 0/2
no switchport
ip address 192.168.2.5 255.255.255.0
!
interface GigabitEthernet 0/3
no switchport
ip address 192.168.3.5 255.255.255.0
!
interface Loopback 0
ip address 10.1.1.5 255.255.255.255
!
router bgp 65536
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 192.168.1.1 remote-as 65536
neighbor 192.168.2.2 remote-as 65536
neighbor 192.168.3.3 remote-as 65536
address-family ipv4
bgp additional-paths select best 2
neighbor 192.168.1.1 activate
neighbor 192.168.1.1 route-reflector-client
neighbor 192.168.1.1 additional-paths send
neighbor 192.168.1.1 advertise additional-paths best 2
neighbor 192.168.2.2 activate
neighbor 192.168.2.2 route-reflector-client
neighbor 192.168.3.3 activate
exit-address-family
!