1、AS--自治系统
由同1个管理组织一组路由器,有相同策略
0-65535
公有AS:1-64511
私有AS:64512-65535=1024
route-views.routeviews.org
2、为什么使用BGP
1)承载大量路由---37W(增长中....2011年04月07日)
2)路由策略
实际使用:MAN多个出口
MPLS×××
3、什么时候不使用BGP
1)设备资源不足:2G
2)不是很懂BGP
3)单出口
4、 BGP特点:
1)BGP是属于EGP、无类、DV路由协议
不同AS之间使用---->EGP
2)BGP是一个路径vector路由协议
AS-BY-AS而不是hop-by-hop
3)可靠更新:工作在TCP=179端口上
4)BGP采用增量、触发更新
5)周期性keepalive检验tcp连接
6)有丰富属性-->控制路由选择
5、BGP三张表
1)邻居表
sh ip bgp summary
sh ip bgp neighbor
2)BGP数据库
列出BGP所有的路由条目(包含最佳和次佳)
sh ip bgp
*>
3)路由表
把BGP表中最佳的路径放到转发表中
sh ip route bgp
6、BGP数据包结构
1)open +keepalive=hello
routerid holdtime
2)keepalive 只有头部大小=19byte
60sec holdtime=180sec
3)update:
最佳路由=网络号+mask+属性
*>
4)notification
发现有错误,报警,撤除TCP连接
7、BGP邻居
1)IBGP
(1)同1个AS形成的邻居
(2)条件:只要可达
(3)过程:建邻居--->建立TCP连接---->发包---->查找IGP路由
(4)IBGP通常使用loopback建立邻居
2)EBGP
(1)不同AS形成的邻居
(2)条件:直连
(3)通常是使用物理接口建立邻居
8、BGP路由传递
1)控制层面
AS-BY-AS
2)数据层面
hop-by-hop
黑洞:(1)重发布BGP---->IGP 扩展性问题
(2)full-mesh IBGP邻居--->邻居关系多
(3)RR/联邦
(4)MPLS
9、BGP基本配置
1)
R4(config-if)#router bgp 4
R4(config-router)#nei 24.1.1.2 remote-as 123
R2(config-router)#router bgp 123
R2(config-router)#nei 24.1.1.4 remote-as 4
R2(config-router)#nei 3.3.3.3 remote-as 123
R3(config-router)#router bgp 123
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#nei 2.2.2.2 remote-as 123
R3(config-router)#nei 35.1.1.5 remote-as 5
R5(config-router)#bgp router-id 35.1.1.3
R5(config-router)#nei 35.1.1.3 remote-as 123
2)更新源
R3(config-router)#nei 2.2.2.2 update-source lo0
R2(config-router)#nei 3.3.3.3 update-source lo0
R3(config-router)#do sh ip bgp sum
BGP router identifier 3.3.3.3, local AS number 123
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down
State/PfxRcd
2.2.2.2 4 123 4 4 1 0 0 00:00:11 0
35.1.1.5 4 5 9 9 1 0 0 00:05:46 0
3)发布网络
R4(config-router)#network 4.4.4.0 mask 255.255.255.0
被发布的网络必须跟路由表严格匹配
R5(config-router)#net 5.5.5.0 mask 255.255.255.0
R2(config-router)#do sh ip bgp
* valid, > best,
Network Next Hop Metric LocPrf Weight Path
*> 4.4.4.0/24 24.1.1.4 0 0 4 i
* i5.5.5.0/24 35.1.1.5 0 100 0 5 i
*> 表示可以发布给其它R、可以放进路由表
4)next-hop-self
R3(config-router)#neighbor 2.2.2.2 next-hop-self
R2(config-router)#nei 3.3.3.3 next-hop-self
5)解决数据黑洞---full mesh ibgp
R1(config-router)#router bgp 123
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#nei 2.2.2.2 remote-as 123
R1(config-router)#nei 2.2.2.2 update-source lo0
R1(config-router)#nei 3.3.3.3 remote-as 123
R1(config-router)#nei 3.3.3.3 update-source lo0
R2(config-router)#nei 1.1.1.1 remote-as 123
R2(config-router)#nei 1.1.1.1 update-source lo0
R2(config-router)#nei 1.1.1.1 next-hop-s
R3(config-router)#nei 1.1.1.1 remote-as 123
R3(config-router)#nei 1.1.1.1 update-source lo 0
R3(config-router)#nei 1.1.1.1 next-hop-s
sh ip bgp summ ----查看邻居
sh ip bgp查看BGP 数据库
sh ip route bgp查看BGP 路由
clear ip bgp *硬清除
1、BGP下1跳行为
1)路由往IBGP邻居通告下1跳不变
2)路由往EBGP邻居通告下1跳是当前R
3)next-hop-self
4)MA环境中的下一跳(重定向)
R1(config-router)#router bgp 13
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#nei 12.1.1.2 remote-as 2
R1(config-router)#nei 3.3.3.3 remote-as 13
R1(config-router)#nei 3.3.3.3 upda lo0
R1(config-router)#nei 3.3.3.3 next-hop-self
R2(config-if)#router bgp 2
R2(config-router)#nei 12.1.1.1 remote-as 13
R2(config-router)#net 2.2.2.0 mask 255.255.255.0
R3(config-router)#router bgp 13
R3(config-router)#nei 1.1.1.1 remote-as 13
R3(config-router)#nei 1.1.1.1 up lo 0
R3(config-router)#nei 134.1.1.4 remote-as 4
R4(config-if)#router bgp 4
R4(config-router)#nei 134.1.1.3 remote-as 13
R4(config-router)#do sh ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 2.2.2.0/24 134.1.1.1 0 13 2 i
debug ip bgp update
2、peer-group
1)有相同路由策略1组路由器a
2)作用:简化配置、节省资源
3)配置
(1)创建peer-group
(2)把peer放到peer-group中去
3、同步
1)BGP路由和IGP路由的同步
2)同步作用:防止黑洞在发送路由给EBGP邻居之前首先保证IGP有这条路由
12.2(8)T默认都是关闭
3)
router bgp 13
no synchronization
4、BGP状态
1)idle:查找路由表
2)connect:TCP连接已经成功建立
3)open sent:已发送open,等待对方的open
4)open confirm:收到对方open,发送keepalive,等待对方的keepalive
5)established:成功接收keepalive
停在idle:没有邻居的路由
停在active:
(1)邻居没有我的路由
(2)邻居配错邻居IP
(3)邻居没有配置
(4)AS配置错误
debug ip bgp
5、BGP认证
1)MD5
2)
R1(config-router)#neighbor 12.1.1.2 password chuyue100
R2(config-router)#neighbor 12.1.1.1 password chuyue100
6、sh ip bgp rib-failure
r>i3.3.3.0/24 3.3.3.3 0 100 0 i
注意:此路由依然可以发送给邻居,因为是最佳
7、BGP会话清除
1)硬清
clear ip bgp *
把BGP会话及TCP连接都清除
2)软清
TCP连接不清除
clear ip bgp * soft
3)
R1#sh ip bgp neighbor 12.1.1.2 advertised-routes
R2#sh ip bgp neighbor 12.1.1.1 received-routes
R2(config-router)#nei 12.1.1.1 soft-reconfiguration inbound
把从这个邻居收到路由放到一个独立内存空间
8、汇总
1)自动
R2(config)#int lo 1
R2(config-if)#ip add 2.2.1.2 255.255.255.0
R2(config-if)#router bgp 2
R2(config-router)#redistribute connected
*> 2.0.0.0 12.1.1.2 0 0 2 ?
自动汇总仅针对重发布进BGP的路由
no auto-summary -->携带metric
auto-summary --->不携带metric
2)手工
(1)非专业汇总
R2(config-router)#net 2.2.1.0 mask 255.255.255.0
R2(config)#ip route 2.2.0.0 255.255.252.0 null 0
R2(config)#router bgp 2
R2(config-router)#net 2.2.0.0 mask 255.255.252.0
(2)专业汇总
R2(config-router)#aggregate-address 2.2.0.0 255.255.252.0
R2(config-router)#aggregate-address 2.2.0.0 255.255.252.0 summary-only //抑制细化路由
aggregate-address 2.2.0.0 255.255.252.0 as-set summary-only
//汇总路由会使之前的AS-PATH 丢失,as-set可以保留