zoukankan      html  css  js  c++  java
  • 实验12 BGP路由属性

    实验任务一:local_pref属性

    1. 建立物理连接

    2. 建立bgp邻居
      [RTD]ip route-static 2.2.2.2 32 10.10.10.9
      [RTD]ip route-static 3.3.3.3 32 10.10.10.9

    [RTC]ip route-static 2.2.2.2 32 10.10.10.5
    [RTC]ip route-static 4.4.4.4 32 10.10.10.10

    [RTB]ip route-static 3.3.3.3 32 10.10.10.6
    [RTB]ip route-static 4.4.4.4 32 10.10.10.6

    [RTA]bgp 100
    [RTA-bgp-default]peer 10.10.10.2 as-number 200
    [RTA-bgp-default]peer 10.10.20.2 as-number 200
    [RTA-bgp-default]address-family ipv4
    [RTA-bgp-default-ipv4]peer 10.10.10.2 enable
    [RTA-bgp-default-ipv4]peer 10.10.20.2 enable

    [RTB]bgp 200
    [RTB-bgp-default]peer 10.10.10.1 as-number 100
    [RTB-bgp-default]peer 3.3.3.3 as-number 200
    [RTB-bgp-default]peer 3.3.3.3 connect-interface LoopBack 0
    [RTB-bgp-default]address-family ipv4
    [RTB-bgp-default-ipv4]import-route direct
    [RTB-bgp-default-ipv4]network 2.2.2.2 32
    [RTB-bgp-default-ipv4]peer 3.3.3.3 enable
    [RTB-bgp-default-ipv4]peer 3.3.3.3 next-hop-local
    [RTB-bgp-default-ipv4]peer 10.10.10.1 enable

    [RTC-LoopBack0]bgp 200
    [RTC-bgp-default]peer 2.2.2.2 as-number 200
    [RTC-bgp-default]peer 4.4.4.4 as-number 200
    [RTC-bgp-default]peer 2.2.2.2 connect-interface LoopBack 0
    [RTC-bgp-default]peer 4.4.4.4 connect-interface LoopBack 0
    [RTC-bgp-default]address-family ipv4
    [RTC-bgp-default-ipv4]peer 2.2.2.2 enable
    [RTC-bgp-default-ipv4]peer 4.4.4.4 enable
    [RTC-bgp-default-ipv4]import-route direct
    [RTC-bgp-default-ipv4]network 3.3.3.3 32

    [RTD]bgp 200
    [RTD-bgp-default]peer 10.10.20.1 as-number 100
    [RTD-bgp-default]peer 3.3.3.3 as-number 200
    [RTD-bgp-default]peer 3.3.3.3 connect-interface LoopBack 0
    [RTD-bgp-default]address-family ipv4
    [RTD-bgp-default-ipv4]peer 10.10.20.1 enable
    [RTD-bgp-default-ipv4]peer 3.3.3.3 enable
    [RTD-bgp-default-ipv4]import-route direct
    [RTD-bgp-default-ipv4]network 4.4.4.4 32
    3. 查看路由表信息
    display ip routing-table

    Destinations : 22 Routes : 22

    Destination/Mask Proto Pre Cost NextHop Interface
    0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
    1.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
    2.2.2.2/32 BGP 255 0 10.10.10.2 GE0/0
    3.3.3.3/32 BGP 255 0 10.10.10.2 GE0/0
    4.4.4.4/32 BGP 255 0 10.10.20.2 GE0/1
    10.10.10.0/30 Direct 0 0 10.10.10.1 GE0/0
    10.10.10.0/32 Direct 0 0 10.10.10.1 GE0/0
    10.10.10.1/32 Direct 0 0 127.0.0.1 InLoop0
    10.10.10.3/32 Direct 0 0 10.10.10.1 GE0/0
    10.10.10.4/30 BGP 255 0 10.10.10.2 GE0/0
    10.10.10.8/30 BGP 255 0 10.10.20.2 GE0/1
    10.10.20.0/30 Direct 0 0 10.10.20.1 GE0/1
    10.10.20.0/32 Direct 0 0 10.10.20.1 GE0/1
    10.10.20.1/32 Direct 0 0 127.0.0.1 InLoop0
    10.10.20.3/32 Direct 0 0 10.10.20.1 GE0/1
    127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
    127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
    127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
    127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
    224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
    224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
    255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0

    display bgp routing-table ipv4

    Total number of routes: 10

    BGP local router ID is 1.1.1.1
    Status codes: * - valid, > - best, d - dampened, h - history
    s - suppressed, S - stale, i - internal, e - external
    a - additional-path
    Origin: i - IGP, e - EGP, ? - incomplete

     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn
    
    • e 2.2.2.2/32 10.10.10.2 0 0 200i

    • e 3.3.3.3/32 10.10.10.2 0 200i

    • e 10.10.20.2 0 200i
    • e 4.4.4.4/32 10.10.20.2 0 0 200i

    • e 10.10.10.0/30 10.10.10.2 0 0 200?

    • e 10.10.10.4/30 10.10.10.2 0 0 200?

    • e 10.10.20.2 0 200?
    • e 10.10.10.8/30 10.10.20.2 0 0 200?

    • e 10.10.10.2 0 200?
    • e 10.10.20.0/30 10.10.20.2 0 0 200?
      为什么优选10.10.10.2.不选10.10.20.2,优选原则最后一条。

    1. 修改LOCAL_PREF属性
      display bgp routing-table ipv4

    Total number of routes: 13

    BGP local router ID is 3.3.3.3
    Status codes: * - valid, > - best, d - dampened, h - history
    s - suppressed, S - stale, i - internal, e - external
    a - additional-path
    Origin: i - IGP, e - EGP, ? - incomplete

     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn
    
    • i 1.1.1.1/32 2.2.2.2 0 100 0 100i

    • i 10.10.20.1 0 100 0 100i
    • i 2.2.2.2/32 2.2.2.2 0 100 0 i

    • 3.3.3.3/32 127.0.0.1 0 32768 i

    • i 4.4.4.4/32 4.4.4.4 0 100 0 i

    • i 10.10.10.0/30 2.2.2.2 0 100 0 ?

    • 10.10.10.4/30 10.10.10.6 0 32768 ?

    • i 2.2.2.2 0 100 0 ?
    • 10.10.10.6/32 127.0.0.1 0 32768 ?

    • 10.10.10.8/30 10.10.10.9 0 32768 ?

    • i 4.4.4.4 0 100 0 ?
    • 10.10.10.9/32 127.0.0.1 0 32768 ?

    • i 10.10.20.0/30 4.4.4.4 0 100 0 ?

    修改LOCAL_PREF属性
    [RTD-bgp-default-ipv4] default local-preference 300

    查看RTA BGP路由表
    [RTA-bgp-default-ipv4]display bgp routing-table ipv4

    Total number of routes: 11

    BGP local router ID is 1.1.1.1
    Status codes: * - valid, > - best, d - dampened, h - history
    s - suppressed, S - stale, i - internal, e - external
    a - additional-path
    Origin: i - IGP, e - EGP, ? - incomplete

     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn
    
    • 1.1.1.1/32 127.0.0.1 0 32768 i

    • e 2.2.2.2/32 10.10.10.2 0 0 200i

    • e 3.3.3.3/32 10.10.10.2 0 200i

    • e 10.10.20.2 0 200i
    • e 4.4.4.4/32 10.10.20.2 0 0 200i

    • e 10.10.10.0/30 10.10.10.2 0 0 200?

    • e 10.10.10.4/30 10.10.10.2 0 0 200?

    • e 10.10.20.2 0 200?
    • e 10.10.10.8/30 10.10.20.2 0 0 200?

    • e 10.10.10.2 0 200?
    • e 10.10.20.0/30 10.10.20.2 0 0 200?

    [RTC]display bgp routing-table ipv4

    Total number of routes: 13

    BGP local router ID is 3.3.3.3
    Status codes: * - valid, > - best, d - dampened, h - history
    s - suppressed, S - stale, i - internal, e - external
    a - additional-path
    Origin: i - IGP, e - EGP, ? - incomplete

     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn
    
    • i 1.1.1.1/32 10.10.20.1 0 300 0 100i

    • i 2.2.2.2 0 100 0 100i
    • i 2.2.2.2/32 2.2.2.2 0 100 0 i

    • 3.3.3.3/32 127.0.0.1 0 32768 i

    • i 4.4.4.4/32 4.4.4.4 0 300 0 i

    • i 10.10.10.0/30 2.2.2.2 0 100 0 ?

    • 10.10.10.4/30 10.10.10.6 0 32768 ?

    • i 2.2.2.2 0 100 0 ?
    • 10.10.10.6/32 127.0.0.1 0 32768 ?

    • 10.10.10.8/30 10.10.10.9 0 32768 ?

    • i 4.4.4.4 0 300 0 ?
    • 10.10.10.9/32 127.0.0.1 0 32768 ?

    • i 10.10.20.0/30 4.4.4.4 0 300 0 ?

    在上面可知:LOCAL_PREF是在AS内传播的,且是向本AS内的路由器转发的路由上local_pref值的修改。影响的是离开AS的路由。
    默认值是100

    [RTA-bgp-default-ipv4]display bgp routing-table ipv4

    Total number of routes: 11

    BGP local router ID is 1.1.1.1
    Status codes: * - valid, > - best, d - dampened, h - history
    s - suppressed, S - stale, i - internal, e - external
    a - additional-path
    Origin: i - IGP, e - EGP, ? - incomplete

     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn
    
    • 1.1.1.1/32 127.0.0.1 0 32768 i

    • e 2.2.2.2/32 10.10.10.2 0 0 200i

    • e 3.3.3.3/32 10.10.10.2 0 200i

    • e 10.10.20.2 0 200i
    • e 4.4.4.4/32 10.10.20.2 0 0 200i

    • e 10.10.10.0/30 10.10.10.2 0 0 200?

    • e 10.10.10.4/30 10.10.10.2 0 0 200?

    • e 10.10.20.2 0 200?
    • e 10.10.10.8/30 10.10.20.2 0 0 200?

    • e 10.10.10.2 0 200?
    • e 10.10.20.0/30 10.10.20.2 0 0 200?

    1. 修改MED属性
      [RTA]display bgp routing-table ipv4

    Total number of routes: 11

    BGP local router ID is 1.1.1.1
    Status codes: * - valid, > - best, d - dampened, h - history
    s - suppressed, S - stale, i - internal, e - external
    a - additional-path
    Origin: i - IGP, e - EGP, ? - incomplete

     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn
    
    • 1.1.1.1/32 127.0.0.1 0 32768 i

    • e 2.2.2.2/32 10.10.10.2 0 0 200i

    • e 3.3.3.3/32 10.10.10.2 0 200i

    • e 10.10.20.2 0 200i
    • e 4.4.4.4/32 10.10.20.2 0 0 200i

    • e 10.10.10.0/30 10.10.10.2 0 0 200?

    • e 10.10.10.4/30 10.10.20.2 0 200?

    • e 10.10.10.2 0 0 200?
    • e 10.10.10.8/30 10.10.10.2 0 200?

    • e 10.10.20.2 0 0 200?
    • e 10.10.20.0/30 10.10.20.2 0 0 200?

    display bgp routing-table ipv4

    Total number of routes: 13

    BGP local router ID is 3.3.3.3
    Status codes: * - valid, > - best, d - dampened, h - history
    s - suppressed, S - stale, i - internal, e - external
    a - additional-path
    Origin: i - IGP, e - EGP, ? - incomplete

     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn
    
    • i 1.1.1.1/32 2.2.2.2 0 100 0 100i

    • i 10.10.20.1 0 100 0 100i
    • i 2.2.2.2/32 2.2.2.2 0 100 0 i

    • 3.3.3.3/32 127.0.0.1 0 32768 i

    • i 4.4.4.4/32 4.4.4.4 0 100 0 i

    • i 10.10.10.0/30 2.2.2.2 0 100 0 ?

    • 10.10.10.4/30 10.10.10.6 0 32768 ?

    • i 2.2.2.2 0 100 0 ?
    • 10.10.10.6/32 127.0.0.1 0 32768 ?

    • 10.10.10.8/30 10.10.10.9 0 32768 ?

    • i 4.4.4.4 0 100 0 ?
    • 10.10.10.9/32 127.0.0.1 0 32768 ?

    • i 10.10.20.0/30 4.4.4.4 0 100 0 ?

    修改MED属性
    [RTB-bgp-default-ipv4]default med 10

    [RTA]display bgp routing-table ipv4

    Total number of routes: 11

    BGP local router ID is 1.1.1.1
    Status codes: * - valid, > - best, d - dampened, h - history
    s - suppressed, S - stale, i - internal, e - external
    a - additional-path
    Origin: i - IGP, e - EGP, ? - incomplete

     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn
    
    • 1.1.1.1/32 127.0.0.1 0 32768 i

    • e 2.2.2.2/32 10.10.10.2 10 0 200i

    • e 3.3.3.3/32 10.10.10.2 0 200i

    • e 10.10.20.2 0 200i
    • e 4.4.4.4/32 10.10.20.2 0 0 200i

    • e 10.10.10.0/30 10.10.10.2 10 0 200?

    • e 10.10.10.4/30 10.10.20.2 0 200?

    • e 10.10.10.2 10 0 200?
    • e 10.10.10.8/30 10.10.10.2 0 200?

    • e 10.10.20.2 0 0 200?
    • e 10.10.20.0/30 10.10.20.2 0 0 200?

    display bgp routing-table ipv4

    Total number of routes: 13

    BGP local router ID is 3.3.3.3
    Status codes: * - valid, > - best, d - dampened, h - history
    s - suppressed, S - stale, i - internal, e - external
    a - additional-path
    Origin: i - IGP, e - EGP, ? - incomplete

     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn
    
    • i 1.1.1.1/32 2.2.2.2 0 100 0 100i

    • i 10.10.20.1 0 100 0 100i
    • i 2.2.2.2/32 2.2.2.2 10 100 0 i

    • 3.3.3.3/32 127.0.0.1 0 32768 i

    • i 4.4.4.4/32 4.4.4.4 0 100 0 i

    • i 10.10.10.0/30 2.2.2.2 10 100 0 ?

    • 10.10.10.4/30 10.10.10.6 0 32768 ?

    • i 2.2.2.2 10 100 0 ?
    • 10.10.10.6/32 127.0.0.1 0 32768 ?

    • 10.10.10.8/30 10.10.10.9 0 32768 ?

    • i 4.4.4.4 0 100 0 ?
    • 10.10.10.9/32 127.0.0.1 0 32768 ?

    • i 10.10.20.0/30 4.4.4.4 0 100 0 ?
      MED在AS内AS间都传播,MED越小越优先。一般影响AS间的选路。
      MED默认值是0

    总结:default med x,default local_pref y,都是根据自己产生的路由传播修改MED值,从邻居学到的路由不会修改其中的MED值。

  • 相关阅读:
    C#+API实现指定窗体激活
    DEVC++学习之(一)
    javascript 实现原生下载的各种情况
    IssueVision 之WebService安全篇
    Add relationship to BS sample
    ExpandRelationWithCtxt 与 GetRelatedObjects 的区别
    C#调用javascript
    解禁网页限制
    Unix cc options vs gcc options
    IssueVision 之模式篇
  • 原文地址:https://www.cnblogs.com/akiz/p/11148171.html
Copyright © 2011-2022 走看看