baron tech blog

学びをアウトプットしていきたいです

BGP in the Data Centerを読みました (5/6) : Chapter 5 - BGP Life Cycle Management

cumulusnetworks.com

だいぶ間が空いてしまいましたが、今回はChapter 5についてまとめました。

Chapter 4では、DCネットワーク向けのシンプルで自動化に適したBGP設定について見てきました。 Chapter 5では、ネットワークの初期設定後のメンテナンスについて見ていきます。具体的には、ルータのアップグレード等についてです。

データセンタネットワーク全般については、”Cloud-Native Data Center Networking” を読むのがおすすめです。 筆者が同じ方で、 "BGP in the Data Center" に記載されている内容も含まれています。 この本はCumulus Networksにより無償で公開されています。 ぜひ読んでみてください。

各Chapterまとめ

Chapter 5 - Reimagining BGP Configuration

Chapter 3, 4では、ツールによる自動化が容易な、データセンタ向けのシンプルなBGP設定について見てきました。 Chapter 5では、構築したデータセンタネットワークの運用方法や、インターネット等の外部ネットワークへの接続について見ていきます。

show コマンド

まずはBGPのステータス確認方法について見ていきます。 使用トポロジはChapter 4と同様です。

f:id:foobaron:20191012231255p:plain
サンプルネットワークトポロジ

BGPセッション情報の表示

BGPステータスを確認する最も基本的なコマンドは show ip bgp summary です。 FRRoutingの show ip bgp summary の出力例を次に示します。

cumulus@dc-leaf01:~$ sudo vtysh

Hello, this is FRRouting (version 4.0+cl3u13).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

dc-leaf01# show ip bgp summary

IPv4 Unicast Summary:
BGP router identifier 10.0.254.1, local AS number 4210000001 vrf-id 0
BGP table version 10
RIB entries 19, using 2888 bytes of memory
Peers 2, using 39 KiB of memory
Peer groups 1, using 64 bytes of memory

Neighbor         V         AS MsgRcvd MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd
dc-spine01(swp3) 4 4200000000     128     130        0    0    0 00:06:00            7
dc-spine02(swp4) 4 4200000000     128     130        0    0    0 00:06:00            7

Total number of neighbors 2

FRRoutingのCLIvtysh と呼ばれるものです。vtyshで show ip bgp summary を実行しています。 なお、bashから直接 vtysh -c "show ip bgp summary" を実行することも可能です。 本記事での以降の show コマンドは、 vtysh 上で実行しているものとします。

このコマンドは、IPv4のBGPセッションの結果のみを出力します。 BGPが誕生した当時にはIPv4しかなく、 ip というキーワードは、参照していたプロトコルの観点からは不明確でした。

IPv6の出現以降、IPv6のBGPセッションを表示するコマンドが登場しました。 AFI (Address Family Identifier) / SAFI (Subsequent Address Family Identifier) モデルにしたがって、

  • IPv4: show bgp ipv4 unicast summary
  • IPv6 show bgp ipv6 unicast summary

をサポートするようになっています。

このコマンドの出力結果の主なポイントは次のとおりです。

  • OSPF等の他のプロトコルとは異なり、ルータがピアリングすると想定されている全てのBGP neighborが一覧で表示される
  • 表の State/PfxRcd 列には、各BGPセッションの状態が一覧で表示される。セッションがEstablishedである場合は、状態名でなくピアから受信したIP prefix数が表示される
  • 表の Up/Down 列には、全てのBGPセッションの稼働時間 (BGPセッションがEstablishedでない場合は停止時間) が表示される
  • ノードのRouter IDやASN等の情報も表示される

表の V 列には、BGPのバージョンが表示されます。 現在使用されているBGPのバージョンは古くからあり、現在は基本的にversion 4が実行されています。

FRRoutingが他の実装と異なるのは、ピアのホスト名が表示される点です。 これは、Hostname Capability for BGPというInternet Draftに基づいています。 (このInternet Draftには、"BGP in the Data Center"の筆者のD. Dutt氏も貢献されています。) これにより、BGP OPENメッセージとともに、ホスト名を広報できます。

f:id:foobaron:20200112014945p:plain
BGP OPENメッセージにホスト名が含まれている様子

なお、show コマンドや clear コマンドでは、BGP neighborをホスト名で指定できます。

BGP neighborに関する詳細な情報は、 show ip bgp neighbors neighbor_name コマンドを使用します。 このコマンドの出力結果には、BGPセッションが最後にリセットされた時刻、リセットの理由、送受信されたBGPメッセージの数等の追加情報が含まれます。 コマンドの出力例を次に示します。

dc-leaf01# show bgp ipv4 neighbors dc-spine01
BGP neighbor on swp3: fe80::20c:29ff:feee:f3a6, remote AS 4200000000, local AS 4210000001, external link
Hostname: dc-spine01
 Member of peer-group ISL for session parameters
  BGP version 4, remote router ID 10.0.254.254
  BGP state = Established, up for 00:14:49
  Last read 00:00:01, Last write 00:00:01
  Hold time is 9, keepalive interval is 3 seconds
  Neighbor capabilities:
    4 Byte AS: advertised and received
    AddPath:
      IPv4 Unicast: RX advertised IPv4 Unicast and received
    Extended nexthop: advertised and received
      Address families by peer:
                   IPv4 Unicast
    Route refresh: advertised and received(old & new)
    Address Family IPv4 Unicast: advertised and received
    Hostname Capability: advertised (name: dc-leaf01,domain name: n/a) received (name: dc-spine01,domain name: n/a)
    Graceful Restart Capabilty: advertised and received
      Remote Restart timer is 120 seconds
      Address families by peer:
        none
  Graceful restart informations:
    End-of-RIB send: IPv4 Unicast
    End-of-RIB received: IPv4 Unicast
  Message statistics:
    Inq depth is 0
    Outq depth is 0
                         Sent       Rcvd
    Opens:                  2          2
    Notifications:          2          0
    Updates:               20         13
    Keepalives:          1588       1588
    Route Refresh:          0          0
    Capability:             0          0
    Total:               1612       1603
  Minimum time between advertisement runs is 0 seconds

 For address family: IPv4 Unicast
  ISL peer-group member
  Update group 1, subgroup 1
  Packet Queue length 0
  Community attribute sent to this neighbor(all)
  7 accepted prefixes

  Connections established 2; dropped 1
  Last reset 00:14:51, due to User reset
Local host: fe80::20c:29ff:fe99:e2d3, Local port: 38728
Foreign host: fe80::20c:29ff:feee:f3a6, Foreign port: 179
Nexthop: 10.0.254.1
Nexthop global: fe80::20c:29ff:fe99:e2d3
Nexthop local: fe80::20c:29ff:fe99:e2d3
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 5
Read thread: on  Write thread: on

  BFD: Type: single hop
    Detect Multiplier: 3, Min Rx interval: 300, Min Tx interval: 300
    Status: Up, Last update: 0:00:14:47

