BGp

实验:了解BGP的概念和配置

实验拓扑:

clip_image002

实验步骤:

先配置各个接口:

配置基本的BGP网络,

在R1上:

router bgp 1

bgp router-id 1.1.1.1

neighbor 12.12.12.2 remote-as 5

no synchronization

在R2上:

router bgp 5

clip_image003bgp router-id 2.2.2.2

neighbor 12.12.12.1 remote-as 1

no synchronization

clip_image005

你可以用show ip bgp neighbors 查看它现在的邻居关系。

接下来,如果我们想要R1与R3建立IBGP关系,那么我们需要在R1,R2,R3之间公布OSPF路由,

R2(config)#router ospf 100

R2(config-router)#net 12.12.12.0 0.0.0.255 area 0

R2(config-router)#net 2.2.2.0 0.0.0.255 area 0

R5(config)#router ospf 100

R5(config-router)#net 25.25.25.0 0.0.0.255 area 0

R5(config-router)#net 35.35.35.0 0.0.0.255 area 0

R5(config-router)#net 5.5.5.0 0.0.0.255 area 0

R3(config)#router ospf 100

R3(config-router)#net 3.3.3.0 0.0.0.255 area 0

R3(config-router)#net 35.35.35.0 0.0.0.255 area 0

好的,现在我们在R1上配置,让它与R3和R2形成IBGP关系。那么我们在这里需要配置:

R2

R2(config)router bgp 5

R2(config-router)#neighbor 3.3.3.3 remote-as 5

R2(config-router)#neighbor 3.3.3.3 next-hop-self

R2(config-router)#neighbor 3.3.3.3 update-source lo1

R2(config-router)#neighbor 5.5.5.5 remote-as 5

R2(config-router)#neighbor 5.5.5.5 next-hop-self

R2(config-router)#neighbor 5.5.5.5 update-source lo1

R5

R5(config)#router bgp 5

R5(config-router)#no synchronization

R5(config-router)#bgp router-id 5.5.5.5

R5(config-router)#neighbor huo peer-group

R5(config-router)#neighbor huo remote-as 5

R5(config-router)#neighbor huo update-source lo1

R5(config-router)#neighbor 2.2.2.2 peer-group huo

R5(config-router)#neighbor 3.3.3.3 peer-group huo

R3

R3(config)#router bgp 5

R3(config-router)#bgp router-id 3.3.3.3

R3(config-router)#no synchronization

R3(config-router)#neighbor 2.2.2.2 remote-as 5

R3(config-router)#neighbor 2.2.2.2 next-hop-self

R3(config-router)#neighbor 2.2.2.2 update-source lo1

R3(config-router)#neighbor 5.5.5.5 remote-as 5

R3(config-router)#neighbor 5.5.5.5 next-hop-s

R3(config-router)#neighbor 5.5.5.5 update-source lo1

好的,现在R1、R2、R3的邻居关系就起来了。

接下来我们需要来配置R3与R5的邻居关系:

R4

R4(config)#router bgp 4

R4(config-router)#bgp router-id 4.4.4.4

R4(config-router)#no synchronization

R4(config-router)#neighbor 34.34.34.3 remote-as 5

R3

R3(config-router)#neighbor 34.34.34.4 remote-as 4

然后在R1R4上来公布网段:

R1

router bgp 1

network 1.1.1.0 mask 255.255.255.0

R4

router bgp 4

network 4.4.4.0 mask 255.255.255.0

在这里,我们必须看到BGP的neighbor关系UP起来才行:

clip_image007

clip_image009

clip_image011

clip_image013

在路由器上show ip bgp

clip_image015

如果看到的条目没有“>”,则表明该条目不优化,它不会放进路由表,也不传给BGP邻居。那么我们需要做两件事:

1. No synchronization 关闭自动同步

2.指定下一跳,我们一般用的是 next-hop-self

如果在Ebgp网络中用回环口建邻居,那么我们需要配置:

Router bgp x

Bgp router-id

Neighbor x.x.x.x remote-as 1

Neighbor x.x.x.x ebgp-multihop 2

Ip route x.x.x.x 255.255.255.255 接口

我们用扩展ping来PING4.4.4.4

clip_image017

这样,BGp的实验就成功了:

我们把配置全部粘贴出来

R1

R1#show run

interface Loopback1

ip address 1.1.1.1 255.255.255.0

!

interface Serial0

ip address 12.12.12.1 255.255.255.0

!

router bgp 1

no synchronization

bgp router-id 1.1.1.1

bgp log-neighbor-changes

network 1.1.1.0 mask 255.255.255.0

neighbor 12.12.12.2 remote-as 5

R2

R2#show run

!

interface Loopback1

ip address 2.2.2.2 255.255.255.0

!

interface Serial0

ip address 12.12.12.2 255.255.255.0

clockrate 64000

!

interface Serial1

ip address 25.25.25.2 255.255.255.0

!

router ospf 100

log-adjacency-changes

network 2.2.2.0 0.0.0.255 area 0

network 25.25.25.0 0.0.0.255 area 0

!

router bgp 5

no synchronization

bgp router-id 2.2.2.2

bgp log-neighbor-changes

neighbor 3.3.3.3 remote-as 5

neighbor 3.3.3.3 update-source Loopback1

neighbor 3.3.3.3 next-hop-self

neighbor 5.5.5.5 remote-as 5

neighbor 5.5.5.5 update-source Loopback1

neighbor 5.5.5.5 next-hop-self

neighbor 12.12.12.1 remote-as 1

!

R5

R5#show run

hostname R5

!

interface Loopback1

ip address 5.5.5.5 255.255.255.0

!

interface Serial1

ip address 25.25.25.5 255.255.255.0

clockrate 64000

!

interface Serial4

ip address 35.35.35.5 255.255.255.0

clockrate 64000

!

router ospf 100

log-adjacency-changes

network 5.5.5.0 0.0.0.255 area 0

network 25.25.25.0 0.0.0.255 area 0

network 35.35.35.0 0.0.0.255 area 0

!

router bgp 5

no synchronization

bgp router-id 5.5.5.5

bgp log-neighbor-changes

neighbor huo peer-group

neighbor huo remote-as 5

neighbor huo update-source Loopback1

neighbor 2.2.2.2 peer-group huo

neighbor 3.3.3.3 peer-group huo

R3

R3#show run

!

hostname R3

!

interface Loopback1

ip address 3.3.3.3 255.255.255.0

!

interface Serial0

ip address 34.34.34.3 255.255.255.0

clockrate 64000

!

interface Serial1

ip address 35.35.35.3 255.255.255.0

!

router ospf 100

log-adjacency-changes

network 3.3.3.0 0.0.0.255 area 0

network 35.35.35.0 0.0.0.255 area 0

!

router bgp 5

no synchronization

bgp router-id 3.3.3.3

bgp log-neighbor-changes

neighbor 2.2.2.2 remote-as 5

neighbor 2.2.2.2 update-source Loopback1

neighbor 2.2.2.2 next-hop-self

neighbor 5.5.5.5 remote-as 5

neighbor 5.5.5.5 update-source Loopback1

neighbor 5.5.5.5 next-hop-self

neighbor 34.34.34.4 remote-as 4

!

R4#show run

hostname R4

!

interface Loopback1

ip address 4.4.4.4 255.255.255.0

!

interface Serial0

ip address 34.34.34.4 255.255.255.0

!

router bgp 4

no synchronization

bgp router-id 4.4.4.4

bgp log-neighbor-changes

network 4.4.4.0 mask 255.255.255.0

neighbor 34.34.34.3 remote-as 5

你可能感兴趣的:(职场,休闲,BGP)