BGP-2
一、BGP的五种状态
2.active状态信息
3.show ip bgp中前面有r的解释
代表此条路由即从IGP学到,又从EGP学到,且IGP AD小于EGP AD
标明R的路由不放进路由表、会传给BGP邻居
标明R的路由只是代表AD比IGP小,但在BGP中还是最优路由
4.清理BGP session
clear ip bgp * soft 不断开TCP连接,而是重发BGP报文
clear ip bgp * hard 断开TCP连接
5.查看某台路由向另一个路由发送了哪些BGP路由
R2#sh ip bgp neighbors 12.1.1.1 advertised-routes 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, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 2.2.2.0/24 0.0.0.0 0 32768 i Total number of prefixes 1
6.BGP中no auto-summary命令
在将其他协议重分布进BGP时,防止自动汇总
7.将AS2中4条明细路由宣告进BGP
200.1.16.0
200.1.17.0
200.1.18.0
200.1.19.0
第一种方法:
因为BGP想要宣告路由,必须路由表中存在路由才行,我们可以在R2上写一条静态指向NULL 0接口
R2(config)#ip route 200.1.16.0 255.255.252.0 null 0 R2(config)#do sh ip ro Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, 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, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is not set 2.0.0.0/24 is subnetted, 1 subnets C 2.2.2.0 is directly connected, Loopback0 C 200.1.17.0/24 is directly connected, Loopback201 C 200.1.16.0/24 is directly connected, Loopback200 C 200.1.19.0/24 is directly connected, Loopback203 C 200.1.18.0/24 is directly connected, Loopback202 12.0.0.0/24 is subnetted, 1 subnets C 12.1.1.0 is directly connected, Serial2/1 S 200.1.16.0/22 is directly connected, Null0 R2(config)#router bgp 2 R2(config-router)#network 200.1.16.0 mask 255.255.252.0
第二种方法:agg
a.先在BGP中宣告明细路由
R2(config)#router bgp 2 R2(config-router)#net 200.1.16.0 R2(config-router)#net 200.1.17.0 R2(config-router)#net 200.1.18.0 R2(config-router)#net 200.1.19.0 mask 255.255.255.0
R1#sh ip bg BGP table version is 8, local router ID is 1.1.1.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 2.2.2.0/24 12.1.1.2 0 0 2 i *> 200.1.16.0 12.1.1.2 0 0 2 i *> 200.1.17.0 12.1.1.2 0 0 2 i *> 200.1.18.0 12.1.1.2 0 0 2 i *> 200.1.19.0 12.1.1.2 0 0 2 i
b.再在R2上宣告汇总
R2(config)#router bgp 2 R2(config-router)#aggregate-address 200.1.16.0 255.255.252.0
R1#sh ip bg
BGP table version is 9, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2.2.2.0/24 12.1.1.2 0 0 2 i
*> 200.1.16.0 12.1.1.2 0 0 2 i
*> 200.1.16.0/22 12.1.1.2 0 0 2 i
*> 200.1.17.0 12.1.1.2 0 0 2 i
*> 200.1.18.0 12.1.1.2 0 0 2 i
*> 200.1.19.0 12.1.1.2 0 0 2 i
可以看到BGP跟IGP不同,将明细和汇总同时都宣告过来了
c.我们改为只宣告汇总路由
R2(config)#router bgp 2 R2(config-router)#aggregate-address 200.1.16.0 255.255.252.0 summary-only
R2#sh ip bgp BGP table version is 13, local router ID is 2.2.2.2 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 2.2.2.0/24 0.0.0.0 0 32768 i s> 200.1.16.0 0.0.0.0 0 32768 i *> 200.1.16.0/22 0.0.0.0 32768 i s> 200.1.17.0 0.0.0.0 0 32768 i s> 200.1.18.0 0.0.0.0 0 32768 i s> 200.1.19.0 0.0.0.0 0 32768 i
R2上的明细宣告路由都已经打上了s标志,代表suppressed,抑制掉了,不会在发送给其他路由
R1#sh ip bg BGP table version is 13, local router ID is 1.1.1.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 2.2.2.0/24 12.1.1.2 0 0 2 i *> 200.1.16.0/22 12.1.1.2 0 0 2 i
8.prefix-list
第一行此处/23有两层含义:a.代表网络地址前23位都一样;b.代表我的路由一定是23位的
第二行也有两层含义:a.代表网络地址前23位都一样;b.代表我的路由是23位或24位
第三行:代表网络地址前23位都一样;路由< 24位,即只能23位
9.EBGP水平分割
当R2 宣告明细路由进BGP,在R1上做BGP路由汇总
R1(config)#router bgp 1
R1(config-router)#aggregate-address 200.1.16.0 255.255.252.0 summary-only
R1(config-router)#do sh ip bg
BGP table version is 23, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2.2.2.0/24 12.1.1.2 0 0 2 i
s> 200.1.16.0 12.1.1.2 0 0 2 i
*> 200.1.16.0/22 0.0.0.0 32768 i
s> 200.1.17.0 12.1.1.2 0 0 2 i
s> 200.1.18.0 12.1.1.2 0 0 2 i
s> 200.1.19.0 12.1.1.2 0 0 2 i
R2:
router bgp 2 no synchronization bgp router-id 2.2.2.2 bgp log-neighbor-changes network 2.2.2.0 mask 255.255.255.0 network 200.1.16.0 network 200.1.17.0 network 200.1.18.0 network 200.1.19.0 neighbor 12.1.1.1 remote-as 1 no auto-summary
此时R1会将汇总路由发给R3,但同时也会发给R2,如果R2后面还接着好多路由,某条明细断掉后,R8通过汇总路由还是会认为路由是可达的,会继续向R2发送数据,R2吓一跳指向R1,R1又会发给R2,丢包了
这里要注意之所以EBGP没启用水平分割,是因为R1路由表中并为表明AS号,从上图标红色部分可以看出,所以我们就要人为给加上AS号标识
R1:
aggregate-address 200.1.16.0 255.255.252.0 as-set summary-only
二、BGP的路径属性
有*号的代表是各个厂商必须遵守的
1.起源属性origin
IGP(i):通过network命令通告
EGP(e):通过EGP重分布进来的,基本看不到了
incomplete(?):重分布进来的IGP,但不知道起源是哪里
2.选路原则
前提是多条路径都是最优路径