HCIP第七天 BGP

配置:

<r1> dis cu 
[V200R003C00]
#
 sysname r1
#
interface GigabitEthernet0/0/0
 ip address 12.1.1.1 255.255.255.0 
#
interface GigabitEthernet0/0/1
#
interface GigabitEthernet0/0/2
 ip address 11.1.1.1 255.255.255.0 
#
interface NULL0
#
interface LoopBack0
 ip address 1.1.1.1 255.255.255.255 
#
bgp 1      //开始bgp
 router-id 1.1.1.1    //指定router-id
 peer 2.2.2.2 as-number 2    //指定对端路由器地址及AS编号
 peer 2.2.2.2 ebgp-max-hop 3  //因为使用了对端的回环地址,而BGP协议发送的路由信息的默认TTL值为1,会造成一下跳不可达,所以将BGP的最大跳数改为3。
 peer 2.2.2.2 connect-interface LoopBack0    //使用本地环回地址和对端建邻
 #
 ipv4-family unicast
  undo synchronization
  network 1.1.1.1 255.255.255.255     //宣告环回地址
  network 11.1.1.0 255.255.255.0      //宣告客户网段
  peer 2.2.2.2 enable
#
ip route-static 2.2.2.2 255.255.255.255 12.1.1.2 //因为使用了对端的环回地址作为建邻地址,所以需要加一条去对端回环的静态地址
#
return
<r1>

<r2>dis cu 
[V200R003C00]
#
 sysname r2
#
interface GigabitEthernet0/0/0
 ip address 23.1.1.1 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 12.1.1.2 255.255.255.0 
#
interface GigabitEthernet0/0/2
 ip address 22.1.1.1 255.255.255.0 
#
interface NULL0
#
interface LoopBack0
 ip address 2.2.2.2 255.255.255.255 
#
bgp 2
 router-id 2.2.2.2
 peer 1.1.1.1 as-number 1 
 peer 1.1.1.1 ebgp-max-hop 3 
 peer 1.1.1.1 connect-interface LoopBack0   //指定使用本地环回地址与对端建邻
 peer 3.3.3.3 as-number 2 
 peer 3.3.3.3 connect-interface LoopBack0
 peer 4.4.4.4 as-number 2    //因为IBGP水平分割的原因,R2学到的路由共享给R3以后,R3无法共享给4,所以需要R2与R4建邻,将路由共享给R4.
 peer 4.4.4.4 connect-interface LoopBack0
 #
 ipv4-family unicast
  undo synchronization
  network 2.2.2.2 255.255.255.255 
  network 22.1.1.0 255.255.255.0 
  network 23.1.1.0 255.255.255.0 
  peer 1.1.1.1 enable
  peer 3.3.3.3 enable
  peer 3.3.3.3 next-hop-local  //因为IBGP内共享路由信息的时候,不会更改路由信息的属性,当R1的路由共享给R2后,下一跳为R1,R2再把路由共享给R3的时候,下一跳还是R1,但是R3并没有去R1的路由,会导致路由不可达,所以需要在R2上将共享的路由下一跳改为自己。
  peer 4.4.4.4 enable
  peer 4.4.4.4 next-hop-local 
#
ospf 1 router-id 2.2.2.2 
 area 0.0.0.0 
  network 2.2.2.2 0.0.0.0 
  network 22.1.1.1 0.0.0.0 
  network 23.1.1.1 0.0.0.0 
#
return
<r2>
<r3>dis cu 
[V200R003C00]
#
 sysname r3
#
interface GigabitEthernet0/0/0
 ip address 34.1.1.1 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 23.1.1.2 255.255.255.0 
#
interface GigabitEthernet0/0/2
 ip address 33.1.1.1 255.255.255.0 
#
interface NULL0
#
interface LoopBack0
 ip address 3.3.3.3 255.255.255.255 
#
bgp 2
 router-id 3.3.3.3
 peer 2.2.2.2 as-number 2 
 peer 2.2.2.2 connect-interface LoopBack0
 peer 4.4.4.4 as-number 2 
 peer 4.4.4.4 connect-interface LoopBack0
 #
 ipv4-family unicast
  undo synchronization
  network 3.3.3.3 255.255.255.255 
  network 33.1.1.0 255.255.255.0 
  peer 2.2.2.2 enable
  peer 4.4.4.4 enable
#
ospf 1 router-id 3.3.3.3 
 area 0.0.0.0 
  network 3.3.3.3 0.0.0.0 
  network 23.1.1.2 0.0.0.0 
  network 33.1.1.1 0.0.0.0 
  network 34.1.1.1 0.0.0.0 
#
<r3> 
<r4>dis cu 
[V200R003C00]
#
 sysname r4
#
interface GigabitEthernet0/0/0
 ip address 45.1.1.1 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 34.1.1.2 255.255.255.0 
