赞
踩
在建立对等体关系时两端要协商Hold time,并保持一致。如果两端所配置的Hold time时间不同,则BGP会选择较小的值作为协商的结果。如果在这个时间内未收到对端发来的Keepalive消息,则认为BGP连接中断。如果保持时间为0,则标识不发送Keepalive报文。默认保持时间是Keepalive Time的3倍,180s。
当一个IBGP收到一个IBGP邻居的路由时他不会再将这条路由传递给下一个IBGP邻居,这个功能主要是防环,但是会导致IBGP内部的路由无法传输。
BGP按照运行方式分为EBGP(External/Exterior BGP)和IBGP(Internal/Interior BGP)。
运行于不同AS之间的BGP称为EBGP。为了防止AS间产生环路,当BGP设备接收EBGP对等体发送的路由时,会将带有本地AS号的路由丢弃。
运行于同一AS内部的BGP称为IBGP。为了防止AS内产生环路,BGP设备不将从IBGP对等体学到的路由通告给其他IBGP对等体,并与所有IBGP对等体建立全连接。为了解决IBGP对等体的连接数量太多的问题,BGP设计了路由反射器和BGP联盟。
发送BGP报文的设备称为BGP发言者(Speaker),它接收或产生新的报文信息,并发布(Advertise)给其它BGP Speaker。
相互交换报文的Speaker之间互称对等体(Peer)。若干相关的对等体可以构成对等体组(Peer Group)。
BGP对等体间通过以下5种报文进行交互,其中Keepalive报文为周期性发送,其余报文为触发式发送:
用于建立BGP对等体连接。
Version:4 -----表示BGP的版本为4
My AS:本地AS编号
Hold Time:180 保持时间,默认是180,这里是默认时间
BGP Identifier:BGP路由器的Router ID,以IP地址的形式表示,用来识别BGP路由器。
Parameters Length:14 可选参数的长度为14
用于在对等体之间交换路由信息。
Withdrawn Routes Length :0 不可达路由长度,在更新是为0
Path Attribute:显示BGP邻居的相关的信息
Network Layer Reachability Information :2.2.2.2/32 更新路由,与撤销路由对应
Withdrawn Routes Length :5 不可达路由长度,这里是撤销,所以不为0
Withdrawn Routes :2.2.2.2/32(变长) 撤销路由。这里显示撤销的具体路由
用于中断BGP连接。
Errorcode:错误码为6
Errsubcode 由于这里是错误码6,所以没有错误子码
用于保持BGP连接。
在cisco的报文中间是没有这个报文的,这里由于普遍出现,所以记录一下
用于在改变路由策略后请求对等体重新发送路由信息。只有支持路由刷新(Route-refresh)能力的BGP设备会发送和响应此报文。
BGP对等体的交互过程中存在6种状态机:空闲(Idle)、连接(Connect)、活跃(Active)、Open报文已发送(OpenSent)、Open报文已确认(OpenConfirm)和连接已建立(Established)。在BGP对等体建立的过程中,通常可见的3个状态是:Idle、Active和Established。
Idle状态是BGP初始状态。在Idle状态下,BGP拒绝邻居发送的连接请求。只有在收到本设备的Start事件后,BGP才开始尝试和其它BGP对等体进行TCP连接,并转至Connect状态。
在Connect状态下,BGP启动连接重传定时器(Connect Retry),等待TCP完成连接。
在Active状态下,BGP总是在试图建立TCP连接。
在OpenSent状态下,BGP等待对等体的Open报文,并对收到的Open报文中的AS号、版本号、认证码等进行检查。
在OpenConfirm状态下,BGP等待Keepalive或Notification报文。
在Established状态下,BGP可以和对等体交换Update、Keepalive、Route-refresh报文和Notification报文。
一共10条,Cisco有11条,weight是Cisco私有属性
1、公认必遵:Origin,AS-path,Next-hop BGP必须都能识别,且在更新消息必须包含
2、公认可遵:local-pref,auto-aggregate 必须都能识别,更新消息可自由选择是否包含的属性
3、可选传递:aggregator,community 可以不识别,但是要接受并将其转发给它的对等体
4、可选非传递:MED,Originator-ID,cluster-list,weight 可以不识别,可以不转发
在AS之间建立防环
指出包含在update报文中的路由信息所经过的自治系统号。
Router(config)#router bgp 1
Router(config-router)#neighbor 1.1.1.1 next-hop-self //把下一跳修改为自己
access-list 1 permit 1.1.1.1
route-map A permit 10
match ip address 1
set local-pre 300
route-map A permit 10
用来警告下游路由器路由聚合后产生的路由路径丢失。
BGP支持向BGP邻居传递重叠路由,可以选择多种方式:
Router(config)#router bgp 1
Router(config-router)#neighbor IBGP peer-group //设置peer-froup组
Router(config-router)#neighbor IBGP remote-as 12345 //设置相应的参数
Router(config-router)#neighbor IBGP update-source loopback 1
Router(config-router)#neighbor 2.2.2.2 peer-group IBGP //领域引用IBGP组成
Router(config)#router bgp 1
Router(config-router)#neighbor 2.2.2.2 route-map MED out //选择策略路由
Router(config)#route-map MED permit 20
Router(config-route-map)#match ip address prefix-list 134 //匹配路由
Router(config-route-map)#set metric 150 //修改metric
Router(config)#ip prefix-list 134 seq 5 permit 123.0.0.0/8 le 32 //抓取路由
路由反射器使用该属性,不接收与自己相同的起源者ID的路由,防止环路。
在AS内部始发路由的设备,Originator-ID用于防止集群内产生路由环路
路由反射器使用该属性,不接收与自己相同的簇列表的路由,防止集群间产生环路。
在生产的环境环境中间会配置多个领域反射器组,这个时候就不能使用Originator-ID了。
Weight属性是Cisco私有属性,只有Cisco的路由器才能识别weight。 华为私有的私有属性是preference value
1、路由的weight属性只在本地路由器起作用,BGP将路由传递给邻居时,并不保留weight。Weight值的范围0~65535,默认为0,如果是BGP本地发起路由,weight值32768。
2、当到达同一目的地存在多条路径时,优选weight值大的。在Cisco路由器中,比较最优路径的第一条规则就是比较weight值,所以只要改动weight值,就能控制Cisco路由器的BGP选路。
#R1的配置
int lo 0
ip add x.x.x.x 255.255.255.255
ip route y.y.y.y 255.255.255.255 gi0/0
router bgp 12
neighbor y.y.y.y remote 12
neighbor y.y..y.y update-source lo0
#R2的配置
int lo 0
ip add y.y.y.y 255.255.255.255
ip rote x.x.x.x 255.255.255.255 gi0/0
router bgp 12
neighbor x.x.x.x remote 12
neighbor x.x.x.x update-source lo0 //不指定接口下,会使用接口地址建立连接
Router(config)#router bgp 123
Router(config-router)#bgp router-id 1.1.1.1
Router(config-router)#neighbor 10.1.1.1 remote-as 123
Router(config)#router bgp 1
Router(config-router)#bgp router-id 1.1.1.1
Router(config-router)#neighbor IBGP peer-group //设置peer-froup组
Router(config-router)#neighbor IBGP remote-as 12345 //设置相应的参数
Router(config-router)#neighbor10.1.1.1 peer-group IBGP //领域引用IBGP组成
Router(config)#router bgp 1
Router(config-router)#neighbor IBGP peer-group //设置peer-froup组
Router(config-router)#neighbor IBGP remote-as 12345 //设置相应的参数
Router(config-router)#bgp listen range 10.1.1.0/24 peer-group IBGP //监听整个段
R1(config)#router bgp 64512
R1(config-router)#nei 10.1.255.2 password supercisco
Router#sh ip bgp all summary
For address family: IPv4 Unicast
BGP router identifier 2.2.2.2, local AS number 12
BGP table version is 2, main routing table version 2
1 network entries using 140 bytes of memory
1 path entries using 80 bytes of memory
1/1 BGP path/bestpath attribute entries using 144 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 364 total bytes of memory
BGP activity 1/0 prefixes, 1/0 paths, scan interval 60 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
1.1.1.1 4 12 77 81 2 0 0 01:06:03 0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。