> 文档中心 > BGP基本配置

BGP基本配置


系列文章目录

学海无涯
BGP的基础知识
在这里插入图片描述


一路有你

文章目录

  • 系列文章目录
  • 前言
  • BGP实验拓扑描述
    • 实验描述
    • 实验需求
  • BGP的选路规
  • 完成基本配置
        • R1的配置如下:
        • R2的配置如下 :
        • R3 的配置如下:
        • R4的配置如下:
        • R5的配置如下:
  • 总结

前言

情深不知处
通常可以将路由协议分为IGP(内部网关协议)和EGP(外部网关协议)。EGP主要用于ISP之间的交换路由信息。目前使用最为广泛的EGP是BGP版本4,它是第一个支持 CIDR和路由汇总的BGP版本。而RFC4760中定义的BGP4+是对BGP4的扩展,支持包括IPv6在内的多种协议


落叶归有期

BGP实验拓扑描述

BGP拓扑图

实验描述

1.网络拓扑及互联IP地址规划如图所示
2. R3、 R4、R5各自创建LOOPBACK接口, IP地址为x.x.x.x , x为路由器的编号
3. R3、R4、R5运行OSPF ,宣告三者互联接口及各自的LOOPBACK
4. BGP的AS规划如图所示
5. 完成基本的IP、IGP配置,建立BGP连接

实验需求

1.完成基本的BGP配置,R1与R3、R2与R5建立EBGP邻居关系;R3与R4、R4与R5建立IBGP邻居关系(使用LOOPBACK接口作为更新源)
2.验证 BGP选路规则,同时测试BGP相关策略工具。(待续)本次实验未完成

BGP的选路规则

我们先回顾一下BGP的13条选路规则,在本实验手册中,将对选路规则中的主要条目做验证,同时也熟悉一下 BGP的各种属性。

  1. Weight 越大越优先
  2. Local_Pref 越打越优先
  3. 起源于本地的路由优先(如本地network 的,或aggregate 的),即下一跳是0.0.0.0(在BGP表中,当前路由器通告的路由的下一跳为0.0.0.0)
  4. AS-Path 越短越优先
  5. Origin 属性(优先顺序:IGP>EGP>Incomplete)
  6. MED越小越优先
  7. 优选EBGP邻居发来的路由(相对于IBGP邻居),在联邦EGRP和IBGP中优选联盟EGRP路由
  8. 优选到BGP NEXT_HOP最近的路由,该路由是去往下一跳路由器IGP度量值最小的路由
  9. 如果有多条来自相同相邻AS的路由并通过Maximun-paths使多条路径可用,则将所有开销相同的路由加入Loc-RIB
  10. 如果路由都来自EBGP邻居,则优选最老的EBGP邻居传来的路由,降低滚翻的影响
  11. BGP邻居的RID越小越优先
  12. 如果多条路径发路由器ID或路由器ID相同,那么Cluster-List最短的路径
  13. 选择邻居ip地址最小的路由(BGP的neighbor配置中的那个邻居的地址,也就是邻居的更新源IP)

参考BGP的基础知识

完成基本配置

AS345中的R3、R4、R5运行OSPF. AS内部使用IGP保证内部路由的互通,以满足内部的数据传输需求,同时也为IBGP连接提供底层路由的支持,在者作为传输AS , “Transit AS” ,运行IGP还能保证BGP路由在AS内的传递,而BGP路由的有效性(如NEXT_ HOP属性的可达性)也需要IGP做一个基本的保证。所以,第一步我们先完成这个IGP协议的配置。

R1的配置如下:

代码如下(示例):

