BGP的应用

目录

实验需求:按照规划建立BGP对等关系,R1和R5各发布一条路由,保证两个网段可以互相通信

 1.首先配置IP

r1

r2

r3

r4

r5

2.AS之间建立EBGP直连邻居关系

r1和r2之间

r4和r5之间

3.AS内部建立IBGP对等体邻居关系

首先建立ospf使内部建立通讯连接

然后建立IBGP 

4.使r1和r5的路由互相通信

1.将r1的环回下发

 将下一跳的属性修改为自身

 可以在r5上看到已下发的路由

2.将r5的环回下发到r1

将r5的环回下发

  将下一跳的属性修改为自身

可以在r1上看到已下发的路由 

5.验证实验需求


实验需求:按照规划建立BGP对等关系,R1和R5各发布一条路由,保证两个网段可以互相通信

 1.首先配置IP

r1

[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[r1-GigabitEthernet0/0/0]int l0
[r1-LoopBack0]ip add 1.1.1.1 24

r2

[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[r2-GigabitEthernet0/0/0]int l0
[r2-LoopBack0]ip add 2.2.2.2 24
[r2-LoopBack0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 23.0.0.1 24

r3

[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 23.0.0.2 24
[r3-GigabitEthernet0/0/0]int l0
[r3-LoopBack0]ip add 3.3.3.3 24
[r3-LoopBack0]int g0/0/1
[r3-GigabitEthernet0/0/1]ip add 34.0.0.1 24

r4

[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add 34.0.0.2 24
[r4-GigabitEthernet0/0/0]int l0
[r4-LoopBack0]ip add 4.4.4.4 24
[r4-LoopBack0]int g0/0/1
[r4-GigabitEthernet0/0/1]ip add 45.0.0.1 24

r5

[r5]int g0/0/0
[r5-GigabitEthernet0/0/0]ip add 45.0.0.2 24
[r5-GigabitEthernet0/0/0]int l0
[r5-LoopBack0]ip add 5.5.5.5 24

2.AS之间建立EBGP直连邻居关系

r1和r2之间

[r1]bgp 1
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 12.0.0.2 as-number 2
Oct  7 2022 17:08:41-08:00 r1 %%01BGP/3/STATE_CHG_UPDOWN(l)[0]:The status of the
 peer 12.0.0.2 changed from OPENCONFIRM to ESTABLISHED. (InstanceName=Public, St
ateChangeReason=Up)  
[r1-bgp]display bgp peer

 BGP local router ID : 1.1.1.1
 Local AS number : 1
 Total number of peers : 1		  Peers in established state : 1

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  12.0.0.2        4           2        2        4     0 00:00:03 Established    0
[r2]bgp 2
[r2-bgp]router-id 2.2.2.2	
[r2-bgp]peer 12.0.0.1 as-number 1
Oct  7 2022 17:08:41-08:00 r2 %%01BGP/3/STATE_CHG_UPDOWN(l)[0]:The status of the
 peer 12.0.0.1 changed from OPENCONFIRM to ESTABLISHED. (InstanceName=Public, St
ateChangeReason=Up)  
[r2-bgp]display bgp peer

 BGP local router ID : 2.2.2.2
 Local AS number : 2
 Total number of peers : 1		  Peers in established state : 1

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  12.0.0.1        4           1        3        3     0 00:01:20 Established    0

r4和r5之间

[r4]bgp 2
[r4-bgp]router-id 4.4.4.4	
[r4-bgp]peer 45.0.0.2 as-number 3
Oct  7 2022 17:12:40-08:00 r4 %%01BGP/3/STATE_CHG_UPDOWN(l)[0]:The status of the
 peer 45.0.0.2 changed from OPENCONFIRM to ESTABLISHED. (InstanceName=Public, St
ateChangeReason=Up)  
[r4-bgp]display bgp peer

 BGP local router ID : 4.4.4.4
 Local AS number : 2
 Total number of peers : 1		  Peers in established state : 1

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  45.0.0.2        4           3        2        3     0 00:00:13 Established    0
[r5]bgp 3
[r5-bgp]router-id 5.5.5.5	
[r5-bgp]peer 45.0.0.1 as-number 2
Oct  7 2022 17:12:40-08:00 r5 %%01BGP/3/STATE_CHG_UPDOWN(l)[0]:The status of the
 peer 45.0.0.1 changed from OPENCONFIRM to ESTABLISHED. (InstanceName=Public, St
ateChangeReason=Up)  
[r5-bgp]display bgp peer

 BGP local router ID : 5.5.5.5
 Local AS number : 3
 Total number of peers : 1		  Peers in established state : 1

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  45.0.0.1        4           2        2        2     0 00:00:58 Established    0

3.AS内部建立IBGP对等体邻居关系

首先建立ospf使内部建立通讯连接

[r2]ospf 1 router-id 2.2.2.2	
[r2-ospf-1]a 0
[r2-ospf-1-area-0.0.0.0]network 23.0.0.0 0.0.0.255
[r2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]a 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 3.3.3.3 0.0.0.0
[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]a 0
[r4-ospf-1-area-0.0.0.0]network 34.0.0.0 0.0.0.255
[r4-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0

然后建立IBGP 

[r2]bgp 2
[r2-bgp]peer 3.3.3.3 as-number 2	
[r2-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[r2-bgp]peer 4.4.4.4 as-number 2
[r2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r3]bgp 2
[r3-bgp]router-id 3.3.3.3
[r3-bgp]peer 2.2.2.2 as-number 2
[r3-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r3-bgp]peer 4.4.4.4 as-number 2
[r3-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r4-bgp]bgp 2
[r4-bgp]peer 2.2.2.2 as-number 2
[r4-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r4-bgp]peer 3.3.3.3 as-number 2	
[r4-bgp]peer 3.3.3.3 connect-interface LoopBack 0

4.使r1和r5的路由互相通信

1.将r1的环回下发

[r1]bgp 1
[r1-bgp]network 1.1.1.0 24
[r1]display bgp routing-table 

 BGP Local router ID is 1.1.1.1 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete


 Total Number of Routes: 1
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   1.1.1.0/24         0.0.0.0         0                     0      i

 将下一跳的属性修改为自身

[r2-bgp]peer 3.3.3.3 next-hop-local
[r2-bgp]peer 4.4.4.4 next-hop-local

 可以在r5上看到已下发的路由

[r5]display bgp routing-table 

 BGP Local router ID is 5.5.5.5 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete


 Total Number of Routes: 1
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   1.1.1.0/24         45.0.0.1                              0      2 1i

2.将r5的环回下发到r1

将r5的环回下发

[r5-bgp]network 5.5.5.0 24
[r5]display bgp routing-table 

 BGP Local router ID is 5.5.5.5 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete


 Total Number of Routes: 2
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   1.1.1.0/24         45.0.0.1                              0      2 1i
 *>   5.5.5.0/24         0.0.0.0         0                     0      i

  将下一跳的属性修改为自身

[r4-bgp]peer 3.3.3.3 next-hop-local
[r4-bgp]peer 2.2.2.2 next-hop-local

可以在r1上看到已下发的路由 

[r1]display bgp routing-table 

 BGP Local router ID is 1.1.1.1 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete


 Total Number of Routes: 2
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   1.1.1.0/24         0.0.0.0         0                     0      i
 *>   5.5.5.0/24         12.0.0.2                              0      2 3i

5.验证实验需求

[r1]ping -a 1.1.1.1 5.5.5.5
  PING 5.5.5.5: 56  data bytes, press CTRL_C to break
    Reply from 5.5.5.5: bytes=56 Sequence=1 ttl=252 time=80 ms
    Reply from 5.5.5.5: bytes=56 Sequence=2 ttl=252 time=50 ms
    Reply from 5.5.5.5: bytes=56 Sequence=3 ttl=252 time=30 ms
    Reply from 5.5.5.5: bytes=56 Sequence=4 ttl=252 time=40 ms
    Reply from 5.5.5.5: bytes=56 Sequence=5 ttl=252 time=40 ms

  --- 5.5.5.5 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 30/48/80 ms
-------------------------------------------------------------------------------------
[r5]ping -a 5.5.5.5 1.1.1.1
  PING 1.1.1.1: 56  data bytes, press CTRL_C to break
    Reply from 1.1.1.1: bytes=56 Sequence=1 ttl=252 time=40 ms
    Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=252 time=50 ms
    Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=252 time=30 ms
    Reply from 1.1.1.1: bytes=56 Sequence=4 ttl=252 time=40 ms
    Reply from 1.1.1.1: bytes=56 Sequence=5 ttl=252 time=40 ms

  --- 1.1.1.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 30/40/50 ms
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Gur.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值