设为首页 收藏本站
查看: 4673|回复: 0

[经验分享] 利用BGP origin-code 属性修改BGP选路

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-7-20 10:50:21 | 显示全部楼层 |阅读模式
实验拓扑

QQ截图20150720105038.png

基本配置:
R1

L0:1.1.1.1/32
L1:11.1.1.1/32
E1/0:10.1.12.1/24
E1/1:10.1.14.1/24

R2
L0:2.2.2.2/32
L1:22.2.2.2/32
E1/0:10.1.12.2/24
E1/1:10.1.24.2/24

R4
L0:4.4.4.4/32
L1:44.4.4.4/32
E1/0:10.1.24.4/24
E1/1:10.1.14.4/24

配置IGP(RIP):

R1
router rip
version 2
network 1.0.0.0
network 10.0.0.0
no auto-summary
R2
router rip
version 2
network 2.0.0.0
network 10.0.0.0
no auto-summary
R4
router rip
version 2
network 4.0.0.0
network 10.0.0.0
no auto-summary

配置BGP:
router bgp 1
bgp router-id 1.1.1.1
bgp log-neighbor-changes
network 1.1.1.1 mask 255.255.255.255
network 2.2.2.2 mask 255.255.255.255 backdoor
network 4.4.4.4 mask 255.255.255.255 backdoor
network 11.1.1.1 mask 255.255.255.255
neighbor 2.2.2.2 remote-as 23
neighbor 2.2.2.2 ebgp-multihop 2
neighbor 2.2.2.2 update-source Loopback0
neighbor 4.4.4.4 remote-as 23
neighbor 4.4.4.4 ebgp-multihop 2
neighbor 4.4.4.4 update-source Loopback0

R2
router bgp 23
bgp router-id 2.2.2.2
bgp log-neighbor-changes
network 1.1.1.1 mask 255.255.255.255 backdoor
network 2.2.2.2 mask 255.255.255.255
network 22.2.2.2 mask 255.255.255.255
neighbor 1.1.1.1 remote-as 1
neighbor 1.1.1.1 ebgp-multihop 2
neighbor 1.1.1.1 update-source Loopback0
neighbor 4.4.4.4 remote-as 23
neighbor 4.4.4.4 update-source Loopback0
R4

router bgp 23
bgp router-id 4.4.4.4
bgp log-neighbor-changes
network 1.1.1.1 mask 255.255.255.255 backdoor
network 4.4.4.4 mask 255.255.255.255
network 44.4.4.4 mask 255.255.255.255
neighbor 1.1.1.1 remote-as 1
neighbor 1.1.1.1 ebgp-multihop 2
neighbor 1.1.1.1 update-source Loopback0
neighbor 2.2.2.2 remote-as 23
neighbor 2.2.2.2 update-source Loopback0

查看R1路由表:origin 为i,表示从IGP 学来的路由。
R1#sh ip bgp
BGP table version is 5, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
r   2.2.2.2/32       4.4.4.4                                0 23 i
r>                   2.2.2.2                  0             0 23 i
r   4.4.4.4/32       4.4.4.4                  0             0 23 i
r>                   2.2.2.2                                0 23 i
*   22.2.2.2/32      4.4.4.4                                0 23 i
*>                   2.2.2.2                  0             0 23 i
*   44.4.4.4/32      4.4.4.4                  0             0 23 i
*>                   2.2.2.2                                0 23 i

查看22.2.2.2 44.4.4.4的路由表:
R1#sh ip bgp 22.2.2.2
BGP routing table entry for 22.2.2.2/32, version 4
Paths: (2 available, best #2, table default)
  Advertised to update-groups:
     18        
  Refresh Epoch 1
  23
    4.4.4.4 (metric 1) from 4.4.4.4 (4.4.4.4)
      Origin IGP, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 1
  23
    2.2.2.2 (metric 1) from 2.2.2.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, external, best
      rx pathid: 0, tx pathid: 0x0
R1#sh ip bgp 44.4.4.4
BGP routing table entry for 44.4.4.4/32, version 5
Paths: (2 available, best #2, table default)
  Advertised to update-groups:
     18        
  Refresh Epoch 1
  23
    4.4.4.4 (metric 1) from 4.4.4.4 (4.4.4.4)
      Origin IGP, metric 0, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 1
  23
    2.2.2.2 (metric 1) from 2.2.2.2 (2.2.2.2)
      Origin IGP, localpref 100, valid, external, best
      rx pathid: 0, tx pathid: 0x0

origin皆为IGP。修改 bgp origin-clde 属性,使R1到R2的22.2.2.2 永久的从R4走,到R4的44.4.4.4永久的从R2走。
在R1上配置:
第一步:配置prefix-list
ip prefix-list 22 seq 5 permit 22.2.2.2/32
ip prefix-list 44 seq 5 permit 44.4.4.4/32

第二步:配置route-map
route-map ori-r2 permit 10
match ip address prefix-list 22
set origin incomplete
route-map ori-r2 permit 20

route-map ori-r4 permit 10
match ip address prefix-list 44
set origin incomplete
route-map ori-r4 permit 20

第三步:在BGP中,对相应的邻居in方向调用route-map。
neighbor 2.2.2.2 route-map ori-r2 in
neighbor 4.4.4.4 route-map ori-r4 in

第四步:重置BGP邻居,重新学习路由
clea ip bgp *

查看R1 BGP路由表:
R1#sh ip bgp
BGP table version is 16, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
*>  1.1.1.1/32       0.0.0.0                  0         32768 i
r   2.2.2.2/32       4.4.4.4                                0 23 i
r>                   2.2.2.2                  0             0 23 i
r   4.4.4.4/32       4.4.4.4                  0             0 23 i
r>                   2.2.2.2                                0 23 i
*>  11.1.1.1/32      0.0.0.0                  0         32768 i
*>  22.2.2.2/32      4.4.4.4                                0 23 i
*                    2.2.2.2                  0             0 23 ?
*   44.4.4.4/32      4.4.4.4                  0             0 23 ?
*>                   2.2.2.2                                0 23 i

此是,BGP表显示从R2学来的22.2.2.2路由,origin-code属性已改为?(incomplete),从R4学来的44.4.4.4路由,属性也改为?(incomplete),优先选择origin-clde为i的路由。

IGP(i)优于EGP(e)优于incomplete(?)的路由。

R1#sh ip bgp 22.2.2.2
BGP routing table entry for 22.2.2.2/32, version 16
Paths: (2 available, best #1, table default)
  Advertised to update-groups:
     18        
  Refresh Epoch 1
  23
    4.4.4.4 (metric 1) from 4.4.4.4 (4.4.4.4)
      Origin IGP, localpref 100, valid, external, best
      rx pathid: 0, tx pathid: 0x0
  Refresh Epoch 1
  23
    2.2.2.2 (metric 1) from 2.2.2.2 (2.2.2.2)
      Origin incomplete, metric 0, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
R1#sh ip bgp 44.4.4.4
BGP routing table entry for 44.4.4.4/32, version 15
Paths: (2 available, best #2, table default)
  Advertised to update-groups:
     18        
  Refresh Epoch 1
  23
    4.4.4.4 (metric 1) from 4.4.4.4 (4.4.4.4)
      Origin incomplete, metric 0, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 1
  23
    2.2.2.2 (metric 1) from 2.2.2.2 (2.2.2.2)
      Origin IGP, localpref 100, valid, external, best
      rx pathid: 0, tx pathid: 0x0
实验完成。


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-88626-1-1.html 上篇帖子: cisco设备管理 下篇帖子: [Lab8]BGP
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表