【BGP】経路集約(aggregate-address、as-set)

BGP では、複数の経路を 1 つにまとめて(集約して)広告できます。コマンドは aggregate-address です。この記事では、集約経路の AS_PATH が、as-set の有無でどう変わるかを確認します。

注意

aggregate-address で集約経路を作って広告するには、集約の範囲に入る個別経路が、少なくとも 1 つ BGP テーブルにある必要があります。

集約経路は、aggregate-address を設定したルータが作った経路として扱われます。そのため、既定では、集約する前の個別経路が持っていた AS_PATH は、集約経路に引き継がれません。

ポイント

集約経路に、個別経路の AS_PATH を引き継がせるには、aggregate-address に as-set オプションを付けます。

この記事でわかること
  1. 集約する前の個別経路を確認する
  2. summary-only で集約すると、個別経路の AS が AS_PATH から消える
  3. as-set を付けると、個別経路の AS が AS_PATH に残る

検証構成

R1 に 4 つのループバックを作り、network コマンドで R2 に広告します。R2 は aggregate-address で集約して、R3 に広告します。

AS 1 AS 2 AS 3 R1 R2 R3 .1 .2 .2 .3 192.168.12.0/24 192.168.23.0/24 個別経路 172.16.0.0/24〜172.16.3.0/24 集約経路 172.16.0.0/22 Loopback100〜103 172.16.0.0/24〜172.16.3.0/24
図1 検証構成

集約する前の経路を確認する

まず、集約する前の基本設定をします。

R1

R1(config)# interface Loopback100 
R1(config-if)#  ip address 172.16.0.1 255.255.255.0
R1(config-if)# interface Loopback101
R1(config-if)#  ip address 172.16.1.1 255.255.255.0
R1(config-if)# interface Loopback102
R1(config-if)#  ip address 172.16.2.1 255.255.255.0
R1(config-if)# interface Loopback103
R1(config-if)#  ip address 172.16.3.1 255.255.255.0
R1(config-if)# exit
R1(config)# router bgp 1
R1(config-router)#  network 172.16.0.0 mask 255.255.255.0
R1(config-router)#  network 172.16.1.0 mask 255.255.255.0
R1(config-router)#  network 172.16.2.0 mask 255.255.255.0
R1(config-router)#  network 172.16.3.0 mask 255.255.255.0
R1(config-router)#  neighbor 192.168.12.2 remote-as 2

R2

R2(config)# router bgp 2
R2(config-router)#  neighbor 192.168.12.1 remote-as 1
R2(config-router)#  neighbor 192.168.23.3 remote-as 3

R3

R3(config)# router bgp 3
R3(config-router)#  neighbor 192.168.23.2 remote-as 2

R2 の BGP テーブルを確認すると、R1 の 4 つのループバックの経路を受け取っています。

R2

R2# show ip bgp
BGP table version is 21, 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, 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
 *>  172.16.0.0/24    192.168.12.1             0             0 1 i
 *>  172.16.1.0/24    192.168.12.1             0             0 1 i
 *>  172.16.2.0/24    192.168.12.1             0             0 1 i
 *>  172.16.3.0/24    192.168.12.1             0             0 1 i

R3 の BGP テーブルにも、R2 と同じように 4 つの経路があります。AS_PATH は「2 1」です。

R3

R3# show ip bgp
BGP table version is 5, 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, 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
 *>  172.16.0.0/24    192.168.23.2                           0 2 1 i
 *>  172.16.1.0/24    192.168.23.2                           0 2 1 i
 *>  172.16.2.0/24    192.168.23.2                           0 2 1 i
 *>  172.16.3.0/24    192.168.23.2                           0 2 1 i
ポイント

172.16.0.0/24、172.16.1.0/24、172.16.2.0/24、172.16.3.0/24 をまとめた経路は、172.16.0.0/22 です。

summary-only で集約する

R2 で、aggregate-address で 172.16.0.0/22 を設定します。今回は集約経路だけを広告したいので、summary-only を付けます。

R2

R2(config)# router bgp 2
R2(config-router)# aggregate-address 172.16.0.0 255.255.252.0 summary-only 

R2 の BGP テーブルを確認すると、個別経路に s(suppressed:広告を止めている)が付いています。

R2

R2# show ip bgp
BGP table version is 26, 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, 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
 s>  172.16.0.0/24    192.168.12.1             0             0 1 i
 *>  172.16.0.0/22    0.0.0.0                            32768 i
 s>  172.16.1.0/24    192.168.12.1             0             0 1 i
 s>  172.16.2.0/24    192.168.12.1             0             0 1 i
 s>  172.16.3.0/24    192.168.12.1             0             0 1 I