交換された経路情報の表示

次に、経路情報を確認するコマンドについて見ていきます。 このコマンドは、 show ip bgp または show bgp ipv4 unicast です。 コマンドの出力例を次に示します。

dc-leaf01# show ip bgp
BGP table version is 24, local router ID is 10.0.254.1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
              i internal, r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.0.254.1/32    0.0.0.0                  0         32768 ?
*= 10.0.254.2/32    swp3                                   0 4200000000 4210000002 ?
*>                  swp4                                   0 4200000000 4210000002 ?
*= 10.0.254.3/32    swp3                                   0 4200000000 4210000003 ?
*>                  swp4                                   0 4200000000 4210000003 ?
*= 10.0.254.4/32    swp3                                   0 4200000000 4210000004 ?
*>                  swp4                                   0 4200000000 4210000004 ?
*> 10.0.254.253/32  swp4                     0             0 4200000000 ?
*> 10.0.254.254/32  swp3                     0             0 4200000000 ?
*> 10.1.1.0/26      0.0.0.0                  0         32768 ?
*= 10.1.2.0/26      swp3                                   0 4200000000 4210000002 ?
*>                  swp4                                   0 4200000000 4210000002 ?
*= 10.1.3.0/26      swp3                                   0 4200000000 4210000003 ?
*>                  swp4                                   0 4200000000 4210000003 ?
*= 10.1.4.0/26      swp3                                   0 4200000000 4210000004 ?
*>                  swp4                                   0 4200000000 4210000004 ?

Displayed  10 routes and 16 total paths

出力結果で注目すべきポイントは、表のIP prefix (Network) 、Next Hop 、 各IP prefixに関連付けられた AS_PATH (Path) です。

行頭の*は、経路が有効、すなわちNext Hopへの到達性があるということを示します。 また、* の後の > はベストパス、 = は経路に複数の等コストパスがあることを示しています。

受信した特定のIP prefixに関する経路広告の詳細を取得するには、show ip bgp ip_prefixを使用します。