#
interface GigabitEthernet0/0/2
 ip address 44.1.1.1 255.255.255.0 
#
interface GigabitEthernet4/0/0
 ip address 54.1.1.1 255.255.255.0 
#
interface NULL0
#
interface LoopBack0
 ip address 4.4.4.4 255.255.255.255 
#
bgp 2
 router-id 4.4.4.4
 peer 2.2.2.2 as-number 2 
 peer 2.2.2.2 connect-interface LoopBack0
 peer 3.3.3.3 as-number 2 
 peer 3.3.3.3 connect-interface LoopBack0
 peer 5.5.5.5 as-number 3 
 peer 5.5.5.5 ebgp-max-hop 3 
 peer 5.5.5.5 connect-interface LoopBack0
 #
 ipv4-family unicast
  undo synchronization
  network 4.4.4.4 255.255.255.255 
  network 44.1.1.0 255.255.255.0 
  peer 2.2.2.2 enable
  peer 2.2.2.2 next-hop-local 
  peer 3.3.3.3 enable
  peer 3.3.3.3 next-hop-local 
  peer 5.5.5.5 enable
#
ospf 1 router-id 4.4.4.4 
 area 0.0.0.0 
  network 4.4.4.4 0.0.0.0 
  network 34.1.1.2 0.0.0.0 
  network 44.1.1.1 0.0.0.0 
#
ip route-static 5.5.5.5 255.255.255.255 45.1.1.2
ip route-static 5.5.5.5 255.255.255.255 54.1.1.2
#
<r4>
<r5>di cu 
[V200R003C00]
#
 sysname r5
#
interface GigabitEthernet0/0/0
 ip address 54.1.1.2 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 45.1.1.2 255.255.255.0 
#
interface GigabitEthernet0/0/2
 ip address 55.1.1.1 255.255.255.0 
#
interface LoopBack0
 ip address 5.5.5.5 255.255.255.255 
#
bgp 3
 router-id 5.5.5.5
 peer 4.4.4.4 as-number 2 
 peer 4.4.4.4 ebgp-max-hop 3 
 peer 4.4.4.4 connect-interface LoopBack0
 #
 ipv4-family unicast
  undo synchronization
  network 5.5.5.5 255.255.255.255 
  network 55.1.1.0 255.255.255.0 
  peer 4.4.4.4 enable
#
ip route-static 4.4.4.4 255.255.255.255 45.1.1.1
ip route-static 4.4.4.4 255.255.255.255 54.1.1.1
#
return
<r5> 
PC>ping 22.1.1.1

Ping 22.1.1.1: 32 data bytes, Press Ctrl_C to break
From 22.1.1.1: bytes=32 seq=1 ttl=255 time<1 ms
From 22.1.1.1: bytes=32 seq=2 ttl=255 time=16 ms
From 22.1.1.1: bytes=32 seq=3 ttl=255 time=15 ms
From 22.1.1.1: bytes=32 seq=4 ttl=255 time=16 ms
From 22.1.1.1: bytes=32 seq=5 ttl=255 time=16 ms

--- 22.1.1.1 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 0/12/16 ms

PC>ping 33.1.1.2

Ping 33.1.1.2: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 33.1.1.2: bytes=32 seq=2 ttl=126 time=16 ms
From 33.1.1.2: bytes=32 seq=3 ttl=126 time=16 ms
From 33.1.1.2: bytes=32 seq=4 ttl=126 time=16 ms
From 33.1.1.2: bytes=32 seq=5 ttl=126 time=16 ms

--- 33.1.1.2 ping statistics ---
  5 packet(s) transmitted
  4 packet(s) received
  20.00% packet loss
  round-trip min/avg/max = 0/16/16 ms

PC>ping 11.1.1.1

Ping 11.1.1.1: 32 data bytes, Press Ctrl_C to break
From 11.1.1.1: bytes=32 seq=1 ttl=254 time=32 ms
From 11.1.1.1: bytes=32 seq=2 ttl=254 time=15 ms
From 11.1.1.1: bytes=32 seq=3 ttl=254 time=31 ms
From 11.1.1.1: bytes=32 seq=4 ttl=254 time=16 ms
From 11.1.1.1: bytes=32 seq=5 ttl=254 time=15 ms

--- 11.1.1.1 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 15/21/32 ms

PC>ping 55.1.1.1

Ping 55.1.1.1: 32 data bytes, Press Ctrl_C to break
From 55.1.1.1: bytes=32 seq=1 ttl=252 time=63 ms
From 55.1.1.1: bytes=32 seq=2 ttl=252 time=31 ms
From 55.1.1.1: bytes=32 seq=3 ttl=252 time=31 ms
From 55.1.1.1: bytes=32 seq=4 ttl=252 time=16 ms
From 55.1.1.1: bytes=32 seq=5 ttl=252 time=31 ms

