BGP的local-preference试验

拓扑:

bgp的local-preference

因为BGPlocal-preference默认为100,而BGP默认选择local-preference较大的值作为下一跳

local-preference配置:在本地配置影响IBGP对等体出站

R1的配置:

Router>en

Router#conf t

Router(config)#host R1

R1(config)#int s1/1

R1(config-if)#ip add 10.1.1.1 255.255.255.0

R1(config-if)#no sh

R1(config-if)#int fa0/0

R1(config-if)#ip add 10.4.4.1 255.255.255.0

R1(config-if)#no sh

R1(config-if)#int lo 0

R1(config-if)#ip add 1.1.1.1 255.255.255.0

R1(config-if)#no sh

R1(config-if)#exi

R1(config)#router rip    bgp的底层协议我起的RIP

R1(config-router)#ver 2

R1(config-router)#no au

R1(config-router)#net 1.0.0.0

R1(config-router)#net 10.0.0.0 

R1(config-router)#end

R1(config)#int lo 1

R1(config-if)#ip add 100.100.100.100 255.255.255.0

R1(config-if)#no sh

R1(config-if)#exi

R1(config)#router bgp 100

R1(config-router)#net 100.100.100.0 mask 255.255.255.0   (公告100.100.100.0/24网段)

R1(config-router)#nei 2.2.2.2 remote 100

R1(config-router)#nei 2.2.2.2 update-source loopback 0  (指定更新源是LOOPBACK 0

R1(config-router)#nei 4.4.4.4 remote 200

R1(config-router)#nei 4.4.4.4 update-source lo 0

R1(config-router)#nei 4.4.4.4 ebgp-multihop 2  ebgp建立邻居时要配置)

 

R2 R3 R4 的配置与R1的类似

 

现在我们查看R3 R4bgp路由表:

R3#sh ip bgp

BGP table version is 3, local router ID is 3.3.3.3

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf     Weight Path

* i100.100.100.0/24    1.1.1.1                  0    100       0 100 i

*>                  2.2.2.2                                 0 100 i

* i200.200.200.0       1.1.1.1                  0    100       0 100 i

*>                  2.2.2.2                   0              0 100 i

 

R4#sh ip bgp

BGP table version is 3, local router ID is 4.4.4.4

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path

* i100.100.100.0/24    2.2.2.2                  0    100      0 100 i

*>                  1.1.1.1                  0             0 100 i

* i200.200.200.0       2.2.2.2                  0    100      0 100 i

*>                  1.1.1.1                                0 100 i

发现R3 学到100.100.100.0/24 网络和200.200.200.0/24网络都是从R2学到的

发现R4 学到100.100.100.0/24 网络和200.200.200.0/24网络都是从R1学到的

这是为什么呢?为什么不是R3学到100.100.100.0/24 网络从R1而学200.200.200.0/24网络都是从R2学到呢?

这是因为EBGP优与IBGP

 

 

现在在R4上做local-preference来影响R3出站:让R3学到100.100.100.0/24 是从R1学到的。

 

R4(config)#access-list 1 per 100.100.100.0 0.0.0.255  (标示出要施加策略的网络)

R4(config)#route-map ccxx per 10                   (写ROUTE-MAP

R4(config-route-map)#ma ip add 1

R4(config-route-map)#set local-preference 200          (改变local-preference值,越大越优)

R4(config-route-map)#exi

R4(config)#route-map ccxx per 20                      (写一个空ROUTE-MAP

R4(config-route-map)#exi

R4(config)#router bgp 200

R4(config-router)#nei 1.1.1.1 route-map ccxx in            (套用ROUTE-MAP)

 

再查看R3 R4BGP路由表:

R3#sh ip bgp

BGP table version is 4, local router ID is 3.3.3.3

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop         Metric LocPrf Weight Path

*>i100.100.100.0/24   1.1.1.1            0    200      0 100 I  (变了吧!!(=^ ^=))

*                   2.2.2.2                           0 100 i

* i200.200.200.0       1.1.1.1              0    100      0 100 i

*>                  2.2.2.2               0             0 100 i

 

R4#sh ip bgp

BGP table version is 4, local router ID is 4.4.4.4

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path

*> 100.100.100.0/24   1.1.1.1                  0    200      0 100 i

* i200.200.200.0    2.2.2.2                  0    100      0 100 i

*>                  1.1.1.1                                0 100 i

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值