BGP基础配置实验

一、配置合法IP

[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 12.0.0.1 255.255.255.0 
[R1-GigabitEthernet0/0/0]quit

[R1]interface LoopBack 0
[R1-LoopBack0]ip address 1.1.1.1 255.255.255.0
[R1-LoopBack0]quit

[R1]interface LoopBack 1
[R1-LoopBack1]ip address 172.16.0.1 255.255.255.0
[R1-LoopBack1]quit

[R1]interface LoopBack 2
[R1-LoopBack2]ip address 172.16.1.1 255.255.255.0
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip address 12.0.0.2 255.255.255.0 
[R2-GigabitEthernet0/0/1]quit

[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip address 23.0.0.1 255.255.255.0 
[R2-GigabitEthernet0/0/0]quit

[R2]interface LoopBack 0
[R2-LoopBack0]ip address 2.2.2.2 255.255.255.0
[R3]interface GigabitEthernet 0/0/1
[R3-GigabitEthernet0/0/1]ip address 23.0.0.2 255.255.255.0 
[R3-GigabitEthernet0/0/1]quit

[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip address 34.0.0.1 255.255.255.0 
[R3-GigabitEthernet0/0/0]quit

[R3]interface LoopBack 0
[R3-LoopBack0]ip address 3.3.3.3 255.255.255.0
[R4]interface GigabitEthernet 0/0/1
[R4-GigabitEthernet0/0/1]ip address 34.0.0.2 255.255.255.0 
[R4-GigabitEthernet0/0/1]quit

[R4]interface GigabitEthernet 0/0/0
[R4-GigabitEthernet0/0/0]ip address 45.0.0.1 255.255.255.0 
[R4-GigabitEthernet0/0/0]quit

[R4]interface LoopBack 0
[R4-LoopBack0]ip address 4.4.4.4 255.255.255.0
[R5]interface GigabitEthernet 0/0/1
[R5-GigabitEthernet0/0/1]ip address 45.0.0.2 255.255.255.0 
[R5-GigabitEthernet0/0/1]quit

[R5]interface LoopBack 0
[R5-LoopBack0]ip address 5.5.5.5 255.255.255.0

二、BGP的对等体建立

1.EBGP对等体之间直连建邻
[R1]bgp 1
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 12.0.0.2 as-number 2
[R2]bgp 2
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 12.0.0.1 as-number 1
[R4]bgp 2
[R4-bgp]router-id 4.4.4.4
[R4-bgp]peer 45.0.0.2 as-number 3
[R5]bgp 2
[R5-bgp]router-id 5.5.5.5
[R5-bgp]peer 45.0.0.1 as-number 2
2.IBGP对等体之间环回建邻
(1)AS 2内部基于OSPF实现路由可达
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network  2.2.2.2 0.0.0.0 
[R2-ospf-1-area-0.0.0.0]network 23.0.0.0 0.0.0.255
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network  3.3.3.3 0.0.0.0 
[R3-ospf-1-area-0.0.0.0]network 23.0.0.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 34.0.0.0 0.0.0.255
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network  4.4.4.4 0.0.0.0 
[R4-ospf-1-area-0.0.0.0]network 34.0.0.0 0.0.0.255
(2)建立全连的IBGP对等体

注意:因为IBGP的水平分割限制了路由信息在IBGP对等体之间只能传一跳,则有可能造成路由信息的传递障碍,故需要在AS 2内部建立全连的IBGP对等体。

[R2]bgp 2
[R2-bgp]peer 3.3.3.3 as-number 2 
[R2-bgp]peer 3.3.3.3 connect-interface LoopBack0
[R2-bgp]peer 4.4.4.4 as-number 2 
[R2-bgp]peer 4.4.4.4 connect-interface LoopBack0
[R3]bgp 2
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 2.2.2.2 as-number 2 
[R3-bgp]peer 4.4.4.4 as-number 2 
[R3-bgp]peer 4.4.4.4 connect-interface LoopBack0
[R4]bgp 2
[R4-bgp]router-id 4.4.4.4
[R4-bgp]peer 2.2.2.2 as-number 2
[R4-bgp]peer 3.3.3.3 as-number 2

三、发布路由

从左到右

[R1]ip ip-prefix aa permit 172.16.0.0 16 greater-equal 24 less-equal 24
[R1]route-policy aa permit node 10
[R1-route-policy]if-match ip-prefix aa
[R1-route-policy]quit
[R1]bgp 1 
[R1-bgp]network 1.1.1.0 24 
[R1-bgp]import-route direct route-policy aa

注意:由于在一个AS内部传递的路由的属性是不发生变化的,因此在IBGP对等体之间传递路由时,需要通过以下命令修改下一跳属性。

[R2]bgp 2
[R2-bgp]peer 3.3.3.3 next-hop-local
[R2-bgp]peer 4.4.4.4 next-hop-local

从右到左 

[R5]bgp 3
[R5-bgp]network 5.5.5.0 255.255.255.0
[R4]bgp 2
[R4-bgp]peer 2.2.2.2 next-hop-local
[R4-bgp]peer 3.3.3.3 next-hop-local

四、手工聚合

[R1]ip ip-prefix bb permit 172.16.0.0 24
[R1]route-policy bb permit node 10
[R1-route-policy]if-match ip-prefix bb
[R1-route-policy]quit
[R1]bgp 1 
[R1-bgp]aggregate 172.16.0.0 255.255.254.0 suppress-policy bb

五、测试

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值