Fails to setup IPv4 ephemeral network on IPv6-only EC2 instance

オープン 初心者向け
#7,253 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@aayushostwal がすでに取り組んでいます。

2026年12月1日 から。

  • #7287 @aayushostwal による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
aws, linux, python
領域
cloud, networking

調査の方向性

cloudinit/net/netops/iproute2.py から始めます。ここではログに表示される 2 つの route-append コマンドが組み立てられているので、失敗している ip -4 route append ... via ... dev ens5 の出力と比較してください。issue のテキストは、IPv4 ルートコマンドの失敗後に諦める呼び出し元として cloudinit/net/ephemeral.py も指しているため、ルート引数を変更する前にそのフローを読んでください。完了条件は、両方のルート構築パスが意図した onlink 動作を含み、IPv6-only の EC2 セットアップまたはその最も近いユニットカバレッジで ephemeral networking を実行できることです。

索引モデルが issue の本文から書いたものです。

説明

bug new

Bug report

Current cloud-init blocks on IPv6-only EC2 instances during the init-local run. It tries to setup both IPv4 and IPv6 ephemeral networks, where IPv4 ultimately fails and IPv6 does not work correctly.

The IPv4 ephemeral setup fails while setting up routes. It calls ip route without the "onlink" flag and without any reachable gateway:

ip -4 route append 169.254.169.253/32 via 169.254.0.1 dev ens5

The IPv6 ephemeral setup does not work correctly, as it can only makes sure link-local is available. However the EC2 metadata service is not reachable via IPv6 link-local, but via a well known (and not properly assigned) ULA address. To reach this address, the network setup would need to use DHCPv6 as well.

As both variants fail in different ways, init-local can not reach any metadata service and retries for four minutes.

Fix:

diff --git a/cloudinit/net/netops/iproute2.py b/cloudinit/net/netops/iproute2.py
index e40e5dc9..263ff890 100644
--- a/cloudinit/net/netops/iproute2.py
+++ b/cloudinit/net/netops/iproute2.py
@@ -55,6 +55,7 @@ class Iproute2(NetOps):
                 *gateway_args,
                 "dev",
                 interface,
+                "onlink",
                 *source_args,
             ]
         )
@@ -74,6 +75,7 @@ class Iproute2(NetOps):
                 *gateway_args,
                 "dev",
                 interface,
+                "onlink",
             ]
         )

Steps to reproduce the problem

  • Run EC2 instance on IPv6-only EC2 subnet
  • cloud-init will block four minutes during init-local stage

Environment details

  • Cloud-init version: 26.2
  • Operating System Distribution: Debian 13, Debian 14, Ubuntu 26.04
  • Cloud provider, platform or installer type: EC2

cloud-init logs

2026-11-20 11:10:36,128 - ephemeral.py[DEBUG]: Received dhcp lease on ens5 for 169.254.163.67/255.255.255.255
2026-11-20 11:10:36,128 - ephemeral.py[DEBUG]: Attempting setup of ephemeral network on ens5 with 169.254.163.67/32 brd 0.0.0.0
2026-11-20 11:10:36,129 - subp.py[DEBUG]: Running command ['ip', '--json', 'addr'] with allowed return codes [0] (shell=False, capture=True)
2026-11-20 11:10:36,131 - ephemeral.py[DEBUG]: Skip adding ip address: ens5 already has address 169.254.163.67
2026-11-20 11:10:36,131 - ephemeral.py[DEBUG]: Skip bringing up network link: interface ens5 is already up
2026-11-20 11:10:36,131 - subp.py[DEBUG]: Running command ['ip', '-4', 'route', 'append', '169.254.169.253/32', 'via', '169.254.0.1', 'dev', 'ens5'] with allowed return codes [0] (shell=False, capture=True)
2026-11-20 11:10:36,133 - subp.py[DEBUG]: Running command ['ip', '-family', 'inet', 'link', 'set', 'dev', 'ens5', 'down'] with allowed return codes [0] (shell=False, capture=True)
2026-11-20 11:10:36,136 - subp.py[DEBUG]: Running command ['ip', '-family', 'inet', 'addr', 'del', '169.254.163.67/32', 'dev', 'ens5'] with allowed return codes [0] (shell=False, capture=True)
2026-11-20 11:10:36,137 - ephemeral.py[DEBUG]: Failed to bring up ens5 for ephemeral ipv4 networking.
主要言語
Python
スター
3.9k
フォーク
1.2k
平均マージ
2日 24分
マージ済み PR(30日)
18

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

canonical/cloud-init のほかの issue

canonical/cloud-init の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。