BGP アトリビュート一覧
BGPアトリビュートは複数存在するが、よく利用されるのは以下4つ。
- Weight (Ciscoのみ)
 - Local Preference
 - AS path length
 - MED (Multi Exit Discriminator)
 
| Priority | Attribute | 説明 | Default | 
| 1 | Weight (Cisco独自) | 値が大きい方を採用 | 0 | 
| 2 | Local Preference | 値が大きい方を採用 | 100 | 
| 3 | Originate | このルータでiBGP/eBGPが生成されたか | – | 
| 4 | AS path length | 経由するASパスが最も短いもの | – | 
| 5 | Origin code | IGP < EGP < Incompleteの順で優先 | – | 
| 6 | MED | 値が小さい方を採用 | – | 
| 7 | eBGP path over iBGP path | 内部経路より外部経路を選択 | – | 
| 8 | Shortest IGP path to BGP next hop | 最小のIGP Metric | – | 
| 9 | Oldest path | 最初に受信したルート | – | 
| 10 | Router ID | 最小のBGP neighbor Router ID | – | 
| 11 | Neighbor IP addres | 最小のneighbor IP address | – | 
NW構成 (Cisco CML利用)
構成
- Routerホスト名、interface、IP address
 

BGP AS構成
- BGP AS構成

 
BGP Weight値と経路
- BGP Weightを使って以下のように制御したいとする。
 - (PC1 -> PC2 ) 緑破線
 - (PC2 -> PC1 ) 赤破線
 

BGP Weight値
Weightは値が大きい方が優先される
outbound インターフェイスが複数ある場合、Weight値が大きいIFからパケットが送出される。
【AS1】192.168.1.0/24 →【AS3】172.16.1.0/24 を考える

デフォルト
AS path lengthが少ない【経路1】が採用される。
【経路1】AS1 → AS2 → AS3
【経路2】AS1 → AS4 → AS5→ AS3
Weight値で想定通り制御する
Weight値により【経路2】が採用される。
【経路1】R1における、【AS2向け】 (neighbor 10.12.1.2 weight 15)
【経路2】R1における、【AS4向け】 (neighbor 10.14.1.4 weight 25)
※Config上、Weight値を変更しても反映しないので「clear ip bgp * soft in」などを忘れずに!
【AS3】172.16.1.0/24 →【AS1】192.168.1.0/24 を考える