R1#configure terminalEnter configuration commands, one per line.  End with CNTL/Z.R1(config)#interface serial 0/0R1(config-if)#ip address 10.1.13.1 255.255.255.0R1(config-if)#no sh*Mar  1 00:42:07.159: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up*Mar  1 00:42:08.159: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to upR1(config-if)#interface loopback 1*Mar  1 00:42:31.639: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to downR1(config-if)#ip add 100.0.1.1 255.255.255.0R1(config-if)#no shR1(config-if)#interface loopback 2*Mar  1 00:42:46.891: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback2, changed state to upR1(config-if)#ip add 100.0.2.1 255.255.255.0R1(config-if)#no shR1#configure  terminalEnter configuration commands, one per line.  End with CNTL/Z.R1(config)#router bgp 100R1(config-router)#no synchronizationR1(config-router)#no auto-summaryR1(config-router)#neighbor 10.1.13.3 remote-as 345R1(config-if)#router bgp 100R1(config-router)#network 100.0.1.0 mask 255.255.255.0R1(config-router)#network 100.0.2.0 mask 255.255.255.0

R2的配置如下 :

代码如下(示例):

R2#configure terminalEnter configuration commands, one per line.  End with CNTL/Z.R2(config)#interface serial 0/0R2(config-if)#ip address 10.1.25.2 255.255.255.0R2(config-if)#no sh*Mar  1 00:47:43.403: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up*Mar  1 00:47:44.403: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to upR2(config-if)#interface loopback1R2(config-if)#ip address 100.0.1.1 255.255.255.0R2(config-if)#no sh*Mar  1 00:48:11.703: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to downR2(config-if)#no shR2(config-if)#interface loopback2R2(config-if)#ip address 100.0.2.1 255.255.255.0R2(config-if)#no shR2#configure terminalEnter configuration commands, one per line.  End with CNTL/Z.R2(config)#router bgp 200R2(config-router)#no synchronizationR2(config-router)#no auto-summaryR2(config-router)#neighbor 10.1.25.5 remote-as 345

R3 的配置如下:

代码如下(示例):

R3#configure terminalEnter configuration commands, one per line.  End with CNTL/Z.R3(config)#interface serial 0/0R3(config-if)#ip address 10.1.13.3 255.255.255.0R3(config-if)#no sh*Mar  1 00:51:58.231: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up*Mar  1 00:51:59.231: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to upR3(config)#interface fastEthernet 1/0R3(config-if)#ip add 10.1.34.3 255.255.255.0R3(config-if)#no sh*Mar  1 00:50:38.779: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up*Mar  1 00:50:39.779: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to upR3(config-if)#interface loopback0*Mar  1 00:50:51.391: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to upR3(config-if)#ip address 3.3.3.3 255.255.255.0R3(config-if)#no shR3(config-if)#router ospf 100R3(config-router)#network 10.1.34.0 0.0.0.255 area 0R3(config-router)#network 3.3.3.3 0.0.0.0 area 0R3#configure terminalEnter configuration commands, one per line.  End with CNTL/Z.R3(config)#router bgp 345R3(config-router)#no synchronizationR3(config-router)#no auto-summaryR3(config-router)#neighbor 10.1.13.1 remote-as 100  //EBGP邻居R3(config-router)#*Mar  1 05:10:15.254: %BGP-3-NOTIFICATION: received from neighbor 10.1.13.1 2/2 (peer in wrong AS) 2 bytes 00C8R3(config-router)#neighbor 4.4.4.4 remote-as 345  //IBGP邻居*Mar  1 05:10:42.446: %BGP-3-NOTIFICATION: received from neighbor 10.1.13.1 2/2 (peer in wrong AS) 2 bytes 00C8R3(config-router)#neighbor 4.4.4.4 update-source loopback 0  //指定更新源为loopback0R3(config-router)#*Mar  1 05:11:12.618: %BGP-3-NOTIFICATION: received from neighbor 10.1.13.1 2/2 (peer in wrong AS) 2 bytes 00C8R3(config)#router bgp 345R3(config-router)#neighbor 4.4.4.4 next-hop-selfR3(config)#router bgp 345R3(config-router)#neighbor 5.5.5.5 remote-as 345R3(config-router)#neighbor 5.5.5.5 update-source loopback 0R3(config-router)#neigbor 5.5.5.5 next-hop-self

