Local Preference とは
自律システムの出口パスを選択するために使用します。自律システム内のすべての内部BGPルータに送信され、外部BGPルータ間では交換されません。 同じプレフィックスに対して、値が高い方のパスが優先され、デフォルト値は100です。
検証
構成と設定
R5のループバック5.5.5.5/32をAS236のアドタイズします。ローカルプリファレンスを設定することで、AS236でこのループバック宛の経路は出口をR3にします。ルータ間はEIGRPで到達可能とします。

まず、図の通り、BGPピアリングします。
R5(config)# router bgp 5 R5(config-router)# neighbor 192.168.25.2 remote-as 236 R5(config-router)# neighbor 192.168.35.3 remote-as 236 R5(config-router)# network 5.5.5.5 mask 255.255.255.255 R2(config)# router bgp 236 R2(config-router)# neighbor 192.168.25.5 remote-as 5 R2(config-router)# neighbor 192.168.26.6 remote-as 236 R3(config)# router bgp 236 R3(config-router)# neighbor 192.168.35.5 remote-as 5 R3(config-router)# neighbor 192.168.36.6 remote-as 236 R6(config)# router bgp 236 R6(config-router)# neighbor 192.168.26.2 remote-as 236 R6(config-router)# neighbor 192.168.36.3 remote-as 236
確認
ここで、R6のBGPテーブルを確認します。
R6# show ip bgp
BGP table version is 2, local router ID is 6.6.6.6
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
* i 5.5.5.5/32 192.168.35.5 0 100 0 5 i
*>i 192.168.25.5 0 100 0 5 i
R2から学習したルート5.5.5.5/32をベストパスとしています。 詳しくみてみると、R2の方がR3よりルータIDが小さいためです。ローカルプリファレンスのデフォルト値は100です。
R6# show ip bgp 5.5.5.5 BGP routing table entry for 5.5.5.5/32, version 2 Paths: (2 available, best #2, table default) Not advertised to any peer 5 192.168.35.5 (metric 307200) from 192.168.36.3 (3.3.3.3) Origin IGP, metric 0, localpref 100, valid, internal rx pathid: 0, tx pathid: 0 5 192.168.25.5 (metric 307200) from 192.168.26.2 (2.2.2.2) Origin IGP, metric 0, localpref 100, valid, internal, best rx pathid: 0, tx pathid: 0x0
bgp default local-preference設定
R3を優先するため、R3のデフォルトのローカルプリファレンス値を1000に変更してみます。
R3(config)# router bgp 236 R3(config-router)# bgp default local-preference 1000
BGPのプロセスをクリアします。
R3# clear ip bgp * soft
R6のBGPテーブルを確認します。
R6# show ip bgp BGP table version is 3, local router ID is 6.6.6.6 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 *>i 5.5.5.5/32 192.168.35.5 0 1000 0 5 i * i 192.168.25.5 0 100 0 5 i
R6# show ip bgp 5.5.5.5 BGP routing table entry for 5.5.5.5/32, version 3 Paths: (2 available, best #1, table default) Not advertised to any peer 5 192.168.35.5 (metric 307200) from 192.168.36.3 (3.3.3.3) Origin IGP, metric 0, localpref 1000, valid, internal, best rx pathid: 0, tx pathid: 0x0 5 192.168.25.5 (metric 307200) from 192.168.26.2 (2.2.2.2) Origin IGP, metric 0, localpref 100, valid, internal
R3からのルートをベストパスとして認識しています。 LocPrfが1000に変更されていることがわかります。
route-mapによるlocal-preference設定
ルートマップでも同様のことが可能です。ローカルプリファレンスを900に変更するroute-mapを作成し、R3でR5からの入力側で適用します。設定後、BGPプロセスをクリアします。
R3(config)# route-map SETLocPrf permit 10 R3(config-route-map)# set local-preference 900 R3(config-route-map)# exit R3(config)# R3(config)# router bgp 236 R3(config-router)# neighbor 192.168.35.5 route-map SETLocPrf in R3(config-router)# exit R3(config)# exit R3# clear ip bgp * soft
R6のBGPテーブルを確認します。
R6# show ip bgp BGP table version is 4, local router ID is 6.6.6.6 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 *>i 5.5.5.5/32 192.168.35.5 0 900 0 5 i * i 192.168.25.5 0 100 0 5 i
R3をベストパスとして認識しています。 先に設定したbgp default local-preference 1000 の設定は削除しておらず、このコマンドで設定した値をルートマップは上書きします。
route-map に match コマンドを指定することで、特定のルートだけローカルプリファレンスを変更することもできます。
R5に55.55.55.55/32を追加し、ローカルプリファレンス値を555にします。5.5.5.5/32はデフォルト値のままです。
R5(config)# int loopback 55 R5(config-if)# ip add 55.55.55.55 255.255.255.255 R5(config)# router bgp 5 R5(config-router)# network 55.55.55.55 mask 255.255.255.255
R3(config)# access-list 1 permit 55.55.55.55 0.0.0.0 R3(config)# route-map SETLocPrf permit 10 R3(config-route-map)# match ip address 1 R3(config-route-map)# set local-preference 555 R3(config)# route-map SETLocPrf permit 1000 R3# clear ip bgp * soft
R6のBGPテーブルを確認します。
R6# show ip bgp BGP table version is 12, local router ID is 6.6.6.6 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 * i 5.5.5.5/32 192.168.25.5 0 100 0 5 i *>i 192.168.35.5 0 1000 0 5 i * i 55.55.55.55/32 192.168.25.5 0 100 0 5 i *>i 192.168.35.5 0 555 0 5 i
R3からの55.55.55.55/32はローカルプリファレンスが555に変更され、5.5.5.5/32はbgp default local-preferenceが反映され、ローカルプリファレンスは1000のままです。
その他 BGP関連記事は >> ルーティングプロトコル(BGP)まとめ << より参照できます。
コメント