はじめに
GMOコネクトの永田です。
前回の記事を投稿したところ、暗号のおねえさん から「一般的なご家庭なら経路冗長化するよね!」と素敵なコメントがありました。
確かに、お家では経路の冗長化は必須ですね!ということで、今回はBGPの冗長構成について試してみます。
Primary PathとBackup Pathを用意しておき、Primary Pathに障害が発生した際に自動的にBackup Pathに切り替わる、そんな構成を実現してみます。
containerlabを使えば、複雑な冗長構成も簡単に構築・検証できます!
なお、前回の記事の構成を元にしていますので、必要に応じて参照してください。
まとめ
- containerlabとFRRoutingで、BGPの冗長構成を簡単に実現可能
- Primary PathとBackup Pathの自動切り替えが正しく動作することを確認
- BGPのBest Path選択アルゴリズムにより、Primary Pathが優先的に選択される
- 障害発生時は自動的にBackup Pathにフェイルオーバー、復旧時は自動的にPrimary Pathに戻る
試したtopology
今回は、srcとdstの間に2つの経路を用意します。
- Primary Path: r1 ↔ r3 ↔ r2
- Backup Path: r1 ↔ r4 ↔ r2
それぞれのルーターが異なるAS(Autonomous System)に所属し、AS間でBGPを使って経路情報を交換します。
ルーター構成詳細
ルーター | インターフェース | IPアドレス | BGP Neighbor | AS番号 | 役割 |
---|---|---|---|---|---|
r1 | eth1 | 192.168.1.1/24 | - | AS65001 | Edge Router (Source side) |
eth2 | 192.168.13.1/24 | 192.168.13.2 (r3) | |||
eth3 | 192.168.14.1/24 | 192.168.14.2 (r4) | |||
lo | 10.10.10.1/32 | - | |||
r2 | eth1 | 192.168.2.1/24 | - | AS65002 | Edge Router (Destination side) |
eth2 | 192.168.23.1/24 | 192.168.23.2 (r3) | |||
eth3 | 192.168.24.1/24 | 192.168.24.2 (r4) | |||
lo | 10.10.10.2/32 | - | |||
r3 | eth1 | 192.168.13.2/24 | 192.168.13.1 (r1) | AS65003 | Transit Router (Primary path) |
eth2 | 192.168.23.2/24 | 192.168.23.1 (r2) | |||
lo | 10.10.10.3/32 | - | |||
r4 | eth1 | 192.168.14.2/24 | 192.168.14.1 (r1) | AS65004 | Transit Router (Backup path) |
eth2 | 192.168.24.2/24 | 192.168.24.1 (r2) | |||
lo | 10.10.10.4/32 | - |
Advertised Networks
- r1: 192.168.1.0/24(srcが所属するネットワーク)
- r2: 192.168.2.0/24(dstが所属するネットワーク)
- r3: Transit only(ローカルネットワークのアドバタイズなし)
- r4: Transit only(ローカルネットワークのアドバタイズなし)
topology設定
では早速containerlabでtopologyを組んでいきます。
clab yml
name: clab-bgp-backup-topo
topology:
nodes:
r1:
kind: linux
image: quay.io/frrouting/frr:10.4.1
binds:
- r1/daemons:/etc/frr/daemons
- r1/frr.conf:/etc/frr/frr.conf
- r1/vtysh.conf:/etc/frr/vtysh.conf
r2:
kind: linux
image: quay.io/frrouting/frr:10.4.1
binds:
- r2/daemons:/etc/frr/daemons
- r2/frr.conf:/etc/frr/frr.conf
- r2/vtysh.conf:/etc/frr/vtysh.conf
r3:
kind: linux
image: quay.io/frrouting/frr:10.4.1
binds:
- r3/daemons:/etc/frr/daemons
- r3/frr.conf:/etc/frr/frr.conf
- r3/vtysh.conf:/etc/frr/vtysh.conf
r4:
kind: linux
image: quay.io/frrouting/frr:10.4.1
binds:
- r4/daemons:/etc/frr/daemons
- r4/frr.conf:/etc/frr/frr.conf
- r4/vtysh.conf:/etc/frr/vtysh.conf
src:
kind: linux
image: praqma/network-multitool:latest
exec:
- "ip link set eth1 up"
- "ip addr add 192.168.1.11/24 dev eth1"
- "ip route add 192.168.0.0/16 via 192.168.1.1 dev eth1"
dst:
kind: linux
image: praqma/network-multitool:latest
exec:
- "ip link set eth1 up"
- "ip addr add 192.168.2.11/24 dev eth1"
- "ip route add 192.168.0.0/16 via 192.168.2.1 dev eth1"
links:
# for bgp peering
- endpoints: [r1:eth2, r3:eth1]
- endpoints: [r1:eth3, r4:eth1]
- endpoints: [r2:eth2, r3:eth2]
- endpoints: [r2:eth3, r4:eth2]
# for host connectivity
- endpoints: [src:eth1, r1:eth1]
- endpoints: [dst:eth1, r2:eth1]
前回の記事と比較すると、以下の点が追加されています:
- r3とr4の2つのTransit Routerを追加
- r1とr2がそれぞれr3とr4の両方とBGPピアリング
- これにより、Primary PathとBackup Pathの2つの経路が確立
FRRouting Config
daemons(r1/r2/r3/r4とも同じ)
前回の記事と同じ設定です。bgpd=yes
を設定してBGPを有効化します。
zebra=yes
bgpd=yes
ospfd=yes
ospf6d=no
ripd=no
ripngd=no
isisd=no
pimd=no
ldpd=yes
nhrpd=no
eigrpd=no
babeld=no
sharpd=no
staticd=no
pbrd=no
bfdd=no
fabricd=no
vtysh_enable=yes
zebra_options=" -s 90000000 --daemon -A 127.0.0.1"
bgpd_options=" --daemon -A 127.0.0.1"
ospfd_options=" --daemon -A 127.0.0.1"
# (以下省略)
vtysh.conf(r1/r2/r3/r4とも同じ)
こちらも前回の記事と同じです。
service integrated-vtysh-config
frr.conf(r1)
frr version 10.4.1_git
frr defaults traditional
hostname router1
no ipv6 forwarding
!
# I/F settings
interface eth1
ip address 192.168.1.1/24
!
interface eth2
ip address 192.168.13.1/24
!
interface eth3
ip address 192.168.14.1/24
!
interface lo
ip address 10.10.10.1/32
!
# AS-PATH filter for outbound (own routes only)
bgp as-path access-list OWN-ROUTES permit ^$
!
route-map BGP-OUT permit 10
match as-path OWN-ROUTES
exit
!
# AS-PATH filter for inbound (allow routes from r3 and r4)
bgp as-path access-list IN-ROUTES permit 65003
bgp as-path access-list IN-ROUTES permit 65004
!
route-map BGP-IN permit 10
match as-path IN-ROUTES
exit
!
# BGP Configuration for Router1(AS65001)
router bgp 65001
neighbor 192.168.13.2 remote-as 65003
neighbor 192.168.14.2 remote-as 65004
!
address-family ipv4 unicast
network 192.168.1.0/24
neighbor 192.168.13.2 soft-reconfiguration inbound
neighbor 192.168.13.2 route-map BGP-OUT out
neighbor 192.168.13.2 route-map BGP-IN in
neighbor 192.168.14.2 soft-reconfiguration inbound
neighbor 192.168.14.2 route-map BGP-OUT out
neighbor 192.168.14.2 route-map BGP-IN in
exit-address-family
exit
!
line vty
!
r1の設定のポイント
前回の記事との主な違いは以下の点です:
- eth3の追加: r4へのインターフェースを追加
- BGP neighborの追加: r3(192.168.13.2, AS65003)とr4(192.168.14.2, AS65004)の2つのneighborを設定
- IN-ROUTESの変更: r3とr4の両方からのルートを許可
r1は、r3とr4の両方から192.168.2.0/24への経路情報を受信します。この時、BGPのBest Path選択アルゴリズムにより、Router IDが小さいr3(10.10.10.3)の経路がPrimary Pathとして選択されます。
frr.conf(r2)
frr version 10.4.1_git
frr defaults traditional
hostname router2
no ipv6 forwarding
!
# I/F settings
interface eth1
ip address 192.168.2.1/24
!
interface eth2
ip address 192.168.23.1/24
!
interface eth3
ip address 192.168.24.1/24
!
interface lo
ip address 10.10.10.2/32
!
# AS-PATH filter for outbound (own routes only)
bgp as-path access-list OWN-ROUTES permit ^$
!
route-map BGP-OUT permit 10
match as-path OWN-ROUTES
exit
!
# AS-PATH filter for inbound (allow routes from r3 and r4)
bgp as-path access-list IN-ROUTES permit 65003
bgp as-path access-list IN-ROUTES permit 65004
!
route-map BGP-IN permit 10
match as-path IN-ROUTES
exit
!
# BGP Configuration for Router2(AS65002)
router bgp 65002
neighbor 192.168.23.2 remote-as 65003
neighbor 192.168.24.2 remote-as 65004
!
address-family ipv4 unicast
network 192.168.2.0/24
neighbor 192.168.23.2 soft-reconfiguration inbound
neighbor 192.168.23.2 route-map BGP-OUT out
neighbor 192.168.23.2 route-map BGP-IN in
neighbor 192.168.24.2 soft-reconfiguration inbound
neighbor 192.168.24.2 route-map BGP-OUT out
neighbor 192.168.24.2 route-map BGP-IN in
exit-address-family
exit
!
line vty
!
r2の設定も同様の考え方で、r3とr4の両方とBGPピアリングします。
frr.conf(r3)
frr version 10.4.1_git
frr defaults traditional
hostname router3
no ipv6 forwarding
!
# I/F settings
interface eth1
ip address 192.168.13.2/24
!
interface eth2
ip address 192.168.23.2/24
!
interface lo
ip address 10.10.10.3/32
!
# AS-PATH filter for outbound (transit routes from neighbors)
bgp as-path access-list OUT-ROUTES permit 65001
bgp as-path access-list OUT-ROUTES permit 65002
!
route-map BGP-OUT permit 10
match as-path OUT-ROUTES
exit
!
# AS-PATH filter for inbound (allow routes from r1 and r2)
bgp as-path access-list IN-ROUTES permit 65001
bgp as-path access-list IN-ROUTES permit 65002
!
route-map BGP-IN permit 10
match as-path IN-ROUTES
exit
!
# BGP Configuration for Router3(AS65003) - Primary Transit
router bgp 65003
neighbor 192.168.13.1 remote-as 65001
neighbor 192.168.23.1 remote-as 65002
!
address-family ipv4 unicast
neighbor 192.168.13.1 soft-reconfiguration inbound
neighbor 192.168.13.1 route-map BGP-OUT out
neighbor 192.168.13.1 route-map BGP-IN in
neighbor 192.168.23.1 soft-reconfiguration inbound
neighbor 192.168.23.1 route-map BGP-OUT out
neighbor 192.168.23.1 route-map BGP-IN in
exit-address-family
exit
!
line vty
!
r3の設定のポイント
r3はTransit Routerとして動作します。つまり、自身が起点となるネットワークはアドバタイズせず、r1とr2間の経路情報を中継します。
- network設定なし: 自身のネットワークをアドバタイズしない
- OUT-ROUTESの設定: r1(AS65001)とr2(AS65002)からのルートのみを転送許可
- これにより、r1から受信した192.168.1.0/24をr2に、r2から受信した192.168.2.0/24をr1に転送
frr.conf(r4)
frr version 10.4.1_git
frr defaults traditional
hostname router4
no ipv6 forwarding
!
# I/F settings
interface eth1
ip address 192.168.14.2/24
!
interface eth2
ip address 192.168.24.2/24
!
interface lo
ip address 10.10.10.4/32
!
# AS-PATH filter for outbound (transit routes from neighbors)
bgp as-path access-list OUT-ROUTES permit 65001
bgp as-path access-list OUT-ROUTES permit 65002
!
route-map BGP-OUT permit 10
match as-path OUT-ROUTES
exit
!
# AS-PATH filter for inbound (allow routes from r1 and r2)
bgp as-path access-list IN-ROUTES permit 65001
bgp as-path access-list IN-ROUTES permit 65002
!
route-map BGP-IN permit 10
match as-path IN-ROUTES
exit
!
# BGP Configuration for Router4(AS65004) - Backup Transit
router bgp 65004
neighbor 192.168.14.1 remote-as 65001
neighbor 192.168.24.1 remote-as 65002
!
address-family ipv4 unicast
neighbor 192.168.14.1 soft-reconfiguration inbound
neighbor 192.168.14.1 route-map BGP-OUT out
neighbor 192.168.14.1 route-map BGP-IN in
neighbor 192.168.24.1 soft-reconfiguration inbound
neighbor 192.168.24.1 route-map BGP-OUT out
neighbor 192.168.24.1 route-map BGP-IN in
exit-address-family
exit
!
line vty
!
r4の設定もr3と同様に、Transit Routerとして動作します。
動かしてみた
topologyの起動
containerlabで起動します。
❯ sudo containerlab deploy -t bgp-backup-topo.clab.yml
09:26:13 INFO Containerlab started version=0.71.0
09:26:13 INFO Parsing & checking topology file=bgp-backup-topo.clab.yml
09:26:14 INFO Creating lab directory path=clab-bgp-backup-topo/clab-clab-bgp-backup-topo
09:26:14 INFO Creating container name=src
09:26:14 INFO Creating container name=r2
09:26:14 INFO Creating container name=r3
09:26:14 INFO Creating container name=dst
09:26:14 INFO Creating container name=r1
09:26:14 INFO Creating container name=r4
09:26:14 INFO Created link: r1:eth2 ▪┄┄▪ r3:eth1
09:26:14 INFO Created link: r2:eth2 ▪┄┄▪ r3:eth2
09:26:14 INFO Created link: r1:eth3 ▪┄┄▪ r4:eth1
09:26:14 INFO Created link: r2:eth3 ▪┄┄▪ r4:eth2
09:26:14 INFO Created link: dst:eth1 ▪┄┄▪ r2:eth1
09:26:14 INFO Created link: src:eth1 ▪┄┄▪ r1:eth1
09:26:14 INFO Executed command node=src command="ip link set eth1 up" stdout=""
09:26:14 INFO Executed command node=src command="ip addr add 192.168.1.11/24 dev eth1" stdout=""
09:26:14 INFO Executed command node=src command="ip route add 192.168.0.0/16 via 192.168.1.1 dev eth1" stdout=""
09:26:14 INFO Executed command node=dst command="ip link set eth1 up" stdout=""
09:26:14 INFO Executed command node=dst command="ip addr add 192.168.2.11/24 dev eth1" stdout=""
09:26:14 INFO Executed command node=dst command="ip route add 192.168.0.0/16 via 192.168.2.1 dev eth1" stdout=""
09:26:14 INFO Adding host entries path=/etc/hosts
09:26:14 INFO Adding SSH config for nodes path=/etc/ssh/ssh_config.d/clab-clab-bgp-backup-topo.conf
You are on the latest version (0.71.0)
╭───────────────────────────────┬─────────────────────────────────┬─────────┬───────────────────╮
│ Name │ Kind/Image │ State │ IPv4/6 Address │
├───────────────────────────────┼─────────────────────────────────┼─────────┼───────────────────┤
│ clab-clab-bgp-backup-topo-dst │ linux │ running │ 172.20.20.7 │
│ │ praqma/network-multitool:latest │ │ 3fff:172:20:20::7 │
├───────────────────────────────┼─────────────────────────────────┼─────────┼───────────────────┤
│ clab-clab-bgp-backup-topo-r1 │ linux │ running │ 172.20.20.9 │
│ │ quay.io/frrouting/frr:10.4.1 │ │ 3fff:172:20:20::9 │
├───────────────────────────────┼─────────────────────────────────┼─────────┼───────────────────┤
│ clab-clab-bgp-backup-topo-r2 │ linux │ running │ 172.20.20.11 │
│ │ quay.io/frrouting/frr:10.4.1 │ │ 3fff:172:20:20::b │
├───────────────────────────────┼─────────────────────────────────┼─────────┼───────────────────┤
│ clab-clab-bgp-backup-topo-r3 │ linux │ running │ 172.20.20.10 │
│ │ quay.io/frrouting/frr:10.4.1 │ │ 3fff:172:20:20::a │
├───────────────────────────────┼─────────────────────────────────┼─────────┼───────────────────┤
│ clab-clab-bgp-backup-topo-r4 │ linux │ running │ 172.20.20.8 │
│ │ quay.io/frrouting/frr:10.4.1 │ │ 3fff:172:20:20::8 │
├───────────────────────────────┼─────────────────────────────────┼─────────┼───────────────────┤
│ clab-clab-bgp-backup-topo-src │ linux │ running │ 172.20.20.6 │
│ │ praqma/network-multitool:latest │ │ 3fff:172:20:20::6 │
╰───────────────────────────────┴─────────────────────────────────┴─────────┴───────────────────╯
r1のBGPおよびrouting tableの確認
早速、r1のBGP状態を確認します。
❯ docker exec clab-clab-bgp-backup-topo-r1 vtysh -c "show bgp summary"
IPv4 Unicast Summary:
BGP router identifier 10.10.10.1, local AS number 65001 VRF default vrf-id 0
BGP table version 2
RIB entries 3, using 384 bytes of memory
Peers 2, using 33 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
192.168.13.2 4 65003 52 52 2 0 0 00:48:33 1 1 N/A
192.168.14.2 4 65004 53 54 2 0 0 00:48:33 1 1 N/A
Total number of neighbors 2
期待通りですね!r3とr4の両方とBGPセッションが確立され、それぞれから1つの経路情報(192.168.2.0/24)を受信しています。
r3(Primary Path)からの経路情報
r1# show ip bgp nei 192.168.13.2 received-routes
BGP table version is 2, local router ID is 10.10.10.1, vrf id 0
Default local pref 100, local AS 65001
Status codes: s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 192.168.2.0/24 192.168.13.2 0 65003 65002 i
Total number of prefixes 1
AS_PATHは 65003 → 65002
となっており、r3経由でr2に到達することを示しています。
r4(Backup Path)からの経路情報
r1# show ip bgp nei 192.168.14.2 received-routes
BGP table version is 2, local router ID is 10.10.10.1, vrf id 0
Default local pref 100, local AS 65001
Status codes: s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 192.168.2.0/24 192.168.14.2 0 65004 65002 i
Total number of prefixes 1
AS_PATHは 65004 → 65002
となっており、r4経由でr2に到達することを示しています。
BGP Best Path選択の確認
では、2つの経路のうちどちらが選択されているかを確認します。
r1# show ip bgp 192.168.2.0/24
BGP routing table entry for 192.168.2.0/24, version 2
Paths: (2 available, best #1, table default)
Not advertised to any peer
65003 65002
192.168.13.2 from 192.168.13.2 (10.10.10.3)
Origin IGP, valid, external, best (Router ID)
Last update: Fri Oct 17 08:07:15 2025
65004 65002
192.168.14.2 from 192.168.14.2 (10.10.10.4)
Origin IGP, valid, external
Last update: Fri Oct 17 08:07:15 2025
重要なポイント:
-
Paths: (2 available, best #1, table default)
: 2つの経路が利用可能で、1番目がBest Pathとして選択 - r3経由のパスが
best (Router ID)
として選択されている - 選択理由は Router ID(10.10.10.3 < 10.10.10.4)
BGPのBest Path選択アルゴリズムでは、他の条件が同じ場合、Router IDが小さい方が優先されます。r3のRouter ID(10.10.10.3)がr4(10.10.10.4)より小さいため、r3経由のPrimary Pathが選択されました。
BGPの経路選択の詳細については、JPNICのBGPの基礎知識 - 経路の優先順位を参照してください。
r1のルーティングテーブル
r1# show ip route
Codes: K - kernel route, C - connected, L - local, S - static,
R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric, t - Table-Direct,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
IPv4 unicast VRF default:
K>* 0.0.0.0/0 [0/0] via 172.20.20.1, eth0, weight 1, 01:10:54
L * 10.10.10.1/32 is directly connected, lo, weight 1, 01:10:54
C>* 10.10.10.1/32 is directly connected, lo, weight 1, 01:10:54
C>* 172.20.20.0/24 is directly connected, eth0, weight 1, 01:10:54
L>* 172.20.20.10/32 is directly connected, eth0, weight 1, 01:10:54
C>* 192.168.1.0/24 is directly connected, eth1, weight 1, 01:10:53
L>* 192.168.1.1/32 is directly connected, eth1, weight 1, 01:10:53
B>* 192.168.2.0/24 [20/0] via 192.168.13.2, eth2, weight 1, 01:10:48
C>* 192.168.13.0/24 is directly connected, eth2, weight 1, 01:10:54
L>* 192.168.13.1/32 is directly connected, eth2, weight 1, 01:10:54
C>* 192.168.14.0/24 is directly connected, eth3, weight 1, 01:10:54
L>* 192.168.14.1/32 is directly connected, eth3, weight 1, 01:10:54
B>* 192.168.2.0/24 [20/0] via 192.168.13.2, eth2
により、192.168.2.0/24へはeth2(r3経由)を使用することが確認できます。期待通りPrimary Pathが使われています!
Primary Pathの動作確認
実際にsrcからdstへ通信して、Primary Pathが使われていることを確認します。
❯ docker exec clab-clab-bgp-backup-topo-src traceroute -n 192.168.2.11
traceroute to 192.168.2.11 (192.168.2.11), 30 hops max, 46 byte packets
1 192.168.1.1 0.010 ms 0.001 ms 0.001 ms
2 192.168.13.2 0.002 ms 0.001 ms 0.001 ms
3 192.168.23.1 0.000 ms 0.001 ms 0.001 ms
4 192.168.2.11 0.000 ms 0.000 ms 0.001 ms
完璧です!tracerouteの結果から、以下の経路で通信していることが確認できます:
- src → r1(192.168.1.1)
- r1 → r3(192.168.13.2)← Primary Path!
- r3 → r2(192.168.23.1)
- r2 → dst(192.168.2.11)
topology図通りの経路になっています!😊
Primary Path障害時のフェイルオーバー確認
次に、Primary Path(r3)を一時停止して、Backup Path(r4)に自動的に切り替わることを確認します。
ここではdocker stop
ではなくdocker pause
を使用します。docker stop
でコンテナを停止すると、再起動時にネットワークインターフェースの状態が初期化されてしまいますが、docker pause
を使えばプロセスを一時停止するだけなので、docker unpause
で復旧した際にネットワークインターフェースの状態が維持されます。これにより、containerlabの再デプロイが不要になります。
❯ docker pause clab-clab-bgp-backup-topo-r3
clab-clab-bgp-backup-topo-r3
r3を一時停止後、BGPのhold timer(デフォルトで180秒)が経過するまで待ってからr1のBGP状態を確認します。
❯ docker exec clab-clab-bgp-backup-topo-r1 vtysh -c "show bgp summary"
IPv4 Unicast Summary:
BGP router identifier 10.10.10.1, local AS number 65001 VRF default vrf-id 0
BGP table version 3
RIB entries 3, using 384 bytes of memory
Peers 2, using 33 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
192.168.13.2 4 65003 186 190 0 0 0 00:00:26 OpenSent 0 N/A
192.168.14.2 4 65004 189 189 3 0 0 03:05:26 1 1 N/A
Total number of neighbors 2
r3へのBGPセッションが OpenSent状態(接続試行中)になり、r4からのみ経路情報を受信しています。docker pause
により、r3のプロセスが完全に停止しているため、BGPセッションも切断されました。
Backup Pathへの切り替え確認
❯ docker exec clab-clab-bgp-backup-topo-r1 vtysh -c "show ip bgp 192.168.2.0/24"
BGP routing table entry for 192.168.2.0/24, version 3
Paths: (1 available, best #1, table default)
Not advertised to any peer
65004 65002
192.168.14.2 from 192.168.14.2 (10.10.10.4)
Origin IGP, valid, external, best (First path received)
Last update: Fri Oct 17 08:07:16 2025
r3経由のパスが利用不可となり、r4経由のパスが自動的にBest Pathとして選択されました!
tracerouteでBackup Pathを確認
❯ docker exec clab-clab-bgp-backup-topo-src traceroute -n 192.168.2.11
traceroute to 192.168.2.11 (192.168.2.11), 30 hops max, 46 byte packets
1 192.168.1.1 0.003 ms 0.000 ms 0.000 ms
2 192.168.14.2 0.001 ms 0.000 ms 0.001 ms
3 192.168.24.1 0.001 ms 0.001 ms 0.001 ms
4 192.168.2.11 0.000 ms 0.000 ms 0.000 ms
期待通り、経路が自動的にBackup Pathに切り替わりました:
- src → r1(192.168.1.1)
- r1 → r4(192.168.14.2)← Backup Pathに切り替わった!
- r4 → r2(192.168.24.1)
- r2 → dst(192.168.2.11)
通信は継続しており、無停止でフェイルオーバーが完了しています!🎉
Primary Path復旧時のフェイルバック確認
最後に、r3を再開してPrimary Pathに戻ることを確認します。
❯ docker unpause clab-clab-bgp-backup-topo-r3
clab-clab-bgp-backup-topo-r3
docker unpause
でr3のプロセスを再開します。docker stop/start
と異なり、ネットワークインターフェースの状態が維持されているため、FRRoutingの設定もそのまま保持されています。
BGPが収束するのを待ち、さらに手動でBGPセッションをリセットしてルート選択を再評価させます。
❯ docker exec clab-clab-bgp-backup-topo-r1 vtysh -c "clear ip bgp *"
注意: docker unpause
後、BGPは自動的に再接続しますが、"Oldest Path"の選択基準により、先に確立されたr4経由のパスが優先される場合があります。そのため、clear ip bgp *
で手動リセットを行い、Router IDによる正しい選択(r3を優先)を促します。
❯ docker exec clab-clab-bgp-backup-topo-r1 vtysh -c "show ip bgp 192.168.2.0/24"
BGP routing table entry for 192.168.2.0/24, version 5
Paths: (2 available, best #1, table default)
Not advertised to any peer
65003 65002
192.168.13.2 from 192.168.13.2 (10.10.10.3)
Origin IGP, valid, external, best (Router ID)
Last update: Fri Oct 17 12:40:14 2025
65004 65002
192.168.14.2 from 192.168.14.2 (10.10.10.4)
Origin IGP, valid, external
Last update: Fri Oct 17 12:40:14 2025
2つの経路が再び利用可能になり、BGPセッションのリセット後、r3経由のPrimary Pathが再びBest Pathとして選択されました!
❯ docker exec clab-clab-bgp-backup-topo-src traceroute -n 192.168.2.11
traceroute to 192.168.2.11 (192.168.2.11), 30 hops max, 46 byte packets
1 192.168.1.1 0.002 ms 0.001 ms 0.001 ms
2 192.168.13.2 0.001 ms 0.001 ms 0.000 ms
3 192.168.23.1 0.001 ms 0.001 ms 0.001 ms
4 192.168.2.11 0.001 ms 0.000 ms 0.000 ms
完璧です!Primary Path(r3経由)に自動的に戻りました!😊
検証結果のまとめ
containerlabとFRRoutingを使って、BGPの冗長構成を実現し、以下のことを確認できました:
- Primary PathとBackup Pathの設定: 2つの異なるAS経由の経路を設定
- BGP Best Path選択: Router IDに基づいてPrimary Pathが優先的に選択される
- 自動フェイルオーバー: Primary Path障害時に自動的にBackup Pathに切り替わる
- 自動フェイルバック: Primary Path復旧時に自動的に元の経路に戻る
- 無停止での切り替え: 経路切り替え中も通信が継続される
実際のネットワーク環境では、このような冗長構成が非常に重要です。containerlabを使えば、こうした複雑な構成も簡単に検証できます。
(再掲)まとめ
- containerlabとFRRoutingで、BGPの冗長構成を簡単に実現可能
- Primary PathとBackup Pathの自動切り替えが正しく動作することを確認
- BGPのBest Path選択アルゴリズムにより、Primary Pathが優先的に選択される
- 障害発生時は自動的にBackup Pathにフェイルオーバー、復旧時は自動的にPrimary Pathに戻る
最後に、GMOコネクトでは研究開発や国際標準化に関する支援や技術検証をはじめ、幅広い支援を行っておりますので、何かありましたらお気軽にお問合せください。