华为OSPF、BGP路由反射器配置详解

  • 对于网络工程师而言,OSPF、BGP的重要性不言而喻,本篇文章我们就来回顾下OSPF、BGP的配置技巧,重点如下
    1.熟悉DHCP配置;
    2.熟悉OSFP配置;
    3.BGP路由反射器配置
  • 入下图所示,要求如下:
    1.网络拓扑规划如图所示;
    2.PC1、PC2、PC3全部自动获取ip地址;
    3.R1、R2、R3之间运行osfp保证网络的联通性;
    4.PC1、PC2、PC3之间网络互通

  • 第一步 配置OSPF保证路由器直接网络连通性
    R1配置如下:
    [R1]dhcp enable
    Info: The operation may take a few seconds. Please wait for a moment.done.
    [R1]interface g0/0/2
    [R1-GigabitEthernet0/0/2]ip address 192.168.1.254 24
    [R1-GigabitEthernet0/0/2]dhcp select interface
    [R1]interface g0/0/0
    [R1-GigabitEthernet0/0/0]ip address 192.168.12.1 24
    [R1-GigabitEthernet0/0/0]q
    [R1]interface LoopBack 0
    [R1-LoopBack0]ip address 10.10.1.1 24
    [R1-LoopBack0]q
    [R1-ospf-1]area 0
    [R1-ospf-1-area-0.0.0.0]network 192.168.12.0 0.0.0.255
    [R1-ospf-1-area-0.0.0.0]network 10.10.1.1 255.255.255.255
    R2配置如下:
    [R2]dhcp enable
    Info: The operation may take a few seconds. Please wait for a moment.done.
    [R2]interface g0/0/2
    [R2-GigabitEthernet0/0/2]ip address 192.168.2.254 24
    [R2-GigabitEthernet0/0/2]dhcp select interface
    [R2]interface g0/0/1
    [R2-GigabitEthernet0/0/1]ip address 192.168.12.2 24.
    [R2-GigabitEthernet0/0/1]q
    [R2]interface g0/0/0
    [R2-GigabitEthernet0/0/0]ip address 192.168.23.2 24.
    [R2-GigabitEthernet0/0/0]q
    [R2]interface LoopBack 0
    [R2-LoopBack0]ip address 10.10.2.2 24
    [R2-LoopBack0]q
    [R2-ospf-1]area 0
    [R2-ospf-1-area-0.0.0.0]network 192.168.12.0 0.0.0.255
    [R2-ospf-1-area-0.0.0.0]network 192.168.23.0 0.0.0.255
    [R2-ospf-1-area-0.0.0.0]network 10.10.2.2 255.255.255.255
    R3配置如下:
    [R2]dhcp enable
    Info: The operation may take a few seconds. Please wait for a moment.done.
    [R3]interface g0/0/2
    [R3-GigabitEthernet0/0/2]ip address 192.168.3.254 24
    [R3-GigabitEthernet0/0/2]dhcp select interface
    [R3]interface g0/0/1
    [R3-GigabitEthernet0/0/1]ip address 192.168.23.3 24
    [R3]interface LoopBack 0
    [R3-LoopBack0]ip address 10.10.3.3 24
    [R3-LoopBack0]q
    [R3-ospf-1]area 0
    [R3-ospf-1-area-0.0.0.0]network 192.168.23.0 0.0.0.255
    [R3-ospf-1-area-0.0.0.0]network 10.10.3.3 255.255.255.255
    测试路由器直接连通性:
    在R1上ping路由器R3,网络互通
    [R1]ping 10.10.3.3
    PING 10.10.3.3: 56 data bytes, press CTRL_C to break
    Reply from 10.10.3.3: bytes=56 Sequence=1 ttl=254 time=40 ms
    Reply from 10.10.3.3: bytes=56 Sequence=2 ttl=254 time=20 ms
    Reply from 10.10.3.3: bytes=56 Sequence=3 ttl=254 time=30 ms
    Reply from 10.10.3.3: bytes=56 Sequence=4 ttl=254 time=30 ms
    Reply from 10.10.3.3: bytes=56 Sequence=5 ttl=254 time=50 ms

    --- 10.10.3.3 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/34/50 ms

  • 第二步 配置bgp
    R1配置如下
    [R1]bgp
    [R1]bgp 64512
    [R1-bgp]peer 10.10.2.2 as-number 64512
    [R1-bgp]peer 10.10.2.2 connect-interface LoopBack 0
    [R1-bgp]import-route direct
    [R1-bgp]router-id 1.1.1.1
    R2配置如下
    [R2]bgp 64512
    [R2-bgp]router-id 2.2.2.2
    [R2-bgp]peer 10.10.1.1 as-number 64512
    [R2-bgp]peer 10.10.1.1 connect-interface LoopBack 0
    [R2-bgp]peer 10.10.3.3 as-number 64512
    [R2-bgp]peer 10.10.3.3 connect-interface LoopBack 0
    [R2-bgp]import-route direct
    R3配置如下
    [R3]bgp
    [R3]bgp 64512
    [R3-bgp]peer 10.10.2.2 as-number 64512
    [R3-bgp]peer 10.10.2.2 connect-interface LoopBack 0
    [R3-bgp]import-route direct
    [R3-bgp]router-id 3.3.3.3
  • 此时查看R1bgp路由表和R3的路由表如下;
    bgp路由表
    [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: 12
    Network NextHop MED LocPrf PrefVal Path/Ogn

    > 10.10.1.0/24 0.0.0.0 0 0 ?
    > 10.10.1.1/32 0.0.0.0 0 0 ?
    >i 10.10.2.0/24 10.10.2.2 0 100 0 ?
    > 127.0.0.0 0.0.0.0 0 0 ?
    > 127.0.0.1/32 0.0.0.0 0 0 ?
    > 192.168.1.0 0.0.0.0 0 0 ?
    > 192.168.1.254/32 0.0.0.0 0 0 ?
    >i 192.168.2.0 10.10.2.2 0 100 0 ?
    *> 192.168.12.0 0.0.0.0 0 0 ?

    • i 10.10.2.2 0 100 0 ?
      > 192.168.12.1/32 0.0.0.0 0 0 ?
      >i 192.168.23.0 10.10.2.2 0 100 0 ?
      [R3]dis ip routing-table
      Route Flags: R - relay, D - download to fib
      Routing Tables: Public
      Destinations : 18 Routes : 18

Destination/Mask Proto Pre Cost Flags NextHop Interface

  10.10.1.1/32  OSPF    10   2           D   192.168.23.2    GigabitEthernet

0/0/1
10.10.2.0/24 IBGP 255 0 RD 10.10.2.2 GigabitEthernet
0/0/1
10.10.2.2/32 OSPF 10 1 D 192.168.23.2 GigabitEthernet
0/0/1
10.10.3.0/24 Direct 0 0 D 10.10.3.3 LoopBack0
10.10.3.3/32 Direct 0 0 D 127.0.0.1 LoopBack0
10.10.3.255/32 Direct 0 0 D 127.0.0.1 LoopBack0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.2.0/24 IBGP 255 0 RD 10.10.2.2 GigabitEthernet
0/0/1
192.168.3.0/24 Direct 0 0 D 192.168.3.254 GigabitEthernet
0/0/2
192.168.3.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
192.168.3.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
192.168.12.0/24 OSPF 10 2 D 192.168.23.2 GigabitEthernet
0/0/1
192.168.23.0/24 Direct 0 0 D 192.168.23.3 GigabitEthernet
0/0/1
192.168.23.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.23.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0

  • 可以总结如下,可以看到,由于IBGP 遵守水平分割规则,R2不能将学习到的路由互相转发,造成R1与R3不能学习到对方的路由。PC1与PC2不能ping通。
  • 在R2上配置路由反射器,使R1和R3成为了R2路由反射器配置如下
    [R2]bgp 64512
    [R2-bgp]peer 10.10.1.1 reflect-client
    [R2-bgp]peer 10.10.3.3 reflect-client

R1的路由表和bgp路由表如下:
[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: 14
Network NextHop MED LocPrf PrefVal Path/Ogn

> 10.10.1.0/24 0.0.0.0 0 0 ?
> 10.10.1.1/32 0.0.0.0 0 0 ?
>i 10.10.2.0/24 10.10.2.2 0 100 0 ?
>i 10.10.3.0/24 10.10.3.3 0 100 0 ?
> 127.0.0.0 0.0.0.0 0 0 ?
> 127.0.0.1/32 0.0.0.0 0 0 ?
> 192.168.1.0 0.0.0.0 0 0 ?
> 192.168.1.254/32 0.0.0.0 0 0 ?
>i 192.168.2.0 10.10.2.2 0 100 0 ?
>i 192.168.3.0 10.10.3.3 0 100 0 ?
*> 192.168.12.0 0.0.0.0 0 0 ?

  • i 10.10.2.2 0 100 0 ?
    > 192.168.12.1/32 0.0.0.0 0 0 ?
    >i 192.168.23.0 10.10.2.2 0 100 0 ?
    [R1]dis ip ro
    [R1]dis ip routing-table
    Route Flags: R - relay, D - download to fib
    Routing Tables: Public
    Destinations : 20 Routes : 20

Destination/Mask Proto Pre Cost Flags NextHop Interface

  10.10.1.0/24  Direct  0    0           D   10.10.1.1       LoopBack0
  10.10.1.1/32  Direct  0    0           D   127.0.0.1       LoopBack0
10.10.1.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
  10.10.2.0/24  IBGP    255  0          RD   10.10.2.2       GigabitEthernet

0/0/0
10.10.2.2/32 OSPF 10 1 D 192.168.12.2 GigabitEthernet
0/0/0
10.10.3.0/24 IBGP 255 0 RD 10.10.3.3 GigabitEthernet
0/0/0
10.10.3.3/32 OSPF 10 2 D 192.168.12.2 GigabitEthernet
0/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 Direct 0 0 D 192.168.1.254 GigabitEthernet
0/0/2
192.168.1.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
192.168.2.0/24 IBGP 255 0 RD 10.10.2.2 GigabitEthernet
0/0/0
192.168.3.0/24 IBGP 255 0 RD 10.10.3.3 GigabitEthernet
0/0/0
192.168.12.0/24 Direct 0 0 D 192.168.12.1 GigabitEthernet
0/0/0
192.168.12.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.12.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.23.0/24 OSPF 10 2 D 192.168.12.2 GigabitEthernet
0/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0

  • 可以总结看到,路由反射器将从客户处学到的路由转发给除此客户外的所有的客户,R1与R3可以学习到对方的路由。PC1与PC3可以ping通。
  • 测试PC1、PC2、PC3网络互通
    PC>ping 192.168.3.253

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

  • 配置成功!!!!

转载于:https://blog.51cto.com/11806823/2299712

你可能感兴趣的:(华为OSPF、BGP路由反射器配置详解)