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 100

2 命令(EBGP) :R1(config-router)#neighbor 12.1.1.2 remote 200

                R2(config-router)#neighbor 12.1.1.1 remote 100

IBGP:

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.2

R2#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:05

EBGP:

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:03

R2#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:34

OK第一种情况的BGP邻居建立了。

第二种情况是用环回接口建立IBGP邻居。

R1:

C    1.0.0.0/8 is directly connected, Loopback0

    2.0.0.0/32 is subnetted, 1 subnets
S       2.2.2.2 [1/0] via 12.1.1.2
C    12.0.0.0/8 is directly connected, Serial0/0

R2:

    1.0.0.0/32 is subnetted, 1 subnets

S       1.1.1.1 [1/0] via 12.1.1.1
C    2.0.0.0/8 is directly connected, Loopback0
C    12.0.0.0/8 is directly connected, Serial0/0

R1(config)#router bgp 100

R1(config-router)#neighbor 2.2.2.2 remote 100
R2(config)#router bgp 100
R2(config-router)#nei 1.1.1.1 remote 100

R2#show ip bgp neighbors
BGP 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 100

R1(config-router)#neighbor 2.2.2.2 update-source loopback 0
R2(config-router)#neighbor 1.1.1.1  update-source loopback 0

再查看:

R2#show ip bgp neighbors

BGP 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 neighbors

BGP 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 100

3命令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 200
R1(config-router)#neighbor 2.2.2.2 update-source lo 0

R2(config)#router bgp 200

R2(config-router)#nei 1.1.1.1 remote 100
R2(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 2

R1#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 100

3命令

R1(config-router)#neighbor 2.2.2.2 update-source loopback 0

R2(config-router)#neighbor 1.1.1.1  update-source loopback 0

R1(config-router)#neighbor 2.2.2.2 ebgp-multihop 2

R2(config-router)#neighbor 1.1.1.1 ebgp-multihop 2