dc-leaf01# show ip bgp 10.0.254.3
BGP routing table entry for 10.0.254.3/32
Paths: (2 available, best #2, table default)
  Advertised to non peer-group peers:
  dc-spine01(swp3) dc-spine02(swp4)
  4200000000 4210000003
    fe80::20c:29ff:feee:f3a6 from dc-spine01(swp3) (10.0.254.254)
    (fe80::20c:29ff:feee:f3a6) (used)
      Origin incomplete, valid, external, multipath
      AddPath ID: RX 0, TX 20
      Last update: Sun Jan 12 01:41:55 2020

  4200000000 4210000003
    fe80::20c:29ff:fede:9b3c from dc-spine02(swp4) (10.0.254.253)
    (fe80::20c:29ff:fede:9b3c) (used)
      Origin incomplete, valid, external, multipath, bestpath-from-AS 4200000000, best
      AddPath ID: RX 0, TX 12
      Last update: Sun Jan 12 00:37:22 2020

外部ネットワークへの接続

これまでのChapterでは、データセンタ内のネットワークについて見てきました。

データセンタ内で動作するサービスを外部のユーザに提供したり、外部にあるデータをデータセンタ内から取得したりするためは、 インターネットのような外部ネットワークに接続する必要があります。

2層Closネットワークが外部に接続する一般的な方法は、次の図のとおりです。

f:id:foobaron:20200112223017p:plain
2層Closネットワークの外部への接続

図のexit01とexit02は、データセンタの内部と外部を区別するノードであり、border leafまたはexit leafと呼ばれます。 その上にあるノードがデータセンタのボーダールータであり、外部ネットワークとBGPピアを確立します。

border leafの機能

border leafは、次の機能を果たします。

  • AS_PATHからプライベートASを削除
    • BGP設定でneighbor neighbor_name remove-private-AS allを使用
  • (オプション) データセンタ内の経路を集約し、ボーダールータにサマリールートのみを広報
    • BGP設定でaggregate-address summary-route summary-onlyを使用
    • summary-only は個々の経路を送信してはならないことを指定
    • summary-onlyがないとサマリールートと個々の経路の両方が広報される
    • 経路が集約されsummary routeのみが広報されると、特に指定がない限りAS_PATH全体が削除される

また、ファイアウォールやロードバランサなどの様々なネットワーク機能を接続する箇所にも適しています。

border leafの数は、データセンタ内部の帯域と外部の帯域の間で想定されるオーバーサブスクリプション比率によって決定されます。 border leafが単一障害点となることを防ぐには、最低でも2台のborder leafが必要です。

外部ネットワークに多くの帯域幅を必要とする組織は多くありません。 しかし、サーバからのトラフィックの大半が外部に出ていく、メディア配信サービスを提供している場合もあるため、 サービスの要件に応じたネットワーク設計が必要です。

非常に大規模なClosネットワークでは、border leafのポート数よりもspineの台数が多くなってしまい、 border leafを全てのspineに接続できなくなってしまいます。 その場合には、層を追加したりborder leafを分割することで対処します。

一方、非常に小規模なClosネットワークでは、border leafを利用せずに直接spineがエッジルータと接続することも可能です。 しかし、ボーダールータのポートの方がspineスイッチやleafスイッチよりも高価であり、ネットワークを拡張するとコストが高くなってしまいます。 また、一部のspineのみを外部に接続すると、spineの機能が均一でなくなり、ネットワークの運用で混乱を招くことになるため、避けることが望ましいです。

ノードのメンテナンス

ネットワークを運用するにあたり、バグ修正等に伴って、スイッチのNetwork Operating System (NOS) をアップグレードしていくことが望ましいです。

スイッチのNOSをアップグレードする際に再起動が必要になります。 スイッチの再起動中に、スイッチのBGP neighborがトラフィックを転送し続けた場合、トラフィックがドロップしてしまいます。 それを回避するため、スイッチを停止させることが事前にわかっている場合、neighborにそのスイッチを迂回してトラフィックを転送させる必要があります。

f:id:foobaron:20191012231255p:plain
サンプルネットワークトポロジ (再掲)

例えば、上記のネットワークトポロジでspine01をアップグレードする場合、全てのleafのベストパス計算でspine01を無視し、spine02のみにトラフィックを送信させる必要があります。 中規模以上の企業では、spineノード4台以上が一般的です。 spineが4台の場合、spineのうち1台がメンテナンスで停止しても、East-Westトラフィックは75% (3/4) の帯域を継続して利用可能です。

Chapter 1で見てきたとおり、 サーバが2台のleafに接続するデュアルアタッチ接続モデルの場合、 leafのアップグレード中にspineからそのleafトラフィックを送信しないようにさせることで、通信のロスを防ぐことができます。 なお、デュアルアタッチ接続モデルでは、leafが1台停止するとサーバの帯域は半分になります。 web-scaleなデータセンタはサーバ台数が多く、ラック全体の喪失を許容できるため、各サーバが単一のleafに接続するシングルアタッチ接続モデルを採用しています。

BGPには、ネットワークから切り離すスイッチにトラフィックが流れないようにする (トラフィックをスイッチから排出させる) 機能がいくつかあります。 L3のネットワークでは、トラフィックが流れないようになった状態でスイッチをメンテナンスできるため、L2のネットワークと比較すると通信影響がありません。 (L3であれば、BGPでなくても同様です。)

AS_PATH Prepend

経路迂回の1つ目の方法がAS_PATH Prependの利用です。

データセンタネットワークでBGPのベストパス計算に最も影響のあるパラメータは AS_PATHです。 as-path prepend を設定することでAS_PATHの長さを増やし、宛先へのベストパス計算で優先度を下げます。

as-path prependは、BGPでの経路迂回の実現方法の中で最も一般的に実装されています。

例えば、leaf01によって広報された経路は、leaf03からは等コストマルチパスに見えます。

  • spine01経由のパス: 4200000000 4210000001 (AS_PATH長 2)
  • spine02経由のパス: 4200000000 4210000001 (AS_PATH長 2)
dc-leaf03# show ip bgp
BGP table version is 62, local router ID is 10.0.254.3
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
              i internal, r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*= 10.0.254.1/32    swp3                                   0 4200000000 4210000001 ?
*>                  swp4                                   0 4200000000 4210000001 ?
...

leaf03のFIBでは、leaf01宛の2つのネクストホップが確認できます。

dc-leaf03:~$ net show route 10.0.254.1
RIB entry for 10.0.254.1
========================
Routing entry for 10.0.254.1/32
  Known via "bgp", distance 20, metric 0, best
  Last update 00:07:44 ago
  * fe80::20c:29ff:fede:9b50, via swp4
  * fe80::20c:29ff:feee:f3ba, via swp3


FIB entry for 10.0.254.1
========================
10.0.254.1  proto bgp  metric 20
        nexthop via 169.254.0.1  dev swp4 weight 1 onlink
        nexthop via 169.254.0.1  dev swp3 weight 1 onlink

spine01をアップグレードする場合、AS_PATHの長さを増やすことでspine01経由のパスの使用を中止できます。

AS_PATHの長さを増やすには as-path prepend というBGP設定を利用します。 経路をBGP neighborに広報する前に、指定したASNがAS_PATHに1回追加されます。 追加するASNは、ノード自身のものが推奨されます。

設定方法の抜粋は次のとおりです。

route-mapMAINT permit <sequence_number>
set as-path prepend <ASN_list> # 経路広報の前にAS_PATHに1つ以上のASNを追加
neighbor ISL route-map MAINT out # as-path prepend用のroute-mapをoutbound方向 (経路広告の送信) に設定

spine01の設定全体は次のとおりです。

dc-spine01:~$ sudo cat /etc/frr/frr.conf
frr version 4.0+cl3u13
frr defaults datacenter
hostname dc-spine01
!
router bgp 4200000000
 bgp router-id 10.0.254.254
 no bgp default ipv4-unicast
 bgp bestpath as-path multipath-relax
 neighbor ISL peer-group
 neighbor ISL remote-as external
 neighbor ISL bfd
 neighbor ISL timers connect 5
 neighbor ISL capability extended-nexthop
 neighbor swp1 interface peer-group ISL
 neighbor swp2 interface peer-group ISL
 neighbor swp3 interface peer-group ISL
 neighbor swp4 interface peer-group ISL
 !
 address-family ipv4 unicast
  redistribute connected route-map ADV_LO
  neighbor ISL activate
  neighbor ISL route-map MAINT out # as-path prepend用のroute-mapをoutbound方向 (経路広告の送信) に設定
  maximum-paths 64
 exit-address-family
!
route-map MAINT permit 10 # as-path prepend用のroute-map MAINTを定義
 set as-path prepend 4200000000 # 自身のASNを追加
!
route-map ADV_LO permit 10
 match interface lo
!

spine01でas-path prependを設定すると、spine01を経由するパスがベストパスに選出されなくなります。

  • spine01経由のパス: 4200000000 4200000000 4210000001 (AS_PATH長 3)
  • spine02経由のパス: 4200000000 4210000001 (AS_PATH長 2)
dc-leaf03# show ip bgp
BGP table version is 69, local router ID is 10.0.254.3
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
              i internal, r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*  10.0.254.1/32    swp3                                   0 4200000000 4200000000 4210000001 ?
*>                  swp4                                   0 4200000000 4210000001 ?

leaf03のFIBでは、leaf01宛のネクストホップがspine02経由のパスのみになりました。

dc-leaf03:~$ net show route 10.0.254.1
RIB entry for 10.0.254.1
========================
Routing entry for 10.0.254.1/32
  Known via "bgp", distance 20, metric 0, best
  Last update 00:02:21 ago
  * fe80::20c:29ff:fede:9b50, via swp4


FIB entry for 10.0.254.1
========================
10.0.254.1 via 169.254.0.1 dev swp4  proto bgp  metric 20 onlink

GRACEFUL_SHUTDOWN Community

経路迂回の2つ目の方法がGRACEFUL_SHUTDOWN Communityの利用です。

GRACEFUL_SHUTDOWNは、RFC 8326で定義されているBGP Communityです。 BGPノードがGRACEFUL_SHUTDOWN Communityが設定されたBGP UPDATEメッセージを受信すると、 LOCAL_PREF attributeの値をデフォルトの100から0に下げることで優先度を落とします。 それにより、GRACEFUL_SHUTDOWNを広報したBGPノードを通過するパスがベストパスに選出されなくなります。

IANAのBGP Well-known Communitiesに記載されているとおり、 GRACEFUL_SHUTDOWNの値は0xFFFF0000です。

f:id:foobaron:20200114164150p:plain
GRACEFUL_SHUTDOWN Communityが付与されたBGP UPDATEメッセージ

FRRoutingでの設定方法は、bgp graceful-shutdownです。 他の実装では、route-map等の設定が追加で必要になります。

dc-spine01:~$ sudo cat /etc/frr/frr.conf`
frr version 4.0+cl3u13
frr defaults datacenter
hostname dc-spine01
!
router bgp 4200000000
 bgp router-id 10.0.254.254
 no bgp default ipv4-unicast
 bgp graceful-shutdown # GRACEFUL_SHUTDOWN Communityを有効化
 bgp bestpath as-path multipath-relax
 neighbor ISL peer-group
 neighbor ISL remote-as external
 neighbor ISL bfd
 neighbor ISL timers connect 5
 neighbor ISL capability extended-nexthop
 neighbor swp1 interface peer-group ISL
 neighbor swp2 interface peer-group ISL
 neighbor swp3 interface peer-group ISL
 neighbor swp4 interface peer-group ISL
 !
 address-family ipv4 unicast
  redistribute connected route-map ADV_LO
  neighbor ISL activate
  maximum-paths 64
 exit-address-family
!
route-map ADV_LO permit 10
 match interface lo
!

spine01でGRACEFUL_SHUTDOWN Communityを有効化した状態で、leaf03からleaf01への経路を確認すると、 spine01を経由するパスがベストパスでなくなっていることがわかります。

dc-leaf03# show ip bgp 10.0.254.1
BGP routing table entry for 10.0.254.1/32
Paths: (2 available, best #2, table default)
  Advertised to non peer-group peers:
  dc-spine01(swp3) dc-spine02(swp4)
  4200000000 4210000001
    fe80::20c:29ff:feee:f3ba from dc-spine01(swp3) (10.0.254.254)
    (fe80::20c:29ff:feee:f3ba) (used)
      Origin incomplete, localpref 0, valid, external
      Community: graceful-shutdown # GRACEFUL_SHUTDOWN Communityが有効
      AddPath ID: RX 0, TX 43
      Last update: Tue Jan 14 01:48:45 2020

  4200000000 4210000001
    fe80::20c:29ff:fede:9b50 from dc-spine02(swp4) (10.0.254.253)
    (fe80::20c:29ff:fede:9b50) (used)
      Origin incomplete, valid, external, bestpath-from-AS 4200000000, best
      AddPath ID: RX 0, TX 27
      Last update: Mon Jan 13 23:30:35 2020
dc-leaf03:~$ net show route 10.0.254.1
RIB entry for 10.0.254.1
========================
Routing entry for 10.0.254.1/32
  Known via "bgp", distance 20, metric 0, best
  Last update 14:51:07 ago
  * fe80::20c:29ff:fede:9b50, via swp4


FIB entry for 10.0.254.1
========================
10.0.254.1 via 169.254.0.1 dev swp4  proto bgp  metric 20 onlink

Max-MED

経路迂回の3つ目の方法がMax-MEDです。

広報された経路のMED attributeを変更することで、ベストパス計算における優先度を下げます。 FRRoutingでは、max-medというBGP設定をサポートしています。

dc-spine01:~$ sudo cat /etc/frr/frr.conf

frr version 4.0+cl3u13
frr defaults datacenter
hostname dc-spine01
!
router bgp 4200000000
 bgp router-id 10.0.254.254
 no bgp default ipv4-unicast
 bgp max-med administrative # Max-MEDを有効化
 bgp bestpath as-path multipath-relax
 neighbor ISL peer-group
 neighbor ISL remote-as external
 neighbor ISL bfd
 neighbor ISL timers connect 5
 neighbor ISL capability extended-nexthop
 neighbor swp1 interface peer-group ISL
 neighbor swp2 interface peer-group ISL
 neighbor swp3 interface peer-group ISL
 neighbor swp4 interface peer-group ISL
 !
 address-family ipv4 unicast
  redistribute connected route-map ADV_LO
  neighbor ISL activate
  maximum-paths 64
 exit-address-family
!
route-map ADV_LO permit 10
 match interface lo
!

spine01でMax-MEDを有効化する前の、RIBのエントリは次のとおりです。

dc-leaf03# show ip bgp
BGP table version is 105, local router ID is 10.0.254.3
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
              i internal, r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*= 10.0.254.1/32    swp3                                   0 4200000000 4210000001 ?
*>                  swp4                                   0 4200000000 4210000001 ?
*= 10.0.254.2/32    swp3                                   0 4200000000 4210000002 ?
*>                  swp4                                   0 4200000000 4210000002 ?
*> 10.0.254.3/32    0.0.0.0                  0         32768 ?
*= 10.0.254.4/32    swp3                                   0 4200000000 4210000004 ?
*>                  swp4                                   0 4200000000 4210000004 ?
*> 10.0.254.253/32  swp4                     0             0 4200000000 ?
*> 10.0.254.254/32  swp3                     0             0 4200000000 ?
*= 10.1.1.0/26      swp3                                   0 4200000000 4210000001 ?
*>                  swp4                                   0 4200000000 4210000001 ?
*= 10.1.2.0/26      swp3                                   0 4200000000 4210000002 ?
*>                  swp4                                   0 4200000000 4210000002 ?
*> 10.1.3.0/26      0.0.0.0                  0         32768 ?
*= 10.1.4.0/26      swp3                                   0 4200000000 4210000004 ?
*>                  swp4                                   0 4200000000 4210000004 ?

Displayed  10 routes and 16 total paths

Max-MEDを有効化すると、MED (Metric) が 4294967294になり、ベストパスに選出されなくなったことが確認できます。

dc-leaf03# show ip bgp
BGP table version is 112, local router ID is 10.0.254.3
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
              i internal, r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*  10.0.254.1/32    swp3            4294967294             0 4200000000 4210000001 ?
*>                  swp4                                   0 4200000000 4210000001 ?
*  10.0.254.2/32    swp3            4294967294             0 4200000000 4210000002 ?
*>                  swp4                                   0 4200000000 4210000002 ?
*> 10.0.254.3/32    0.0.0.0                  0         32768 ?
*  10.0.254.4/32    swp3            4294967294             0 4200000000 4210000004 ?
*>                  swp4                                   0 4200000000 4210000004 ?
*> 10.0.254.253/32  swp4                     0             0 4200000000 ?
*> 10.0.254.254/32  swp3            4294967294             0 4200000000 ?
*  10.1.1.0/26      swp3            4294967294             0 4200000000 4210000001 ?
*>                  swp4                                   0 4200000000 4210000001 ?
*  10.1.2.0/26      swp3            4294967294             0 4200000000 4210000002 ?
*>                  swp4                                   0 4200000000 4210000002 ?
*> 10.1.3.0/26      0.0.0.0                  0         32768 ?
*  10.1.4.0/26      swp3            4294967294             0 4200000000 4210000004 ?
*>                  swp4                                   0 4200000000 4210000004 ?

Displayed  10 routes and 16 total paths

BGPのデバッグ

他のソフトウェアと同様に、BGPはバグまたはオペレータによる誤解が原因で、予期せぬ動作をすることがあります。 このような問題に対するには、デバッグを有効化しデバッグログの調査をするのが一般的です。 FRRoutingでは、debug bgpを使用します。 dubug bgpでは、次の3つのオプションが特に重要です。

neighbor-events

BGPセッションをデバッグするために使用します。

どちらのエンドが接続を開始したかや、BGPの状態遷移、どのCapabilityが交換された等の情報が確認できます。

debug bgpの設定を抜粋すると次のとおりです。

dc-leaf03:~$ sudo cat /etc/frr/frr.conf
!
debug bgp neighbor-events # BGPセッション (BGP neighborの状態遷移) のデバッグを有効化
log file /var/log/frr/debug.log # デバッグログを/var/log/frr/debug.logに書き出し
!

leaf03がclear bgp *を実行してspine01, spine02とのBGPセッションを切断後、 再度BGPセッションを確立し経路広報するまでのデバッグログは次のとおりでした。

dc-leaf03:~$ sudo cat /var/log/frr/debug.log
2020/01/16 00:37:58 BGP: %NOTIFICATION: sent to neighbor swp3 6/4 (Cease/Administratively Reset) 0 bytes
2020/01/16 00:37:58 BGP: %NOTIFICATION: sent to neighbor swp4 6/4 (Cease/Administratively Reset) 0 bytes
2020/01/16 00:37:58 BGP: swp3 [FSM] BGP_Stop (Established->Clearing), fd 26
2020/01/16 00:37:58 BGP: %ADJCHANGE: neighbor swp3(dc-spine01) in vrf default Down User reset
2020/01/16 00:37:58 BGP: swp3 went from Established to Clearing
2020/01/16 00:37:58 BGP: swp4 [FSM] BGP_Stop (Established->Clearing), fd 22
2020/01/16 00:37:58 BGP: %ADJCHANGE: neighbor swp4(dc-spine02) in vrf default Down User reset
2020/01/16 00:37:58 BGP: swp4 went from Established to Clearing
2020/01/16 00:37:58 BGP: swp3 [FSM] Clearing_Completed (Clearing->Idle), fd -1
2020/01/16 00:37:58 BGP: swp3 went from Clearing to Idle
2020/01/16 00:37:58 BGP: swp4 [FSM] Clearing_Completed (Clearing->Idle), fd -1
2020/01/16 00:37:58 BGP: swp4 went from Clearing to Idle
2020/01/16 00:38:00 BGP: swp3 [FSM] Timer (start timer expire).
2020/01/16 00:38:00 BGP: swp3 [FSM] BGP_Start (Idle->Connect), fd -1
2020/01/16 00:38:00 BGP: swp3 [Event] Connect start to swp3 fd 22
2020/01/16 00:38:00 BGP: swp3 [FSM] Non blocking connect waiting result, fd 22
2020/01/16 00:38:00 BGP: swp3 went from Idle to Connect
2020/01/16 00:38:00 BGP: swp4 [FSM] Timer (start timer expire).
2020/01/16 00:38:00 BGP: swp4 [FSM] BGP_Start (Idle->Connect), fd -1
2020/01/16 00:38:00 BGP: swp4 [Event] Connect start to swp4 fd 26
2020/01/16 00:38:00 BGP: swp4 [FSM] Non blocking connect waiting result, fd 26
2020/01/16 00:38:00 BGP: swp4 went from Idle to Connect
2020/01/16 00:38:00 BGP: [Event] BGP connection from host fe80::20c:29ff:fede:9b50 fd 27
2020/01/16 00:38:00 BGP: bind to interface swp4 failed, errno=1
2020/01/16 00:38:00 BGP: swp4 went from Idle to Active
2020/01/16 00:38:00 BGP: swp4 [FSM] TCP_connection_open (Active->OpenSent), fd 27
2020/01/16 00:38:00 BGP: swp4 passive open
2020/01/16 00:38:00 BGP: swp4 Sending hostname cap with hn = dc-leaf03, dn = (null)
2020/01/16 00:38:00 BGP: swp4 sending OPEN, version 4, my as 4210000003, holdtime 9, id 10.0.254.3
2020/01/16 00:38:00 BGP: swp4 went from Active to OpenSent
2020/01/16 00:38:00 BGP: swp3 [FSM] TCP_connection_open (Connect->OpenSent), fd 22
2020/01/16 00:38:00 BGP: swp3 open active, local address fe80::20c:29ff:fe33:e2c7
2020/01/16 00:38:00 BGP: swp3 Sending hostname cap with hn = dc-leaf03, dn = (null)
2020/01/16 00:38:00 BGP: swp3 sending OPEN, version 4, my as 4210000003, holdtime 9, id 10.0.254.3
2020/01/16 00:38:00 BGP: swp3 went from Connect to OpenSent
2020/01/16 00:38:00 BGP: swp4 [FSM] TCP_connection_open (Connect->OpenSent), fd 26
2020/01/16 00:38:00 BGP: swp4 open active, local address fe80::20c:29ff:fe33:e2d1
2020/01/16 00:38:00 BGP: swp4 Sending hostname cap with hn = dc-leaf03, dn = (null)
2020/01/16 00:38:00 BGP: swp4 sending OPEN, version 4, my as 4210000003, holdtime 9, id 10.0.254.3
2020/01/16 00:38:00 BGP: swp4 went from Connect to OpenSent
2020/01/16 00:38:00 BGP: [Event] BGP connection from host fe80::20c:29ff:feee:f3ba fd 28
2020/01/16 00:38:00 BGP: swp3 [Event] BGP connection closed fd 22
2020/01/16 00:38:00 BGP: bind to interface swp3 failed, errno=1
2020/01/16 00:38:00 BGP: swp3 went from Idle to Active
2020/01/16 00:38:00 BGP: swp3 [FSM] TCP_connection_closed (OpenSent->Active), fd 22
2020/01/16 00:38:00 BGP: swp3 went from OpenSent to Active
2020/01/16 00:38:00 BGP: swp3 [FSM] TCP_connection_open (Active->OpenSent), fd 28
2020/01/16 00:38:00 BGP: swp3 passive open
2020/01/16 00:38:00 BGP: swp3 Sending hostname cap with hn = dc-leaf03, dn = (null)
2020/01/16 00:38:00 BGP: swp3 sending OPEN, version 4, my as 4210000003, holdtime 9, id 10.0.254.3
2020/01/16 00:38:00 BGP: swp3 went from Active to OpenSent
2020/01/16 00:38:00 BGP: swp4 rcv OPEN, version 4, remote-as (in open) 23456, holdtime 9, id 10.0.254.253
2020/01/16 00:38:00 BGP: swp4 [Event] BGP connection closed fd 26
2020/01/16 00:38:00 BGP: swp4 rcv OPEN w/ OPTION parameter len: 64
2020/01/16 00:38:00 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 6
2020/01/16 00:38:00 BGP: swp4 OPEN has MultiProtocol Extensions capability (1), length 4
2020/01/16 00:38:00 BGP: swp4 OPEN has MP_EXT CAP for afi/safi: 1/1
2020/01/16 00:38:00 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 8
2020/01/16 00:38:00 BGP: swp4 OPEN has Extended Next Hop Encoding capability (5), length 6
2020/01/16 00:38:00 BGP: swp4 Received with afi/safi/next-hop afi: 1/1/2
2020/01/16 00:38:00 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 2
2020/01/16 00:38:00 BGP: swp4 OPEN has Route Refresh (Old) capability (128), length 0
2020/01/16 00:38:00 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 2
2020/01/16 00:38:00 BGP: swp4 OPEN has Route Refresh capability (2), length 0
2020/01/16 00:38:00 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 6
2020/01/16 00:38:00 BGP: swp4 OPEN has 4-octet AS number capability (65), length 4
2020/01/16 00:38:00 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 6
2020/01/16 00:38:00 BGP: swp4 OPEN has AddPath capability (69), length 4
2020/01/16 00:38:00 BGP: swp4 OPEN has AddPath CAP for afi/safi: 1/1, receive
2020/01/16 00:38:00 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 14
2020/01/16 00:38:00 BGP: swp4 OPEN has FQDN capability (73), length 12
2020/01/16 00:38:00 BGP: swp4 received hostname dc-spine02, domainname (null)
2020/01/16 00:38:00 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 4
2020/01/16 00:38:00 BGP: swp4 OPEN has Graceful Restart capability (64), length 2
2020/01/16 00:38:00 BGP: swp4 OPEN has Graceful Restart capability
2020/01/16 00:38:00 BGP: swp4 Peer has not restarted. Restart Time : 120
2020/01/16 00:38:00 BGP: %NOTIFICATION: sent to neighbor swp4 6/7 (Cease/Connection collision resolution) 0 bytes
2020/01/16 00:38:00 BGP: swp4 [FSM] Receive_OPEN_message (OpenSent->OpenConfirm), fd 27
2020/01/16 00:38:00 BGP: swp4 went from OpenSent to OpenConfirm
2020/01/16 00:38:00 BGP: swp4 [FSM] Receive_KEEPALIVE_message (OpenConfirm->Established), fd 27
2020/01/16 00:38:00 BGP: swp4: peer transfer 0x4ad690f60 fd 27 -> 0x4ad67cd60 fd 26)
2020/01/16 00:38:00 BGP: [EC 100663299] Can't get remote address and port: Transport endpoint is not connected
2020/01/16 00:38:00 BGP: [EC 100663299] %bgp_getsockname() failed for accept from_peer swp4 fd 26 (peer fd 27)
2020/01/16 00:38:00 BGP: swp4 went from OpenSent to Deleted
2020/01/16 00:38:00 BGP: swp4 went from OpenConfirm to Established
2020/01/16 00:38:00 BGP: %ADJCHANGE: neighbor swp4(dc-spine02) in vrf default Up
2020/01/16 00:38:00 BGP: swp4 [FSM] TCP_connection_closed (Established->Clearing), fd 27
2020/01/16 00:38:00 BGP: %ADJCHANGE: neighbor swp4(dc-spine02) in vrf default Down BGP Notification send
2020/01/16 00:38:00 BGP: swp4 went from Established to Clearing
2020/01/16 00:38:00 BGP: swp3 rcv OPEN, version 4, remote-as (in open) 23456, holdtime 9, id 10.0.254.254
2020/01/16 00:38:00 BGP: swp3 rcv OPEN w/ OPTION parameter len: 64
2020/01/16 00:38:00 BGP: swp3 rcvd OPEN w/ optional parameter type 2 (Capability) len 6
2020/01/16 00:38:00 BGP: swp3 OPEN has MultiProtocol Extensions capability (1), length 4
2020/01/16 00:38:00 BGP: swp3 OPEN has MP_EXT CAP for afi/safi: 1/1
2020/01/16 00:38:00 BGP: swp3 rcvd OPEN w/ optional parameter type 2 (Capability) len 8
2020/01/16 00:38:00 BGP: swp3 OPEN has Extended Next Hop Encoding capability (5), length 6
2020/01/16 00:38:00 BGP: swp3 Received with afi/safi/next-hop afi: 1/1/2
2020/01/16 00:38:00 BGP: swp3 rcvd OPEN w/ optional parameter type 2 (Capability) len 2
2020/01/16 00:38:00 BGP: swp3 OPEN has Route Refresh (Old) capability (128), length 0
2020/01/16 00:38:00 BGP: swp3 rcvd OPEN w/ optional parameter type 2 (Capability) len 2
2020/01/16 00:38:00 BGP: swp3 OPEN has Route Refresh capability (2), length 0
2020/01/16 00:38:00 BGP: swp3 rcvd OPEN w/ optional parameter type 2 (Capability) len 6
2020/01/16 00:38:00 BGP: swp3 OPEN has 4-octet AS number capability (65), length 4
2020/01/16 00:38:00 BGP: swp3 rcvd OPEN w/ optional parameter type 2 (Capability) len 6
2020/01/16 00:38:00 BGP: swp3 OPEN has AddPath capability (69), length 4
2020/01/16 00:38:00 BGP: swp3 OPEN has AddPath CAP for afi/safi: 1/1, receive
2020/01/16 00:38:00 BGP: swp3 rcvd OPEN w/ optional parameter type 2 (Capability) len 14
2020/01/16 00:38:00 BGP: swp3 OPEN has FQDN capability (73), length 12
2020/01/16 00:38:00 BGP: swp3 received hostname dc-spine01, domainname (null)
2020/01/16 00:38:00 BGP: swp3 rcvd OPEN w/ optional parameter type 2 (Capability) len 4
2020/01/16 00:38:00 BGP: swp3 OPEN has Graceful Restart capability (64), length 2
2020/01/16 00:38:00 BGP: swp3 OPEN has Graceful Restart capability
2020/01/16 00:38:00 BGP: swp3 Peer has not restarted. Restart Time : 120
2020/01/16 00:38:00 BGP: swp3 [FSM] Receive_OPEN_message (OpenSent->OpenConfirm), fd 28
2020/01/16 00:38:00 BGP: swp3 went from OpenSent to OpenConfirm
2020/01/16 00:38:00 BGP: swp3 [FSM] Receive_KEEPALIVE_message (OpenConfirm->Established), fd 28
2020/01/16 00:38:00 BGP: swp3: peer transfer 0x4ad6a1710 fd 28 -> 0x4ad66b240 fd -1)
2020/01/16 00:38:00 BGP: swp3 went from OpenConfirm to Established
2020/01/16 00:38:00 BGP: %ADJCHANGE: neighbor swp3(dc-spine01) in vrf default Up
2020/01/16 00:38:00 BGP: [Event] Deleting stub connection for peer swp3
2020/01/16 00:38:00 BGP: swp3 went from Active to Deleted
2020/01/16 00:38:00 BGP: swp4 [FSM] Clearing_Completed (Clearing->Idle), fd -1
2020/01/16 00:38:00 BGP: swp4 went from Clearing to Idle
2020/01/16 00:38:00 BGP: swp3 [FSM] Timer (routeadv timer expire)
2020/01/16 00:38:01 BGP: swp4 [FSM] Timer (start timer expire).
2020/01/16 00:38:01 BGP: swp4 [FSM] BGP_Start (Idle->Connect), fd -1
2020/01/16 00:38:01 BGP: swp4 [Event] Connect start to swp4 fd 22
2020/01/16 00:38:01 BGP: swp4 [FSM] Non blocking connect waiting result, fd 22
2020/01/16 00:38:01 BGP: swp4 went from Idle to Connect
2020/01/16 00:38:01 BGP: [Event] BGP connection from host fe80::20c:29ff:fede:9b50 fd 26
2020/01/16 00:38:01 BGP: bind to interface swp4 failed, errno=1
2020/01/16 00:38:01 BGP: swp4 went from Idle to Active
2020/01/16 00:38:01 BGP: swp4 [FSM] TCP_connection_open (Active->OpenSent), fd 26
2020/01/16 00:38:01 BGP: swp4 passive open
2020/01/16 00:38:01 BGP: swp4 Sending hostname cap with hn = dc-leaf03, dn = (null)
2020/01/16 00:38:01 BGP: swp4 sending OPEN, version 4, my as 4210000003, holdtime 9, id 10.0.254.3
2020/01/16 00:38:01 BGP: swp4 went from Active to OpenSent
2020/01/16 00:38:01 BGP: swp4 [FSM] TCP_connection_open (Connect->OpenSent), fd 22
2020/01/16 00:38:01 BGP: swp4 open active, local address fe80::20c:29ff:fe33:e2d1
2020/01/16 00:38:01 BGP: swp4 Sending hostname cap with hn = dc-leaf03, dn = (null)
2020/01/16 00:38:01 BGP: swp4 sending OPEN, version 4, my as 4210000003, holdtime 9, id 10.0.254.3
2020/01/16 00:38:01 BGP: swp4 went from Connect to OpenSent
2020/01/16 00:38:01 BGP: swp4 rcv OPEN, version 4, remote-as (in open) 23456, holdtime 9, id 10.0.254.253
2020/01/16 00:38:01 BGP: swp4 rcv OPEN w/ OPTION parameter len: 64
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 6
2020/01/16 00:38:01 BGP: swp4 OPEN has MultiProtocol Extensions capability (1), length 4
2020/01/16 00:38:01 BGP: swp4 OPEN has MP_EXT CAP for afi/safi: 1/1
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 8
2020/01/16 00:38:01 BGP: swp4 OPEN has Extended Next Hop Encoding capability (5), length 6
2020/01/16 00:38:01 BGP: swp4 Received with afi/safi/next-hop afi: 1/1/2
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 2
2020/01/16 00:38:01 BGP: swp4 OPEN has Route Refresh (Old) capability (128), length 0
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 2
2020/01/16 00:38:01 BGP: swp4 OPEN has Route Refresh capability (2), length 0
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 6
2020/01/16 00:38:01 BGP: swp4 OPEN has 4-octet AS number capability (65), length 4
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 6
2020/01/16 00:38:01 BGP: swp4 OPEN has AddPath capability (69), length 4
2020/01/16 00:38:01 BGP: swp4 OPEN has AddPath CAP for afi/safi: 1/1, receive
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 14
2020/01/16 00:38:01 BGP: swp4 OPEN has FQDN capability (73), length 12
2020/01/16 00:38:01 BGP: swp4 received hostname dc-spine02, domainname (null)
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 4
2020/01/16 00:38:01 BGP: swp4 OPEN has Graceful Restart capability (64), length 2
2020/01/16 00:38:01 BGP: swp4 OPEN has Graceful Restart capability
2020/01/16 00:38:01 BGP: swp4 Peer has not restarted. Restart Time : 120
2020/01/16 00:38:01 BGP: %NOTIFICATION: sent to neighbor swp4 6/7 (Cease/Connection collision resolution) 0 bytes
2020/01/16 00:38:01 BGP: swp4 [FSM] Receive_OPEN_message (OpenSent->OpenConfirm), fd 26
2020/01/16 00:38:01 BGP: swp4 went from OpenSent to OpenConfirm
2020/01/16 00:38:01 BGP: swp4 rcv OPEN, version 4, remote-as (in open) 23456, holdtime 9, id 10.0.254.253
2020/01/16 00:38:01 BGP: swp4 rcv OPEN w/ OPTION parameter len: 64
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 6
2020/01/16 00:38:01 BGP: swp4 OPEN has MultiProtocol Extensions capability (1), length 4
2020/01/16 00:38:01 BGP: swp4 OPEN has MP_EXT CAP for afi/safi: 1/1
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 8
2020/01/16 00:38:01 BGP: swp4 OPEN has Extended Next Hop Encoding capability (5), length 6
2020/01/16 00:38:01 BGP: swp4 Received with afi/safi/next-hop afi: 1/1/2
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 2
2020/01/16 00:38:01 BGP: swp4 OPEN has Route Refresh (Old) capability (128), length 0
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 2
2020/01/16 00:38:01 BGP: swp4 OPEN has Route Refresh capability (2), length 0
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 6
2020/01/16 00:38:01 BGP: swp4 OPEN has 4-octet AS number capability (65), length 4
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 6
2020/01/16 00:38:01 BGP: swp4 OPEN has AddPath capability (69), length 4
2020/01/16 00:38:01 BGP: swp4 OPEN has AddPath CAP for afi/safi: 1/1, receive
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 14
2020/01/16 00:38:01 BGP: swp4 OPEN has FQDN capability (73), length 12
2020/01/16 00:38:01 BGP: swp4 received hostname dc-spine02, domainname (null)
2020/01/16 00:38:01 BGP: swp4 rcvd OPEN w/ optional parameter type 2 (Capability) len 4
2020/01/16 00:38:01 BGP: swp4 OPEN has Graceful Restart capability (64), length 2
2020/01/16 00:38:01 BGP: swp4 OPEN has Graceful Restart capability
2020/01/16 00:38:01 BGP: swp4 Peer has not restarted. Restart Time : 120
2020/01/16 00:38:01 BGP: %NOTIFICATION: sent to neighbor swp4 6/7 (Cease/Connection collision resolution) 0 bytes
2020/01/16 00:38:01 BGP: [EC 33554451] bgp_process_packet: BGP OPEN receipt failed for peer: swp4
2020/01/16 00:38:01 BGP: swp4 [FSM] BGP_Stop (OpenSent->Idle), fd 22
2020/01/16 00:38:01 BGP: swp4 [Event] BGP connection closed fd 22
2020/01/16 00:38:01 BGP: swp4 went from OpenSent to Idle
2020/01/16 00:38:01 BGP: swp4 [FSM] Receive_KEEPALIVE_message (OpenConfirm->Established), fd 26
2020/01/16 00:38:01 BGP: swp4: peer transfer 0x4ad697700 fd 26 -> 0x4ad67cd60 fd -1)
2020/01/16 00:38:01 BGP: swp4 went from OpenConfirm to Established
2020/01/16 00:38:01 BGP: %ADJCHANGE: neighbor swp4(dc-spine02) in vrf default Up
2020/01/16 00:38:01 BGP: [Event] Deleting stub connection for peer swp4
2020/01/16 00:38:01 BGP: swp4 went from Idle to Deleted
2020/01/16 00:38:01 BGP: swp4 [FSM] Timer (routeadv timer expire)
2020/01/16 00:38:01 BGP: send End-of-RIB for IPv4 Unicast to swp4
2020/01/16 00:38:01 BGP: send End-of-RIB for IPv4 Unicast to swp3
2020/01/16 00:38:01 BGP: swp4 [FSM] Timer (routeadv timer expire)
2020/01/16 00:38:01 BGP: swp3 [FSM] Timer (routeadv timer expire)
2020/01/16 00:38:01 BGP: rcvd End-of-RIB for IPv4 Unicast from swp3
2020/01/16 00:38:02 BGP: rcvd End-of-RIB for IPv4 Unicast from swp4
2020/01/16 00:38:03 BGP: swp3 [FSM] Timer (keepalive timer expire)
2020/01/16 00:38:04 BGP: swp4 [FSM] Timer (keepalive timer expire)

bestpath

ベストパス計算をデバッグするために使用します。

debug bgpの設定を抜粋すると次のとおりです。

dc-leaf03:~$ sudo cat /etc/frr/frr.conf
!
debug bgp bestpath 10.0.254.1/32 # 特定のIP prefixに関するベストパス計算のデバッグを有効化
log file /var/log/frr/debug.log # デバッグログを/var/log/frr/debug.logに書き出し
!

spine01でMax-MEDを設定した状態で、leaf01 (10.0.254.1/32) 宛の経路のベストパス計算結果のデバッグログを抜粋すると次のとおりです。

dc-leaf03:~$ sudo cat /var/log/frr/debug.log
2020/01/16 00:47:30 BGP: 10.0.254.1/32: Comparing path swp3 flags 0x418 with path swp4 flags 0x410
2020/01/16 00:47:30 BGP: 10.0.254.1/32: path swp3 loses to path swp4 due to MED -2 > 0
2020/01/16 00:47:30 BGP: 10.0.254.1/32: path swp4 is the bestpath from AS -94967296 # 何故かASNの値がうまく表示されませんでした
2020/01/16 00:47:30 BGP: 10.0.254.1/32: path swp4 is the initial bestpath
2020/01/16 00:47:30 BGP: 10.0.254.1/32: After path selection, newbest is path swp4 oldbest was swp3
2020/01/16 00:47:30 BGP: 10.0.254.1/32: path swp4 is the bestpath, add to the multipath list
2020/01/16 00:47:30 BGP: 10.0.254.1/32: Comparing path swp3 flags 0x418 with path swp4 flags 0x490
2020/01/16 00:47:30 BGP: 10.0.254.1/32: path swp3 loses to path swp4 due to MED -2 > 0
2020/01/16 00:47:30 BGP: 10.0.254.1/32: starting mpath update, newbest swp4 num candidates 1 old-mpath-count 0
2020/01/16 00:47:30 BGP: 10.0.254.1/32: comparing candidate swp4 with existing mpath NONE
2020/01/16 00:47:30 BGP: 10.0.254.1/32: New mpath count (incl newbest) 1 mpath-change NO

spine01 (swp3) 経由のパスとspine02 (swp4) 経由のパスのMEDの値を比較して、spine02を経由するパスをベストパスに選出しています。

updates

BGP neighborとの、IP prefixの広報と受信に関する問題をデバッグするために使用します。 デバッグ対象のIP prefixを指定することもできます。

debug bgpの設定を抜粋すると次のとおりです。

dc-leaf03:~$ sudo cat /etc/frr/frr.conf
!
debug bgp updates 10.0.254.1/32 # 特定のIP prefixに関する広報と受信に関するデバッグを有効化
log file /var/log/frr/debug.log # デバッグログを/var/log/frr/debug.logに書き出し
!

leaf03で10.0.254.1/32 (leaf01) に関する広報と受信のログを確認すると、次のとおりでした。

2020/01/16 01:26:47 BGP: swp3 rcvd UPDATE w/ attr: , origin ?, mp_nexthop fe80::20c:29ff:feee:f3ba(fe80::20c:29ff:feee:f3ba)(fe80::20c:29ff:feee:f3ba), metric 4294967294, path 4200000000 4210000001
2020/01/16 01:26:47 BGP: swp3 rcvd 10.0.254.1/32 IPv4 unicast
2020/01/16 01:26:47 BGP: swp4 rcvd UPDATE w/ attr: , origin ?, mp_nexthop fe80::20c:29ff:fede:9b50(fe80::20c:29ff:fede:9b50)(fe80::20c:29ff:fede:9b50), path 4200000000 4210000001
2020/01/16 01:26:47 BGP: swp4 rcvd 10.0.254.1/32 IPv4 unicast
2020/01/16 01:26:47 BGP: u2:s2 send UPDATE w/ attr: , origin ?, mp_nexthop ::(::)(::), path 4200000000 4210000001
2020/01/16 01:26:47 BGP: u2:s2 send MP_REACH for afi/safi 1/1
2020/01/16 01:26:47 BGP: u2:s2 send UPDATE 10.0.254.1/32 IPv4 unicast

Chapter 5まとめ

  • BGPの状態確認にshowコマンドを利用
  • Closネットワークでは、spineがborder leafを介して外部ネットワークに接続
  • BGPノードのメンテナンス時には事前の経路迂回を実施
    • AS_PATH Prepend
    • GRACEFUL_SHUTDOWN Community
    • Max-MED
  • BGPのデバッグにはdebug bgpを利用