--- 55.1.1.1 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 16/34/63 ms


PC>ping 55.1.1.2

Ping 55.1.1.2: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 55.1.1.2: bytes=32 seq=2 ttl=124 time=31 ms
From 55.1.1.2: bytes=32 seq=3 ttl=124 time=16 ms
From 55.1.1.2: bytes=32 seq=4 ttl=124 time=15 ms
From 55.1.1.2: bytes=32 seq=5 ttl=124 time=32 ms

--- 55.1.1.2 ping statistics ---
  5 packet(s) transmitted
  4 packet(s) received
  20.00% packet loss
  round-trip min/avg/max = 0/23/32 ms

PC>

查看路由表:

<r1>dis 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: 7
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   1.1.1.1/32         0.0.0.0         0                     0      i
      2.2.2.2/32         2.2.2.2         0                     0      2i
 *>   11.1.1.0/24        0.0.0.0         0                     0      i
 *>   22.1.1.0/24        2.2.2.2         0                     0      2i
 *>   33.1.1.0/24        2.2.2.2                               0      2i
 *>   44.1.1.0/24        2.2.2.2                               0      2i
 *>   55.1.1.0/24        2.2.2.2                               0      2 3i
<r1>
<r2>dis bgp routing-table 
 BGP Local router ID is 2.2.2.2 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete
 Total Number of Routes: 8
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

      1.1.1.1/32         1.1.1.1         0                     0      1i
 *>   2.2.2.2/32         0.0.0.0         0                     0      i
   i  3.3.3.3/32         3.3.3.3         0          100        0      i
   i  4.4.4.4/32         4.4.4.4         0          100        0      i
 *>   11.1.1.0/24        1.1.1.1         0                     0      1i
 *>   22.1.1.0/24        0.0.0.0         0                     0      i
 *>i  33.1.1.0/24        3.3.3.3         0          100        0      i
 *>i  44.1.1.0/24        4.4.4.4         0          100        0      i
 *>i  55.1.1.0/24        4.4.4.4         0          100        0      3i
<r2>
<r3>dis bgp routing-table 
 BGP Local router ID is 3.3.3.3 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete
 Total Number of Routes: 7
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
   i  2.2.2.2/32         2.2.2.2         0          100        0      i
 *>   3.3.3.3/32         0.0.0.0         0                     0      i
   i  4.4.4.4/32         4.4.4.4         0          100        0      i
 *>i  11.1.1.0/24        2.2.2.2         0          100        0      1i
 *>i  22.1.1.0/24        2.2.2.2         0          100        0      i
 *>   33.1.1.0/24        0.0.0.0         0                     0      i
 *>i  44.1.1.0/24        4.4.4.4         0          100        0      i
 *>i  55.1.1.0/24        4.4.4.4         0          100        0      3i
<r3>
<r4>dis bgp rou	
<r4>dis bgp routing-table 
 BGP Local router ID is 4.4.4.4 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete
 Total Number of Routes: 8
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
   i  2.2.2.2/32         2.2.2.2         0          100        0      i
   i  3.3.3.3/32         3.3.3.3         0          100        0      i
 *>   4.4.4.4/32         0.0.0.0         0                     0      i
      5.5.5.5/32         5.5.5.5         0                     0      3i
 *>i  11.1.1.0/24        2.2.2.2         0          100        0      1i
 *>i  22.1.1.0/24        2.2.2.2         0          100        0      i
 *>i  33.1.1.0/24        3.3.3.3         0          100        0      i
 *>   44.1.1.0/24        0.0.0.0         0                     0      i
 *>   55.1.1.0/24        5.5.5.5         0                     0      3i
<r4>

 *>i  : *有效路由,>最优路由,i 表示IGP学习到的路由

3i  :表示路由经过的最近一个AS是AS3 ,后面的i表示这条路由是通过Network方式学习到的

<r5>dis 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: 6
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
 *>   5.5.5.5/32         0.0.0.0         0                     0      i
 *>   11.1.1.0/24        4.4.4.4                               0      2 1i
 *>   22.1.1.0/24        4.4.4.4                               0      2i
 *>   33.1.1.0/24        4.4.4.4                               0      2i
 *>   44.1.1.0/24        4.4.4.4         0                     0      2i
 *>   55.1.1.0/24        0.0.0.0         0                     0      i
<r5>

问题:

1.R1上没有学到 R3 R4 R5的环回

2.R3上没有学到R1 R5 的环回

3.R5上没有学到 R1 R2 R3的环回

宣告:在一个AS内所有的EBGP路由器都要宣告一样的路由条目,可以只宣告AS内客户路由条目,不宣告AS内设备间的路由条目,且本地宣告的路由条目优于其他EBGP路由器宣告的条目

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值