集約経路の詳細を確認すると、R2 が自分で作った経路(Local)になっています。

R2

R2# show ip bgp 172.16.0.0 255.255.252.0
BGP routing table entry for 172.16.0.0/22, version 22
Paths: (1 available, best #1, table default)
  Advertised to update-groups:
     1         
  Refresh Epoch 1
  Local, (aggregated by 2 2.2.2.2)
    0.0.0.0 from 0.0.0.0 (2.2.2.2)
      Origin IGP, localpref 100, weight 32768, valid, aggregated, local, atomic-aggregate, best
表示意味
Local, (aggregated by 2 2.2.2.2)AS_PATH は空。AS 2 のルータ 2.2.2.2 が作った集約経路
atomic-aggregate集約で AS_PATH の情報が失われていることを示す属性。as-set を付けない集約で付く

R2 は R3 に、集約経路 172.16.0.0/22 だけを広告しています。

R2

R2# show ip bgp neighbors 192.168.23.3 advertised-routes 
BGP table version is 26, 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, 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
 *>  172.16.0.0/22    0.0.0.0                            32768 i

Total number of prefixes 1

R3 の BGP テーブルを確認すると、AS_PATH は R2 の AS 番号 2 だけです。

R3

R3# show ip bgp 
BGP table version is 10, 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, 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
 *>  172.16.0.0/22    192.168.23.2             0             0 2 i

R3

R3# show ip bgp 172.16.0.0 255.255.252.0
BGP routing table entry for 172.16.0.0/22, version 10
Paths: (1 available, best #1, table default)
  Not advertised to any peer
  Refresh Epoch 2
  2, (aggregated by 2 2.2.2.2)
    192.168.23.2 from 192.168.23.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, external, atomic-aggregate, best
ポイント

集約する前の個別経路は R1 の AS 1 で生成されていましたが、集約したことで、R3 から見ると生成元の AS 1 が AS_PATH から消えています。

as-set を付けて集約する

個別経路の生成元の AS 番号も AS_PATH に残すには、summary-only と一緒に as-set を付けます。

R2

R2(config)# router bgp 2
R2(config-router)# aggregate-address 172.16.0.0 255.255.252.0 summary-only as-set

R2 の BGP テーブルを確認すると、集約経路の AS_PATH に AS 1 が入っています。atomic-aggregate も付かなくなりました。

R2

R2# show ip bgp 172.16.0.0 255.255.252.0
BGP routing table entry for 172.16.0.0/22, version 27
Paths: (1 available, best #1, table default)
  Advertised to update-groups:
     1         
  Refresh Epoch 1
  1, (aggregated by 2 2.2.2.2)
    0.0.0.0 from 0.0.0.0 (2.2.2.2)
      Origin IGP, localpref 100, weight 32768, valid, aggregated, local, best

R3 の BGP テーブルを見ると、AS_PATH に AS 2 と AS 1 があります。

R3

R3# show 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, 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
 *>  172.16.0.0/22    192.168.23.2             0             0 2 1 i

R3

R3# show ip bgp 172.16.1.0 255.255.252.0
BGP routing table entry for 172.16.0.0/22, version 11
Paths: (1 available, best #1, table default)
  Not advertised to any peer
  Refresh Epoch 2
  2 1, (aggregated by 2 2.2.2.2)
    192.168.23.2 from 192.168.23.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, external, best
R2 の設定R3 が受け取る 172.16.0.0/22 の AS_PATHsummary-only2atomic-aggregate(AS 1 が消える)summary-only as-set21AS 1 が残る塗りつぶしの枠:as-set で集約経路に入った、個別経路の AS
図2 as-set の有無と AS_PATH
補足
  • as-set を付けると、集約経路の AS_PATH に、個別経路が通ってきた AS がまとめて(AS_SET として)入ります。この集約経路が AS 1 に戻っても、AS 1 は自分の AS 番号を見つけてループと判断できます。
  • AS_SET は、中の AS がいくつあっても、AS_PATH の長さとしては 1 と数えます。
  • 個別経路が多い場合、どれかが変わるたびに集約経路の AS_SET が変わり、集約経路が送り直されることがあります。as-set は、集約する経路が多いときは使い方に注意してください。

まとめ

設定R3 が受け取る AS_PATHatomic-aggregate
集約なし2 1(4 つの /24)なし
aggregate-address … summary-only2(AS 1 が消える)あり
aggregate-address … summary-only as-set2 1なし

コメント