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

Aperta Adatta ai principianti
#7,253 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@aayushostwal ci sta già lavorando.

Dal 1/12/2026.

  • #7287 di @aayushostwal — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
aws, linux, python
Ambito
cloud, networking

Direzione di ricerca

Inizia in cloudinit/net/netops/iproute2.py, dove vengono assemblati i due comandi route-append mostrati nel log, e confrontali con l'output fallito di ip -4 route append ... via ... dev ens5. Il testo dell'issue indica anche cloudinit/net/ephemeral.py come il chiamante che si arrende dopo il fallimento del comando di route IPv4, quindi leggi quel flusso prima di modificare gli argomenti di route. Fatto significa che entrambi i percorsi di costruzione delle route includono il comportamento onlink previsto e che la rete effimera può essere esercitata su una configurazione EC2 IPv6-only o sulla sua copertura unitaria più vicina.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
Python
Stelle
3.9k
Fork
1.2k
Merge medio
2g 24m
PR unite (30g)
18

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di canonical/cloud-init

Tutte le issue di canonical/cloud-init

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.