BGP ローカルプリファレンスの設定(local-preference)





条件
R1,R2,R3 を AS123, R4 を AS400、R1-R4,R2-R4 をEBGP としてネイバーにします。
R4 の Lo0 に 44.44.44.44/24 を設定し AS300 へ広報します。
R3 から 44.44.44.0 へアクセスするために R1 or R2 を通りますが、どちらの経路を優先させるか
を local preference にて設定したいと思います。(R2 を通るようにしたいと思います。)


R1
interface f0/1
ip add 14.14.14.1 255.255.255.0
no shut

interface f0/0
ip add 13.13.13.1 255.255.255.0
no shut

interface lo0
ip add 1.1.1.1 255.255.255.255

router bgp 123
neighbor 3.3.3.3 remote-as 123
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 14.14.14.4 remote-as 400

ip route 2.2.2.2 255.255.255.255 13.13.13.3
ip route 3.3.3.3 255.255.255.255 13.13.13.3
ip route 23.23.23.0 255.255.255.0 13.13.13.3

R2
interface f0/0
ip add 24.24.24.2 255.255.255.0
no shut

interface f0/1
ip add 23.23.23.2 255.255.255.0
no shut

interface lo0
ip add 2.2.2.2 255.255.255.255

router bgp 123
neighbor 3.3.3.3 remote-as 123
neighbor 3.3.3.3 update-source lo0
neighbor 3.3.3.3 next-hop-self
neighbor 24.24.24.4 remote-as 400

ip route 1.1.1.1 255.255.255.255 23.23.23.3
ip route 3.3.3.3 255.255.255.255 23.23.23.3
ip route 23.23.23.0 255.255.255.0 23.23.23.3

R3
interface f0/0
ip add 23.23.23.3 255.255.255.0
no shut

interface f0/1
ip add 13.13.13.3 255.255.255.0
no shut

interface lo0
ip add 3.3.3.3 255.255.255.255

router bgp 123
neighbor 1.1.1.1 remote-as 123
neighbor 1.1.1.1 update-source lo0
neighbor 2.2.2.2 remote-as 123
neighbor 2.2.2.2 update-source lo0
network 13.13.13.0 mask 255.255.255.0
network 23.23.23.0 mask 255.255.255.0

ip route 1.1.1.1 255.255.255.255 13.13.13.1
ip route 2.2.2.2 255.255.255.255 23.23.23.2

R4
interface f0/0
ip add 14.14.14.4 255.255.255.0
no shut

interface f0/1
ip add 24.24.24.4 255.255.255.0
no shut

interface lo0
ip add 44.44.44.44 255.255.255.0

router bgp 400
neighbor 14.14.14.1 remote-as 123
neighbor 24.24.24.2 remote-as 123
network 44.44.44.0 mask 255.255.255.0


上記設定でAS123 と AS400 がネイバーになりました。
R3 にて sh ip bgp を見てみます。

R3#sh ip bgp
BGP table version is 6, 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
*> 13.13.13.0/24    0.0.0.0                  0         32768 i
*> 23.23.23.0/24    0.0.0.0                  0         32768 i

*>i44.44.44.0/24    1.1.1.1                  0    100      0 400 i
* i                 2.2.2.2                  0    100      0 400 i



44.44.44.0 へのルートは 1.1.1.1 経由と 2.2.2.2 経由があり、
経路選択の属性に違いがないことがわかります。
ではどちらの経路が使用されるかと言うと、、属性に違いがない場合
ルータIDの小さいピアを優先するとのことです。

参考:
http://atnetwork.info/ccnp1/bgp57.html

実際ルーティングを見てみます。

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
S       1.1.1.1 [1/0] via 13.13.13.1
     2.0.0.0/32 is subnetted, 1 subnets
S       2.2.2.2 [1/0] via 23.23.23.2
     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
     23.0.0.0/24 is subnetted, 1 subnets
C       23.23.23.0 is directly connected, FastEthernet0/0
     13.0.0.0/24 is subnetted, 1 subnets
C       13.13.13.0 is directly connected, FastEthernet0/1

     44.0.0.0/24 is subnetted, 1 subnets
B       44.44.44.0 [200/0] via 1.1.1.1, 00:05:13


ルータIDの小さいほうの 1.1.1.1 (R1) が選択されていることがわかりますね。
この経路を local preference 属性を変更して 2.2.2.2 経由になるようにします。

デフォルトの local preferene は 100 となっており、大きい値は優先されます。
そのため R1 → R3 に広報されるの値を下げるか R2 → R3 に広報される値を
上げるかの設定をします。今回は R2 → R3 の値を上げて (200) 対応してみたい
と思います。

R2
access-list 1 permit 44.44.44.0 0.0.0.255

route-map LP permit 10
match ip address 1
set local-preference 200
route-map LP permit 20
set local-preference 100

router bgp 123
neighbor 24.24.24.4 route-map LP in

24.24.24.4 から入ってくるルート情報のうち 44.44.44.0 のルートには
local-preference 200 を設定するというものです。
設定後 clear ip bgp * で BGPピアをリセットして再確立させます。

で、再度 sh ip bgp を見てみます。


R3#sh ip bgp
BGP table version is 11, 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
*> 13.13.13.0/24    0.0.0.0                  0         32768 i
*> 23.23.23.0/24    0.0.0.0                  0         32768 i

*>i44.44.44.0/24    2.2.2.2                  0    200      0 400 i
* i                 1.1.1.1                  0    100      0 400 i



2.2.2.2 から来た 44.44.44.0 へのルート情報が local preference 200
となっていることがわかります。また sh ip route でも 2.2.2.2 経由が
優先されていることがわかります。



     1.0.0.0/32 is subnetted, 1 subnets
S       1.1.1.1 [1/0] via 13.13.13.1
     2.0.0.0/32 is subnetted, 1 subnets
S       2.2.2.2 [1/0] via 23.23.23.2
     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
     23.0.0.0/24 is subnetted, 1 subnets
C       23.23.23.0 is directly connected, FastEthernet0/0
     13.0.0.0/24 is subnetted, 1 subnets
C       13.13.13.0 is directly connected, FastEthernet0/1
     44.0.0.0/24 is subnetted, 1 subnets
B       44.44.44.0 [200/0] via 2.2.2.2, 00:00:14




更新日:2013/4/24
TOPに戻る