天天看點

BGP集訓營:第三天BGP的選路屬性

BGP選路屬性:

1、 ORIGIN

2、 LOCAL-PREF

3、 MED

4、 Weight

5、 AS-PATH

BGP選路、過濾工具:

1、 route-map:origin local-pref,weight,AS-PATH,MED

下面三種用于過濾使用

2、 distribute-list

3、 prefix-list

4、 AS-PATH ACL

Default-metric不能直接發BGP協定下面使用,如果要讓它生效,必須在重分發裡面進行使用。如果要使用default-metric它必須使用在IGP路由協定裡面才有效果。

R0(config-router)#redistribute connected route-map x metric 200

AS-PATH屬性PREPENDING:僞造AS-PATH長度。對于IBGP更新,不生效。對于EBGP更新,可以對進站或出站更新可以進行AS-PATH屬性進行僞造。

進站:僞造的AS号是附加在AS-PATH屬性的開頭。

出站:僞造的AS号碼是附加在AS-PATH屬性的後面。

盡可能的使用出站方向僞造。

起源屬性:

首先把基本配置配置好:

在R1上面檢視一下BGP:

R1#sh ip bgp

BGP table version is 4, local router ID is 2.2.2.2

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

* 1.1.1.0/24 192.168.2.1 0 0 1 i

*> 192.168.1.1 0 0 1 i

R1#

現在在R1上面配置一個route-map

R1(config)#route-map x

R1(config-route-map)#set origin incomplete

R1(config)#router bgp 2

R1(config-router)#neighbor 192.168.1.1 route-map x in

R1(config-router)#end

R1#clear ip bgp * s

現在檢視一下R1上面BGP表:

BGP table version is 5, local router ID is 2.2.2.2

*> 1.1.1.0/24 192.168.2.1 0 0 1 i

* 192.168.1.1 0 0 1 ?

看看我的的最佳路由的下一跳是不是變成了192.168.2.1

這個如果在對端對也是一樣的效果。

現在我将R1上面通過BGP宣告一條2.2.2.0/24的網絡出去。

R1#conf t

Enter configuration commands, one per line. End with CNTL/Z.

R1(config)#router bgp

R1(config-router)#network 2.2.2.0 mask 255.255.255.0

R1#clear

*Mar 1 00:21:52.667: %SYS-5-CONFIG_I: Configured from console by console

現在檢視一下R1上面的BGP

本文轉自 ltyluck 51CTO部落格,原文連結:http://blog.51cto.com/ltyluck/204647

繼續閱讀