スポンサーリンク
スポンサーリンク

BGP Local_Preference

 BGP Local Preference (Well-known discretionary) について記載します。

BGP Local Preferenceの目的

    BGP Local Preferenceは宛先NW向けの通信に対して、自ASから他ASに対してどのルータから出ていくか
調整する値になります。

属性優先度

優先順位  属性(attribute)
1:     Highetst Weight
2:     Highest LOCAL_PREF ←ココ
3:     Prefer locally originated
4:     Shortest AS_PATH
5:     Lowest Origin Type
6:     Lowest MED
7:       Prefer eBGP over iBGP
8:     Lowest IGP metric to the BGP NEXT_HOP
9:     Oldest Path
10:     Lowest Router ID
11:           Minimum Cluster list Length
12:           Lowest Neighbor Address

Cisco IOSのフォルト値は[100]
・値が大きい方が優先されます。

NW構成  ※BGP Local Preferenceは以下LPと記します。

BGP_Local_Pref

 

 

 

 

 

  1. 通信要件は以下の2種類の通信に関して検証をします。
    ① R1(Lo 1.1.1.1/32) ⇒ R4 (Lo 5.5.5.5/32)向け通信
    ② R1(Lo 1.1.1.1/32) ⇒ R4 (Lo 6.6.6.6/32)向け通信
  2. 通信経路は以下になるようLPを調整します。
    ① R1(Lo 1.1.1.1/32) ⇒ R4 (Lo 5.5.5.5/32)向け通信
      R1 ⇒ R2 ⇒ R4 ⇒ 5.5.5.5
    ② R1(Lo 1.1.1.1/32) ⇒ R4 (Lo 6.6.6.6/32)向け通信
      R1 ⇒ R3 ⇒ R4 ⇒ 6.6.6.6
  3. LP値の設定
    ①R2に以下の設定をします。
     5.5.5.5向け通信に対して、LP値 [700]を設定②R3に以下の設定をします。
     6.6.6.6向け通信に対して、LP値 [150]を設定
  4. 結果について
    通信経路は項番2の通りの経路となります。

Config

R1-config

hostname R1
!
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
interface GigabitEthernet0/0
ip address 10.12.1.1 255.255.255.0
!
interface GigabitEthernet0/1
ip address 10.13.1.1 255.255.255.0
!
router ospf 1
network 1.1.1.1 0.0.0.0 area 0
network 10.12.1.0 0.0.0.255 area 0
network 10.13.1.0 0.0.0.255 area 0
!
router bgp 100
bgp log-neighbor-changes
network 1.1.1.1 mask 255.255.255.255
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 update-source Loopback0
neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 update-source Loopback0
!
control-plane
!
end

R2-config

hostname R2
!
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface GigabitEthernet0/0
ip address 10.24.1.2 255.255.255.0
!
interface GigabitEthernet0/1
ip address 10.12.1.2 255.255.255.0
!
interface GigabitEthernet0/2
ip address 10.23.1.2 255.255.255.0
!
router ospf 1
network 2.2.2.2 0.0.0.0 area 0
network 10.12.1.0 0.0.0.255 area 0
network 10.23.1.0 0.0.0.255 area 0
!
router bgp 100
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 next-hop-self
neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 10.24.1.4 remote-as 200
neighbor 10.24.1.4 route-map LOCAL_PREF in
!
route-map LOCAL_PREF permit 10
match ip address 5
set local-preference 700
!
route-map LOCAL_PREF permit 20
!
access-list 5 permit 5.5.5.5
access-list 6 permit 6.6.6.6
!
control-plane
!
end

R3-config

hostname R3
!
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface GigabitEthernet0/0
ip address 10.34.1.3 255.255.255.0
!
interface GigabitEthernet0/1
ip address 10.13.1.3 255.255.255.0
!
interface GigabitEthernet0/2
ip address 10.23.1.3 255.255.255.0
!
router ospf 1
network 3.3.3.3 0.0.0.0 area 0
network 10.13.1.0 0.0.0.255 area 0
network 10.23.1.0 0.0.0.255 area 0
!
router bgp 100
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 next-hop-self
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 10.34.1.4 remote-as 200
neighbor 10.34.1.4 route-map LOCAL_PREF in
!
route-map LOCAL_PREF permit 10
match ip address 6
set local-preference 150
!
route-map LOCAL_PREF permit 20
!
!
access-list 5 permit 5.5.5.5
access-list 6 permit 6.6.6.6
!
control-plane
!
end

R4-config

