畅学网
BGP实验案例
2014-4-1 Andre tian


实验需求:

1、    每一台路由器都起一个/32的回环地址,用来建立BGP邻居关系

2、    大型企业内部起OSPF协议,ISP B内部也起OSPF协议,企业A分别和ISP B和ISP C建立BGP邻接关系,以用来透传互联网上的条目

3、    要求ISP C学到挂在ISP B的服务器条目尽可能少

4、    要求ISP C前往ISP B那些服务器是通过R3和R5之间的高带宽链路,为了充分利用带宽,要求ISP B访问ISP C上的服务器是走的R4和R6之间的低带宽链路,这些配置都需要在大型企业上完成

5、    要求ISP和企业之间建立的BGP邻接是安全的

6、    完成配置之后,确信网络中每一台设备都学到了服务器对应的BGP条目

实验拓扑图:



bgp_experiment.gif



实验步骤:

1、在大型企业A和ISP B内部起OSPF协议

R2:

R2(config)#router ospf 1

R2(config-router)#net 2.2.2.2 0.0.0.0 a 0

R2(config-router)#net 23.23.23.23 0.0.0.0 a 0

R2(config-router)#net 24.24.24.24 0.0.0.0 a 0

R3:

R3(config)#router ospf 1

R3(config-router)#net 3.3.3.3 0.0.0.0 a 0

R3(config-router)#net 23.23.23.1 0.0.0.0 a 0

R4:

R4(config)#router ospf 1

R4(config-router)#net 4.4.4.4 0.0.0.0 a 0

R4(config-router)#net 24.24.24.1 0.0.0.0 a 0

R5:

R5(config)#router ospf 1

R5(config-router)#net 5.5.5.5 0.0.0.0 a 0

R5(config-router)#net 57.57.57.2 0.0.0.0 a 0

R6:

R6(config)#router ospf 1

R6(config-router)#net 6.6.6.6 0.0.0.0 a 0

R6(config-router)#net 67.67.67.2 0.0.0.0 a 0

R7:

R7(config)#router ospf 1

R7(config-router)#net 7.7.7.7 0.0.0.0 a 0

R7(config-router)#net 57.57.57.1 0.0.0.0 a 0

R7(config-router)#net 67.67.67.1 0.0.0.0 a 0

2、全网启用BGP协议

由于ebgp建立在TCP连接的基础上,所以需要配置静态路由。而且BGP属于单播更新,所以必须指定邻居。

R1:

R1(config)#int l1

R1(config-if)#ip add 1.1.1.1 255.255.255.255   //用来建立BGP邻居关系的环回口

R1(config)#router bgp 1

R1(config-router)#neighbor 2.2.2.2 remote-as 2

R1(config-router)#neighbor 2.2.2.2 update-source loopback 1  //使用回环口建立邻居

R1(config-router)#neighbor 2.2.2.2 ebgp-multihop 2   //设置ebgp多跳

R1(config-router)#network 210.1.1.0 mask 255.255.255.0   //通过服务器子网进BGP

R1(config)#ip route 2.2.2.2 255.255.255.255 12.12.12.1  

R2:

R2(config)#int l0

R2(config-if)#ip add 2.2.2.2 255.255.255.255  

R2(config)#router bgp 2

R2(config-router)#neighbor 1.1.1.1 remote-as 1

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

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

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

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

R3(config-router)#neighbor 3.3.3.3 next-hop-self   //在ibgp中以自己为下一跳

R2(config-router)#neighbor 4.4.4.4 remote-as 2

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

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

R2(config)#ip route 1.1.1.1 255.255.255.255 12.12.12.2

R3:

R3(config)#int l0

R3(config-if)#ip add 3.3.3.3 255.255.255.255  

R3(config)#router bgp 2

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

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

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

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

R3(config-router)#neighbor 5.5.5.5 update-source loopback 0

R3(config-router)#neighbor 5.5.5.5 ebgp-multihop 2

R3(config)#ip route 5.5.5.5 255.255.255.255 35.35.35.1

R4:

R4(config)#int l0

R4(config-if)#ip add 4.4.4.4 255.255.255.255  

R4(config)#router bgp 2

R4(config-router)#neighbor 2.2.2.2 remote-as 2

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

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

R4(config-router)#neighbor 6.6.6.6 remote-as 3

R4(config-router)#neighbor 6.6.6.6 update-source loopback 0

R4(config-router)#neighbor 6.6.6.6 ebgp-multihop 2

R4(config)#ip route 6.6.6.6 255.255.255.255 46.46.46.1

R5:

R5(config)#int l0

R5(config-if)#ip add 5.5.5.5 255.255.255.255  

R5(config)#router bgp 3

R5(config-router)#neighbor 7.7.7.7 remote-as 3

R5(config-router)#neighbor 7.7.7.7 update-source loopback 0

R5(config-router)#neighbor 7.7.7.7 next-hop-self  

