BGP确实有点难搞啊,不过没关系,慢慢折腾吧。折腾折腾着就折腾会了,哈哈。
首先看IBGP,拓扑图如下:
第一种情况用直连接口建立EBGP或者IBGP。条件都一样:
1 底层可达,也就是保证能Ping通,因为BGP是建立在TCP的基础上的
2 命令(IBGP) :R1(config-router)#neighbor 12.1.1.2 remote 100
R2(config-router)#neighbor 12.1.1.1 remote 1002 命令(EBGP) :R1(config-router)#neighbor 12.1.1.2 remote 200
R2(config-router)#neighbor 12.1.1.1 remote 100IBGP:
R1#show ip bgp neighbors
BGP neighbor is 12.1.1.2, remote AS 100, internal link BGP version 4, remote router ID 12.1.1.2R2#show ip bgp neighbors
BGP neighbor is 12.1.1.1, remote AS 100, internal link BGP version 4, remote router ID 12.1.1.1 BGP state = Established, up for 00:01:05EBGP:
R1#show ip bgp neighbors
BGP neighbor is 12.1.1.2, remote AS 200, external link BGP version 4, remote router ID 12.1.1.2 BGP state = Established, up for 00:00:03R2#show ip bgp neighbors
BGP neighbor is 12.1.1.1, remote AS 100, external link BGP version 4, remote router ID 12.1.1.1 BGP state = Established, up for 00:00:34OK第一种情况的BGP邻居建立了。
第二种情况是用环回接口建立IBGP邻居。
R1:
C 1.0.0.0/8 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnetsS 2.2.2.2 [1/0] via 12.1.1.2C 12.0.0.0/8 is directly connected, Serial0/0R2:
1.0.0.0/32 is subnetted, 1 subnets
S 1.1.1.1 [1/0] via 12.1.1.1C 2.0.0.0/8 is directly connected, Loopback0C 12.0.0.0/8 is directly connected, Serial0/0R1(config)#router bgp 100
R1(config-router)#neighbor 2.2.2.2 remote 100R2(config)#router bgp 100R2(config-router)#nei 1.1.1.1 remote 100 R2#show ip bgp neighborsBGP neighbor is 1.1.1.1, remote AS 100, internal link BGP version 4, remote router ID 0.0.0.0 BGP state = Active发现邻居却不能建立。原因是:BGP的更新源和neighbor不一致。拿R1来说,neighbor是2.2.2.2,更新源却是12.1.1.2.
所以加如下命令:
R1(config)#router bgp 100R1(config-router)#neighbor 2.2.2.2 update-source loopback 0R2(config-router)#neighbor 1.1.1.1 update-source loopback 0
再查看:
R2#show ip bgp neighborsBGP neighbor is 1.1.1.1, remote AS 100, internal link BGP version 4, remote router ID 1.1.1.1
R1#show ip bgp neighborsBGP neighbor is 2.2.2.2, remote AS 100, internal link BGP version 4, remote router ID 2.2.2.2 BGP state = Established, up for 00:00:48邻居建立了。
所以为条件:
1 底层可达,也就是保证能Ping通,因为BGP是建立在TCP的基础上的
2 命令R1(config-router)#neighbor 12.1.1.2 remote 100
R2(config-router)#neighbor 12.1.1.1 remote 1003命令R1(config-router)#neighbor 2.2.2.2 update-source loopback 0
R2(config-router)#neighbor 1.1.1.1 update-source loopback 0第三种情况是用环回接口建立EBGP邻居。
R1(config)#router bgp 100
R1(config-router)#neighbor 2.2.2.2 remote 200R1(config-router)#neighbor 2.2.2.2 update-source lo 0R2(config)#router bgp 200
R2(config-router)#nei 1.1.1.1 remote 100R2(config-router)#nei 1.1.1.1 update-source lo 0按照IBGP的命令配置完后,查看邻居:
R2#show ip bgp neighbors
BGP neighbor is 1.1.1.1, remote AS 100, external link BGP version 4, remote router ID 0.0.0.0 BGP state = Idle发现却没有建立,因为要建立环回接口的EBPG邻居必须要设置条数命令如下:R1(config-router)#neighbor 2.2.2.2 ebgp-multihop 2
R2(config-router)#neighbor 1.1.1.1 ebgp-multihop 2R1#show ip bgp neighbors
BGP neighbor is 2.2.2.2, remote AS 200, external link BGP version 4, remote router ID 2.2.2.2 BGP state = Established, up for 00:00:05邻居起来了。
所以条件为:
1 底层可达,也就是保证能Ping通,因为BGP是建立在TCP的基础上的
2 命令
R1(config-router)#neighbor 12.1.1.2 remote 200
R2(config-router)#neighbor 12.1.1.1 remote 1003命令
R1(config-router)#neighbor 2.2.2.2 update-source loopback 0
R2(config-router)#neighbor 1.1.1.1 update-source loopback 0R1(config-router)#neighbor 2.2.2.2 ebgp-multihop 2
R2(config-router)#neighbor 1.1.1.1 ebgp-multihop 2