实验12 BGP路由属性

实验任务一:local_pref属性

  1. 建立物理连接
    1399347-20190707220950571-1900338751.png

  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

  1. 查看路由表信息
    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,优选原则最后一条。
    1399347-20190707221008061-401026407.png

  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值。

转载于:https://www.cnblogs.com/akiz/p/11148171.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值