R5(config-router)#neighbor 3.3.3.3 remote-as 2

R5(config-router)#neighbor 3.3.3.3 update-source loopback 0

R5(config-router)#neighbor 3.3.3.3 ebgp-multihop 2

R5(config)#ip route 3.3.3.3 255.255.255.255 35.35.35.2

R6:

R6(config)#int l0

R6(config-if)#ip add 6.6.6.6 255.255.255.255  

R6(config)#router bgp 3

R6(config-router)#neighbor 7.7.7.7 remote-as 3

R6(config-router)#neighbor 7.7.7.7 update-source loopback 0

R6(config-router)#neighbor 7.7.7.7 next-hop-self  

R6(config-router)#neighbor 4.4.4.4 remote-as 2

R6(config-router)#neighbor 4.4.4.4 update-source loopback 0

R6(config-router)#neighbor 4.4.4.4 ebgp-multihop 2

R6(config)#ip route 4.4.4.4 255.255.255.255 46.46.46.2

R7:

R5(config)#int l4

R5(config-if)#ip add 7.7.7.7 255.255.255.255  

R5(config)#router bgp 3

R5(config-router)#neighbor 5.5.5.5 remote-as 3

R5(config-router)#neighbor 5.5.5.5 update-source loopback 4

R5(config-router)#neighbor 6.6.6.6 remote-as 3

R5(config-router)#neighbor 6.6.6.6 update-source loopback 4

R5(config-router)#network 134.1.0.0 mask 255.255.255.0

R5(config-router)#network 134.1.1.0 mask 255.255.255.0

R5(config-router)#network 134.1.2.0 mask 255.255.255.0

R5(config-router)#network 134.1.3.0 mask 255.255.255.0

查看BGP邻居建立情况:

R2#show ip bgp su

BGP router identifier 2.2.2.2, local AS number 2

BGP table version is 11, main routing table version 11

6 network entries using 702 bytes of memory

5/3 BGP path/bestpath attribute entries using 620 bytes of memory

2 BGP AS-PATH entries using 48 bytes of memory

0 BGP route-map cache entries using 0 bytes of memory

0 BGP filter-list cache entries using 0 bytes of memory

BGP using 1890 total bytes of memory

BGP activity 18/12 prefixes, 30/20 paths, scan interval 60 secs



Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

1.1.1.1         4     1     118     118       11    0    0 00:09:04        1

3.3.3.3         4     2     118     125       11    0    0 00:09:04        4

4.4.4.4         4     2     119     128       11    0    0 00:09:04        4



3、进行BGP汇总

因为要求ISP C学到挂在ISP B的服务器条目尽可能少,所以可以在R2上进行BGP汇总。

R2:

R2(config)#router bgp 2

R2(config-route)#aggregate-address 134.1.0.0 255.255.252.0 summary-only as-set

// summary-only只显示汇总路由,不显示明细路由;as-set可以查看路由经过哪些AS区域

查看R1的BGP表:

R1#show ip bgp

BGP table version is 5, 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

*> 134.1.0.0/21     2.2.2.2                  0             0 2 3 i

*> 210.1.1.0        0.0.0.0                  0            32768 i



3、配置BGP选路路由

因为要求ISP C前往ISP B的服务器是通过R3和R5之间的高带宽链路,可以在R2上设置BGP的权重或者本地优先级来改变BGP的最佳路由。这里以配置本地优先级为例进行选路。

R2(config)#access-list 1 permit 134.1.0.0 0.0.3.255   //建立前往目的子网的ACL

R2(config)#route-map sovand permit 10   //建立route-map

R2(config-route-map)#match ip address 1

R2(config-route-map)#set local-preference 200   //设置前往目的子网的本地优先级为200

R2(config)#router bgp 2

R2(config-router)#neighbor 3.3.3.3 route-map sovand in  //在通往R3的路由中应用route-map,方向为进入

查看修改本地优先级后的BGP表:

R2#show ip bgp

BGP table version is 11, 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

s>i134.1.0.0/24     3.3.3.3                  0    200      0 3 i

s i                 4.4.4.4                  0    100      0 3 i

*> 134.1.0.0/21     0.0.0.0                       200  32768 3 i

s>i134.1.1.0/24     3.3.3.3                  0    200      0 3 i

s i                 4.4.4.4                  0    100      0 3 i

s>i134.1.2.0/24     3.3.3.3                  0    200      0 3 i

s i                 4.4.4.4                  0    100      0 3 i

s>i134.1.3.0/24     3.3.3.3                  0    200      0 3 i

s i                 4.4.4.4                  0    100      0 3 i

*> 210.1.1.0        1.1.1.1                  0             0 1 i


另外要求ISP B访问ISP C上的服务器是走的R4和R6之间的低带宽链路,可以在R3上设置MED、起源或者AS_PATH来改变最佳选路。这里以设置MED为例。

