限于篇幅,实验分为两篇!
实验内容:
BGP邻居建立+BGP路由+BGP反射器(Route-Reflector)+BGP联邦综合实验
BGP反射器(Route-Reflector)和BGP联邦是用来解决BGP路由传递的问题的。
BGP邻居建立
BGP路由
BGP反射器
BGP联邦
首先各个路由器的基础配置上图:
配置完后,检查下底层连接是否都能Ping通,一切OK后,就开始建立BGP邻居关系。
首先是R2与R3 R2与R4 R3与R5 这里R1不运行BGP
R2(config)#router bgp 123
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#no sy //关闭同步
R2(config-router)#no au
R2(config-router)#nei 24.1.1.4 remote 400 //EBGP
R2(config-router)#nei 3.3.3.3 remote 123 //IBGP
R2(config-router)#nei 3.3.3.3 update-source lo 0 //因为是用环回口建立的邻居所以需要指定更新源
R4(config)#router bgp 400
R4(config-router)#nei 24.1.1.2 remote 123
R4(config-router)#no sy
R4(config-router)#no au
R3(config)#router bgp 123
R3(config-router)#no sy
R3(config-router)#no au
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#nei 2.2.2.2 remote 123
R3(config-router)#nei 2.2.2.2 update-source lo 0
R3(config-router)#nei 35.1.1.5 remote 500
R5(config)#router bgp 500
R5(config-router)#bgp router-id 5.5.5.5
R5(config-router)#nei 35.1.1.3 remote 123
R5(config-router)#no sy
R5(config-router)#no au
R2#show ip bgp summary
BGP router identifier 2.2.2.2, local AS number 123
BGP table version is 1, main routing table version 1
NeighborVAS MsgRcvd MsgSentTblVerInQ OutQ Up/DownState/PfxRcd
3.3.3.3412334100 00:00:130
24.1.1.4440055100 00:01:450
R5#show ip bgp summary
BGP router identifier 5.5.5.5, local AS number 500
BGP table version is 1, main routing table version 1
NeighborVAS MsgRcvd MsgSentTblVerInQ OutQ Up/DownState/PfxRcd
35.1.1.3412344100 00:00:030
OK, R2与R3 R2与R4 R3与R5的4BGP邻居关系建立成功
说明:
如果用直连接口建立EBGP邻居关系(如:R2与R4 R3与R5)需要满足以下条件:
第一:底层链路可达;
第二:命令neighbor + 对方接口IP + remote +对方AS号
见R5R3或者R4R2上的配置
如果非直连路由器要建立IBGP邻居关系,也就是用环回接口建立(如:R2与R3 )则要满足以下条件:
第一:底层链路可达;
第二:命令neighbor + 对方接口IP + remote +对方AS号
第三:命令neighbor + 对方环回接口IP + update-source +环回接口(loopback 0)
见R2与R3上的配置。
补充:如果非直连路由器要建立EBGP邻居关系,也就是用环回接口建立,则要满足以下条件:
第一:底层链路可达;
第二:命令neighbor + 对方接口IP + remote +对方AS号
第三:命令neighbor + 对方环回接口IP + update-source +环回接口(loopback 0)
第四:命令neighbor + 对方环回接口IP + ebgp-multihop+跳数(默认255,最小为2)
以上是BGP邻居建立实验。
---------------------------------------------------------------------------------
在上面实验的基础上,接着是BGP路由实验,在R4上起一条BGP路由:
R4(config-router)#net 4.4.4.0 mask 255.255.255.0
然后查看R4BGP路由表:
R4#show ip bgp
BGP table version is 2, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
NetworkNext HopMetric LocPrf Weight Path
*> 4.4.4.0/240.0.0.0032768 i
注意红色部分的大于符号,表示最优路由,则能传给邻居R2,我们在R2上查看BGP路由:
R2#show ip bgp
BGP table version is 2, 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
NetworkNext HopMetric LocPrf Weight Path
*> 4.4.4.0/2424.1.1.400 400 i
注意红色部分的大于符号,表示最优路由,则能传给邻居R3,我们在R3上查看BGP路由:
R3#show ip bgp
BGP table version is 1, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
NetworkNext Hop Metric LocPrf Weight Path
* i4.4.4.0/2424.1.1.4 01000 400 i
此处无大于符号,则R3不会把4.4.4.4的路由传给R5,在R5上查看BGP路由就会为空,
R5#show ip bgp
BGP路由为空。
R5不能收到该路由,是因为该路由在R3不是最优的(>),则不能传给R5。
这里就引出了BGP路由传给邻居必须要满足的条件:
1下一跳可达
2关闭同步(PS:也可以开启,但是IGP和BGP路由条目要相同)
现在的路由器一般都是默认关闭了同步的,但是为了防止万一,我们进入BGP路由的时候就应该打上no synchronization命令,可以回头看下最开始的命令行,我都有打no sy
再在R3上查看BGP路由显示的下一跳地址为24.1.1.4,在R3上是Ping不通的,那么如何解决啦?
方法如下,在R2上打上命令
neighbor 3.3.3.3 next-hop-self
意思就是告诉邻居3.3.3.3,它的下一条是我R2的环回接口(因为他们是用环回接口建立的邻居)。
这时再查看R3的BGP路由:
R3#show ip bgp
BGP table version is 2, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
NetworkNext HopMetric LocPrf Weight Path
*>i4.4.4.0/242.2.2.2 01000 400 i
下一条可达了,成最优路由了。
自然在R5上也能学到,4.4.4.4的路由
R5#show ip bgp
BGP table version is 2, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
NetworkNext HopMetric LocPrf Weight Path
*> 4.4.4.0/2435.1.1.30 123 400 i
提示:R5这里虽然能够学到4.4.4.4的路由,但是却不能Ping通4.4.4.4,因为会在R1上丢包。
--------------------------------------------------------------------------
BGP路由实验结束了,接下来是BGP反射器(Route-Reflector)
反射器的三种情况如上图。
说明,基础配置和前面一样,但是邻居关系变化了。R2不再与R3成BGP邻居,R2与R1成BGP邻居,R3与R1成BGP邻居
我自己是先在R2,R3上把BGP 123删除掉,然后分别重新建立邻居,命令如下:
R2(config)#no router bgp 123
R2(config)#router bgp 123
R2(config-router)#neighbor 1.1.1.1 remote 123
R2(config-router)#nei 1.1.1.1 up lo 0
R2(config-router)#no sy
R2(config-router)#no au
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#nei 24.1.1.4 remote 400
R2(config-router)# neighbor 1.1.1.1 next-hop-self
R1(config)#router bgp 123
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#no sy
R1(config-router)#no au
R1(config-router)#nei 2.2.2.2 remote 123
R1(config-router)#nei 2.2.2.2 up lo 0
R1(config-router)#nei 3.3.3.3 remote 123
R1(config-router)#nei 3.3.3.3 up lo 0
R3(config)#no router bgp 123
R3(config)#router bgp 123
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#no sy
R3(config-router)#no au
R3(config-router)#nei 35.1.1.5 remote 500
R3(config-router)#nei 1.1.1.1 remote 123
R3(config-router)#nei 1.1.1.1 up lo 0
R3(config-router)# neighbor 1.1.1.1 next-hop-self
然后检查下邻居是否建立。
接着在R5上起一个 5.5.5.0的BGP路由
R5#show ip bgp
BGP table version is 8, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
NetworkNext HopMetric LocPrf Weight Path
*> 5.5.5.0/240.0.0.0032768 i
然后因为IBGP的水平分割关系,R1不会把他的IBGP邻居R3告诉给他的路由5.5.5.0转发给R2,同理R1也不会把他的IBGP邻居R2告诉给他的路由4.4.4.0转发给R3
分别查看R1,R2,R1的BGP路由:
R1#show ip bgp
BGP table version is 7, 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
NetworkNext HopMetric LocPrf Weight Path
*>i4.4.4.0/242.2.2.201000 400 i
*>i5.5.5.0/243.3.3.301000 500 i
R2#show ip bgp
BGP table version is 6, 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
NetworkNext HopMetric LocPrf Weight Path
*> 4.4.4.0/2424.1.1.400 400 i
R3#show ip bgp
BGP table version is 6, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
NetworkNext HopMetric LocPrf Weight Path
*> 5.5.5.0/2435.1.1.500 500 i
可以看到R1上都有了最优的4.4.4.4和5.5.5.5的路由,但是在R2上无5.5.5.5的路由,R3上无4.4.4.4的路由。要解决这个问题,就要使用路由反射器Route-Reflector。这里设置R1为RR,R2Client.配置如下:
R1(config-router)#nei 2.2.2.2 route-reflector-client //BGP反射器
再查看R2,R3的BGP路由表:
R2#show ip bgp
BGP table version is 7, 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
NetworkNext HopMetric LocPrf Weight Path
*> 4.4.4.0/2424.1.1.400 400 i
*>i5.5.5.0/243.3.3.301000 500 i
R3#show ip bgp
BGP table version is 7, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
NetworkNext HopMetric LocPrf Weight Path
*>i4.4.4.0/242.2.2.201000 400 i
*> 5.5.5.0/2435.1.1.500 500 i
能学到了哦。
为了保险起见,最好还配置下R3为Clinet
R1(config-router)#nei 3.3.3.3 route-reflector-client
这就证明了上面的三幅图。
限于篇幅下接实验二:BGP邻居建立+BGP路由传递解决方案之BGP反射器(Route-Reflector)+BGP联邦综合实验2