hostname R4
!
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface Loopback5
ip address 5.5.5.5 255.255.255.255
!
interface Loopback6
ip address 6.6.6.6 255.255.255.255
!
interface GigabitEthernet0/0
ip address 10.24.1.4 255.255.255.0
!
interface GigabitEthernet0/1
ip address 10.34.1.4 255.255.255.0
!
router bgp 200
bgp log-neighbor-changes
network 4.4.4.4 mask 255.255.255.255
network 5.5.5.5 mask 255.255.255.255
network 6.6.6.6 mask 255.255.255.255
neighbor 10.24.1.2 remote-as 100
neighbor 10.34.1.3 remote-as 100
!
control-plane
!
end

Local-Preference設定 ※以下LP

R2

  1. access-list 5 permit 5.5.5.5
    ⇒LP値を設定したい経路をACLで定義
  2. route-map LOCAL_PREF permit 10
    match ip address 5
    set local-preference 700
    ⇒route-mapでLP値 “700”を定義
  3. route-map LOCAL_PREF permit 20
    ⇒その他経路はLP値定義から除外
  4. router bgp 100
    neighbor 10.24.1.4 route-map LOCAL_PREF in
    ⇒neighbor 10.24.1.4から入ってくる[5.5.5.5]経路について適用

R3

  1. access-list 6 permit 6.6.6.6
    ⇒LP値を設定したい経路をACLで定義
  2. route-map LOCAL_PREF permit 10
    match ip address 6
    set local-preference 150
    ⇒route-mapでLP値 “150”を定義
  3. route-map LOCAL_PREF permit 20
    ⇒その他経路はLP値定義から除外
  4. router bgp 100
    neighbor 10.34.1.4 route-map LOCAL_PREF in
    ⇒neighbor 10.34.1.4から入ってくる[6.6.6.6]経路について適用

R1でどのようにLP値が見えるのか?

R1#show ip bgp
Network       Next Hop           Metric     LocPrf       Weight          Path
*>i     5.5.5.5/32     2.2.2.2                   0         700               0           200 i
*>i     6.6.6.6/32     3.3.3.3                   0         150               0           200 i

各機器の経路情報

BGP_Local_Pref

 

 

 

 

 

show ip bgp

R1-show ip bgp
R1#show ip bgp
     Network          Next Hop            Metric LocPrf Weight Path  
 *>i  5.5.5.5/32       2.2.2.2                  0    700      0 200 i
 *>i  6.6.6.6/32       3.3.3.3                  0    150      0 200 i
R2-show ip bgp
R2#show ip bgp
     Network          Next Hop            Metric LocPrf Weight Path
 *>   5.5.5.5/32       10.24.1.4                0    700      0 200 i
 *>i  6.6.6.6/32       3.3.3.3                  0    150      0 200 i
 *                     10.24.1.4                0             0 200 i
R3-show ip bgp
R3#show ip bgp
     Network          Next Hop            Metric LocPrf Weight Path
 *>i  5.5.5.5/32       2.2.2.2                  0    700      0 200 i
 *                     10.34.1.4                0             0 200 i
 *>   6.6.6.6/32       10.34.1.4                0    150      0 200 i
R4-show ip bgp
R4#show ip bgp
     Network          Next Hop            Metric LocPrf Weight Path
 *>   5.5.5.5/32       0.0.0.0                  0         32768 i
 *>   6.6.6.6/32       0.0.0.0                  0         32768 i

show ip route bgp

R1-show ip bgp
R1#show ip route bgp
Gateway of last resort is not set
B        4.4.4.4 [200/0] via 2.2.2.2, 00:18:23
B        5.5.5.5 [200/0] via 2.2.2.2, 00:18:23
B        6.6.6.6 [200/0] via 3.3.3.3, 00:18:22
R2-show ip bgp
R2#show ip route bgp
Gateway of last resort is not set
B        4.4.4.4 [20/0] via 10.24.1.4, 00:18:38
B        5.5.5.5 [20/0] via 10.24.1.4, 00:18:38
B        6.6.6.6 [200/0] via 3.3.3.3,  00:18:37
R3-show ip bgp
R3#show ip route bgp
Gateway of last resort is not set
B        4.4.4.4 [20/0] via 10.34.1.4, 00:19:03
B        5.5.5.5 [200/0] via 2.2.2.2,  00:19:03
B        6.6.6.6 [20/0] via 10.34.1.4, 00:19:03
R4-show ip bgp
R4#show ip route bgp
Gateway of last resort is not set
B        1.1.1.1 [20/0] via 10.24.1.2, 00:19:48
BGPALL
スポンサーリンク
スポンサーリンク