R4的配置如下:

代码如下(示例):

R4#configure terminalEnter configuration commands, one per line.  End with CNTL/Z.R4(config)#interface fastEthernet 0/0R4(config-if)#ip address 10.1.34.4 255.255.255.0R4(config-if)#no sh*Mar  1 00:57:19.187: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up*Mar  1 00:57:20.187: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to upR4(config-if)#interface fastEthernet 1/0R4(config-if)#ip address 10.1.45.4 255.255.255.0R4(config-if)#no shR4(config-if)#*Mar  1 00:58:13.095: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up*Mar  1 00:58:14.095: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to upR4(config-if)#interface loopback0*Mar  1 00:58:50.443: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to upR4(config-if)#ip address 4.4.4.4 255.255.255.0R4(config-if)#no shR4(config-if)#router ospf 100R4(config-router)#network 10.1.34.0 0.0.0.255 area 0*Mar  1 00:59:44.039: %OSPF-5-ADJCHG: Process 100, Nbr 3.3.3.3 on FastEthernet0/0 from LOADING to FULL, Loading DoneR4(config-router)#network 10.1.45.0 0.0.0.255 area 0R4(config-router)#network 4.4.4.4 0.0.0.0 area 0R4(config-router)#R4#configure terminalEnter configuration commands, one per line.  End with CNTL/Z.R4(config)#router bgp 345R4(config-router)#no synchronizationR4(config-router)#no auto-summaryR4(config-router)#neighbor 3.3.3.3 remote-as 345R4(config-router)#neighbor 3.3.3.3 update-source Loopback 0R4(config-router)#neighbor 5.5.5.5 remote-as 345R4(config-router)#neighbor 5.5.5.5 update-source loopback 0

R5的配置如下:

代码如下(示例):

R5#configure terminalEnter configuration commands, one per line.  End with CNTL/Z.R5(config)#interface serial 0/0R5(config-if)#ip address 10.1.25.5 255.255.255.0R5(config-if)#no sh*Mar  1 01:04:40.299: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up*Mar  1 01:04:41.299: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to upR5(config)#interface fastEthernet 1/0R5(config-if)#ip address 10.1.45.5 255.255.255.0R5(config-if)#no shR5(config-if)#*Mar  1 01:05:26.927: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up*Mar  1 01:05:27.927: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to upR5(config-if)#interface loopback 0*Mar  1 01:05:44.075: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to upR5(config-if)#ip address 5.5.5.5 255.255.255.0R5(config-if)#no shR5(config-if)#router ospf 100R5(config-router)#network 10.1.25.0 0.0.0.255 area 0R5(config-router)#network 10.1.45.0 0.0.0.255 area 0*Mar  1 01:06:51.191: %OSPF-5-ADJCHG: Process 100, Nbr 4.4.4.4 on FastEthernet1/0 from LOADING to FULL, Loading DoneR5(config-router)#network 5.5.5.5 0.0.0.0 area 0R5#configure terminalEnter configuration commands, one per line.  End with CNTL/Z.R5(config)#router bgp 345R5(config-router)#no synchronizationR5(config-router)#no auto-summarR5(config-router)#neighbor 4.4.4.4 remote-as 345*Mar  1 05:21:58.146: %BGP-5-ADJCHANGE: neighbor 4.4.4.4 UpR5(config-router)#neighbor 4.4.4.4 update-source loopback 0R5(config-router)#neighbor 10.1.25.2 remote-as 200R5(config-if)#router bgp 345R5(config-router)#neighbor 3.3.3.3 remote-as 345*Mar  1 06:19:14.106: %BGP-5-ADJCHANGE: neighbor 3.3.3.3 UpR5(config-router)#neighbor 3.3.3.3 update-source loopback0R5(config-router)#neighbor 3.3.3.3 next-hop-self

总结

红豆生南国

本次实验未完成~
在这里插入图片描述

春来发几枝