R3(config)#access-list 1 permit 210.1.1.0 0.0.0.255   //建立前往目的子网的ACL

R3(config)#route-map sovand permit 10   //建立route-map

R3(config-route-map)#match ip address 1

R3(config-route-map)#set metric 100   //设置前往目的子网的MED为100

R3(config)#router bgp 2

R3(config-router)#neighbor 5.5.5.5 route-map sovand out  //在通往R5的路由中应用route-map,方向为出口路由

查看修改MED后的BGP表:

R5#show ip bgp

BGP table version is 10, 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



   Network          Next Hop            Metric LocPrf Weight Path

*>i134.1.0.0/24     7.7.7.7                  0    100      0 i

*>i134.1.1.0/24     7.7.7.7                  0    100      0 i

*>i134.1.2.0/24     7.7.7.7                  0    100      0 i

*>i134.1.3.0/24     7.7.7.7                  0    100      0 i

*> 210.1.1.0        3.3.3.3                100             0 2 1 i



R6#show ip bgp

BGP table version is 10, local router ID is 6.6.6.6

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

*>i134.1.0.0/24     7.7.7.7                  0    100      0 i

*>i134.1.1.0/24     7.7.7.7                  0    100      0 i

*>i134.1.2.0/24     7.7.7.7                  0    100      0 i

*>i134.1.3.0/24     7.7.7.7                  0    100      0 i

*> 210.1.1.0        4.4.4.4                                0 2 1 i



查看选路结果:

R1#traceroute 134.1.1.1 source 210.1.1.1



Type escape sequence to abort.

Tracing the route to 134.1.1.1



  1 12.12.12.1 96 msec 60 msec 256 msec

  2 23.23.23.1 816 msec 204 msec 1360 msec

  3 35.35.35.1 604 msec 872 msec 960 msec

  4 57.57.57.1 1392 msec 1428 msec 1536 msec


R7#traceroute 210.1.1.1 source 134.1.1.1



Type escape sequence to abort.

Tracing the route to 210.1.1.1



  1 67.67.67.2 244 msec 384 msec 64 msec

  2 46.46.46.2 372 msec 836 msec 492 msec

  3 24.24.24.2 572 msec 1028 msec 492 msec

  4 12.12.12.2 868 msec 1136 msec 880 msec



可见ISP C中的210.1.1.0/24服务器前往ISP
B中的134.1.1.0/24服务器走的是35.35.35.1,即R3和R5的链路。ISP B中的134.1.1.0/24服务器前往ISP
C中的210.1.1.0/24服务器走的是46.46.46.2,即R4和R6的链路。 至此BGP的选路算是完成了。

4、配置BGP身份验证

通过使用命令neighbor x.x.x.x password (value)即可

R1(config-router)#neighbor 2.2.2.2 password cisco

R2(config-router)#neighbor 1.1.1.1 password cisco

R3(config-router)#neighbor 5.5.5.5 password cisco

R4(config-router)#neighbor 6.6.6.6 password cisco

R5(config-router)#neighbor 3.3.3.3 password cisco

R6(config-router)#neighbor 4.4.4.4 password cisco

实验完成!

评论:
cialis bestellen
2015-09-26 17:29 回复
http://comprarcialisgenericosinrecetaes.net/ venta cialis
http://comprarcialis-generico.net/ precio cialis
http://achetercialisgeneriquesansordonnance.net/ acheter cialis
http://acquistare-cialis-generico.net/ cialis
http://kaufencialisgenerikade.net/ kaufen cialis
acquistare cialis
2015-09-24 05:00 回复
http://comprarcialisgenericosinrecetaes.net/ cialis
http://comprarcialis-generico.net/ comprar cialis
http://achetercialisgeneriquesansordonnance.net/ acheter cialis
http://acquistare-cialis-generico.net/ acquistare cialis
http://kaufencialisgenerikade.net/ bestellen cialis
achat cialis
2015-09-22 06:48 回复
http://comprarcialisgenericosinrecetaes.net/ cialis
http://comprarcialis-generico.net/ comprar cialis  
http://achetercialisgeneriquesansordonnance.net/ cialis prix
http://acquistare-cialis-generico.net/ cialis
http://kaufencialisgenerikade.net/ cialis
comprar cialis
2015-09-21 16:54 回复
http://comprarcialisgenericosinrecetaes.net/ cialis
http://comprarcialis-generico.net/ cialis generico
http://achetercialisgeneriquesansordonnance.net/ acheter cialis
http://acquistare-cialis-generico.net/ cialis acquisto
http://kaufencialisgenerikade.net/ cialis preise
comprar cialis
2015-09-20 11:16 回复
http://comprarcialisgenericosinrecetaes.net/ cialis generico
http://comprarcialis-generico.net/ cialis sin receta
http://achetercialisgeneriquesansordonnance.net/ vente cialis
http://acquistare-cialis-generico.net/ generico cialis
http://kaufencialisgenerikade.net/ cialis
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容