网络工程师网络配置经典例题(八)

目录

配置BGP的基本示例

组网需求

配置思路

操作步骤

配置各接口所属的VLAN

配置各VLANIF接口的IP地址

配置IBGP连接

配置EBGP

配置SwitchA发布路由10.1.0.0/16

配置BGP引入直连路由


配置BGP的基本示例

组网需求

如图所示,需要在所有Switch间运行BGP协议,SwitchA、SwitchB之间建立EBGP连接,SwitchB、SwitchC和SwitchD之间建立IBGP全连接。

请确保该场景下互联接口的STP处于未使能状态。因为在使能STP的环形网络中,如果用交换机的VLANIF接口构建三层网络,会导致某个端口被阻塞,从而导致三层业务不能正常运行。

配置思路

采用如下的思路配置BGP的基本功能:

  1. 在SwitchB、SwitchC和SwitchD间配置IBGP连接。
  2. 在SwitchA和SwitchB之间配置EBGP连接。

操作步骤

  1. 配置各接口所属的VLAN

    # 配置SwitchA。SwitchB、SwitchC和SwitchD的配置与SwitchA类似。

    <HUAWEI> system-view
    [HUAWEI] sysname SwitchA
    [SwitchA] vlan batch 10 50
    [SwitchA] interface gigabitethernet 0/0/1
    [SwitchA-GigabitEthernet0/0/1] port link-type trunk
    [SwitchA-GigabitEthernet0/0/1] port trunk allow-pass vlan 10
    [SwitchA-GigabitEthernet0/0/1] quit
    [SwitchA] interface gigabitethernet 0/0/2
    [SwitchA-GigabitEthernet0/0/2] port link-type trunk
    [SwitchA-GigabitEthernet0/0/2] port trunk allow-pass vlan 50
    [SwitchA-GigabitEthernet0/0/2] quit
    

  2. 配置各VLANIF接口的IP地址

    # 配置SwitchA。SwitchB、SwitchC和SwitchD的配置与SwitchA类似。

    [SwitchA] interface vlanif 10
    [SwitchA-Vlanif10] ip address 192.168.1.2 24
    [SwitchA-Vlanif10] quit
    [SwitchA] interface vlanif 50
    [SwitchA-Vlanif50] ip address 10.1.1.1 16
    [SwitchA-Vlanif50] quit

  3. 配置IBGP连接

    # 配置SwitchB。

    [SwitchB] bgp 65009
    [SwitchB-bgp] router-id 172.17.2.2
    [SwitchB-bgp] peer 172.16.1.2 as-number 65009
    [SwitchB-bgp] peer 172.16.3.2 as-number 65009
    [SwitchB-bgp] quit

    # 配置SwitchC。

    [SwitchC] bgp 65009
    [SwitchC-bgp] router-id 172.17.3.3
    [SwitchC-bgp] peer 172.16.3.1 as-number 65009
    [SwitchC-bgp] peer 172.16.2.2 as-number 65009
    [SwitchC-bgp] quit

    # 配置SwitchD。

    [SwitchD] bgp 65009
    [SwitchD-bgp] router-id 172.17.4.4
    [SwitchD-bgp] peer 172.16.1.1 as-number 65009
    [SwitchD-bgp] peer 172.16.2.1 as-number 65009
    [SwitchD-bgp] quit

  4. 配置EBGP

    # 配置SwitchA。

    [SwitchA] bgp 65008
    [SwitchA-bgp] router-id 172.17.1.1
    [SwitchA-bgp] peer 192.168.1.1 as-number 65009
    [SwitchA-bgp] quit

    # 配置SwitchB。

    [SwitchB] bgp 65009
    [SwitchB-bgp] peer 192.168.1.2 as-number 65008
    [SwitchB-bgp] quit

    # 查看BGP对等体的连接状态。

    [SwitchB] display bgp peer
     
     BGP local router ID : 172.17.2.2
     Local AS number : 65009
     Total number of peers : 3                 Peers in established state : 3
     
      Peer            V    AS  MsgRcvd  MsgSent  OutQ  Up/Down       State   PrefRcv
     
      172.16.1.2      4  65009     49       62     0   00:44:58   Established     0
      172.16.3.2      4  65009     56       56     0   00:40:54   Established     0
      192.168.1.2     4  65008     49       65     0   00:44:03   Established     0

    可以看出,SwitchB其它Switch的BGP连接均已建立。

  5. 配置SwitchA发布路由10.1.0.0/16

    # 配置SwitchA发布路由。

    [SwitchA] bgp 65008
    [SwitchA-bgp] ipv4-family unicast
    [SwitchA-bgp-af-ipv4] network 10.1.0.0 255.255.0.0
    [SwitchA-bgp-af-ipv4] quit
    [SwitchA-bgp] quit

    # 查看SwitchA路由表信息。

    [SwitchA] display bgp routing-table
     
     BGP Local router ID is 172.17.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
     
     *>   10.1.0.0/16           0.0.0.0         0                     0      i

    # 查看SwitchB的路由表。

    [SwitchB] display bgp routing-table
     
      BGP Local router ID is 172.17.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: 1
          Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
     
     *>   10.1.0.0/16           192.168.1.2     0                     0      65008i

    # 查看SwitchC的路由表。

    [SwitchC] display bgp routing-table
     
     BGP Local router ID is 172.17.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: 1
         Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
     
      i   10.1.0.0/16           192.168.1.2     0          100        0      65008i

    从路由表可以看出,SwitchC学到了AS65008中的10.1.0.0的路由,但因为下一跳192.168.1.2不可达,所以也不是有效路由。

  6. 配置BGP引入直连路由

    # 配置SwitchB。

    [SwitchB] bgp 65009
    [SwitchB-bgp] ipv4-family unicast
    [SwitchB-bgp-af-ipv4] import-route direct
    [SwitchB-bgp-af-ipv4] quit
    [SwitchB-bgp] quit

    # 查看SwitchA的BGP路由表。

    [SwitchA] display bgp routing-table
     
      BGP Local router ID is 172.17.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: 4
        Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
     
     *>   10.1.0.0/16           0.0.0.0         0                     0      i
     *>   172.16.1.0/24      192.168.1.1     0                     0      65009?
     *>   172.16.3.0/24      192.168.1.1     0                     0      65009?
          192.168.1.0        192.168.1.1     0                     0      65009?

    # 查看SwitchC的路由表。

    [SwitchC] display bgp routing-table
     
     BGP Local router ID is 172.17.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: 4
         Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
     
     *>i  10.1.0.0/16           192.168.1.2     0          100        0      65008i
     *>i  172.16.1.0/24      172.16.3.1      0          100        0      ?
       i  172.16.3.0/24      172.16.3.1      0          100        0      ?
     *>i  192.168.1.0        172.16.3.1      0          100        0      ?

    可以看出,到10.1.0.0的路由变为有效路由,下一跳为SwitchA的地址。

    # 使用Ping进行验证。

    [SwitchC] ping 10.1.1.1
      PING 10.1.1.1: 56  data bytes, press CTRL_C to break
        Reply from 10.1.1.1: bytes=56 Sequence=1 ttl=255 time=31 ms
        Reply from 10.1.1.1: bytes=56 Sequence=2 ttl=255 time=47 ms
        Reply from 10.1.1.1: bytes=56 Sequence=3 ttl=255 time=31 ms
        Reply from 10.1.1.1: bytes=56 Sequence=4 ttl=255 time=16 ms
        Reply from 10.1.1.1: bytes=56 Sequence=5 ttl=255 time=31 ms
     
      --- 10.1.1.1 ping statistics ---
        5 packet(s) transmitted
        5 packet(s) received
        0.00% packet loss
        round-trip min/avg/max = 16/31/47 ms
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值