デフォルト
AS path lengthが少ない【経路1】が採用される。
【経路1】AS3 → AS2 → AS1
【経路2】AS3 → AS5 → AS4→ AS1
Weight値で想定通り制御する
Weight値により【経路1】が採用される。
【経路1】R3における、【AS2向け】 (neighbor 10.23.1.2 weight 30)
【経路2】R3における、【AS5向け】 (neighbor 10.23.1.2 weight 10)
※Config上、Weight値を変更しても反映しないので「clear ip bgp * soft in」などを忘れずに!
config
R1-config
hostname R1 ! interface GigabitEthernet0/0 ip address 10.12.1.1 255.255.255.0 ! interface GigabitEthernet0/1 ip address 10.14.1.1 255.255.255.0 ! interface GigabitEthernet0/2 ip address 192.168.1.254 255.255.255.0 ! router bgp 1 bgp log-neighbor-changes network 192.168.1.0 neighbor 10.12.1.2 remote-as 2 neighbor 10.12.1.2 soft-reconfiguration inbound neighbor 10.12.1.2 weight 15 neighbor 10.14.1.4 remote-as 4 neighbor 10.14.1.4 soft-reconfiguration inbound neighbor 10.14.1.4 weight 25 ! control-plane ! end
R2-config
hostname R2 ! interface GigabitEthernet0/0 ip address 10.12.1.2 255.255.255.0 ! interface GigabitEthernet0/1 ip address 10.23.1.2 255.255.255.0 ! router bgp 2 bgp log-neighbor-changes neighbor 10.12.1.1 remote-as 1 neighbor 10.12.1.1 soft-reconfiguration inbound neighbor 10.23.1.3 remote-as 3 neighbor 10.23.1.3 soft-reconfiguration inbound ! control-plane ! end
R3-config
hostname R3 ! interface GigabitEthernet0/0 ip address 10.23.1.3 255.255.255.0 ! interface GigabitEthernet0/1 ip address 10.35.1.3 255.255.255.0 ! interface GigabitEthernet0/2 ip address 172.16.1.254 255.255.255.0 ! router bgp 3 bgp log-neighbor-changes network 172.16.1.0 mask 255.255.255.0 neighbor 10.23.1.2 remote-as 2 neighbor 10.23.1.2 soft-reconfiguration inbound neighbor 10.23.1.2 weight 30 neighbor 10.35.1.5 remote-as 5 neighbor 10.35.1.5 soft-reconfiguration inbound neighbor 10.35.1.5 weight 10 ! control-plane ! end
R4-config
hostname R4 ! interface GigabitEthernet0/0 ip address 10.14.1.4 255.255.255.0 ! interface GigabitEthernet0/1 ip address 10.45.1.4 255.255.255.0 ! router bgp 4 bgp log-neighbor-changes neighbor 10.14.1.1 remote-as 1 neighbor 10.14.1.1 soft-reconfiguration inbound neighbor 10.45.1.5 remote-as 5 neighbor 10.45.1.5 soft-reconfiguration inbound ! control-plane ! end
R5-config
hostname R5 ! interface GigabitEthernet0/0 ip address 10.45.1.5 255.255.255.0 ! interface GigabitEthernet0/1 ip address 10.35.1.5 255.255.255.0 ! router bgp 5 bgp log-neighbor-changes neighbor 10.35.1.3 remote-as 3 neighbor 10.35.1.3 soft-reconfiguration inbound neighbor 10.45.1.4 remote-as 4 neighbor 10.45.1.4 soft-reconfiguration inbound ! control-plane ! end
BGP確認ログ
R1
show ip bgp
R1#show ip bgp 
     Network          Next Hop            Metric LocPrf Weight Path
 *>   172.16.1.0/24    10.14.1.4                             25 4 5 3 i
 *                     10.12.1.2                             15 2 3 i
 *>   192.168.1.0      0.0.0.0                  0         32768 i
*>:Best Path
Weight 25と15 を比較する事により、Best Pathは[10.14.1.4]が採用される。
show ip bgp summary
R1#show ip bgp summary Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 10.12.1.2 4 2 50 48 4 0 0 00:38:31 1 10.14.1.4 4 4 50 49 4 0 0 00:38:30 1
[State/PfxRcd]よりAS2 / AS4 それぞれから経路を受けている事がわかる。
show ip route bgp
R1#show ip route bgp 
Gateway of last resort is not set
      172.16.0.0/24 is subnetted, 1 subnets
B        172.16.1.0 [20/0] via 10.14.1.4, 00:00:40
BGPテーブルより、ルーティングテーブルもNext-Hopは10.14.1.4になる
R2
R3#show ip bgp 
     Network          Next Hop            Metric LocPrf Weight Path
 *>   172.16.1.0/24    0.0.0.0                  0         32768 i
 *    192.168.1.0      10.35.1.5                             10 5 4 1 i
 *>                    10.23.1.2                             30 2 1 i
*>:Best Path
Weight 10と30 を比較する事により、Best Pathは[10.23.1.2]が採用される。
R3#show ip bgp summary Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 10.23.1.2 4 2 757 750 6 0 0 11:19:51 1 10.35.1.5 4 5 752 754 6 0 0 11:18:27 1
[State/PfxRcd]よりAS2 / AS4 それぞれから経路を受けている事がわかる。
R3#show ip route bgp Gateway of last resort is not set B 192.168.1.0/24 [20/0] via 10.23.1.2, 00:28:36
BGPテーブルより、ルーティングテーブルもNext-Hopは10.23.1.2になる
  
  
  
  
