How do I enable IPv6 on Fedora 28 on Amazon EC2

I can't seem to get IPv6 working in Fedora 28 in Amazon EC2 (so using cloud-init and DHCPv6).

It works in RHEL 7 with the configuration described here. Applying the same configuration to Fedora 28 doesn't seem to do anything. In particular, /etc/sysconfig/network does NOT get rewritten to contain NETWORKING_IPV6=yes, nor does /etc/sysconfig/network-scripts/ifcfg-eth0 contain any IPv6 stuff.

My /etc/cloud/cloud.cfg.d/56-custom-networking.cfg contains:

network:
  version: 1
  config:
  - type: physical
    name: eth0
    subnets:
      - type: dhcp
      - type: dhcp6

The generated /etc/sysconfig/network is:

NOZEROCONF=yes
DEVTIMEOUT=10

# Created by cloud-init on instance boot automatically, do not edit.
#
NETWORKING=yes

The generated /etc/sysconfig/network-scripts/ifcfg-eth0 is:

# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=dhcp
DEVICE=eth0
HWADDR=0e:79:0a:22:60:26
ONBOOT=yes
TYPE=Ethernet
USERCTL=no

My ifconfig -a:

[aram@eden ~]$ ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 172.31.35.163  netmask 255.255.240.0  broadcast 172.31.47.255
        inet6 fe80::c79:aff:fe22:6026  prefixlen 64  scopeid 0x20<link>
        ether 0e:79:0a:22:60:26  txqueuelen 1000  (Ethernet)
        RX packets 498  bytes 45355 (44.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 332  bytes 38967 (38.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

OS versions:

[aram@eden ~]$ cat /etc/os-release 
NAME=Fedora
VERSION="28 (Cloud Edition)"
ID=fedora
VERSION_ID=28
PLATFORM_ID="platform:f28"
PRETTY_NAME="Fedora 28 (Cloud Edition)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:fedoraproject:fedora:28"
HOME_URL="https://fedoraproject.org/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=28
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=28
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Cloud Edition"
VARIANT_ID=cloud
[aram@eden ~]$ 

This happens because the current cloud-init version (I tested with 17.1) does not regenerate network settings on every boot. Network settings are only generated on the first instance boot. You can observe this by logging at cloud-init's log files:

$ grep 'network config' /var/log/cloud-init.log

2018-09-18 22:13:26,089 - stages.py[INFO]: Applying network configuration from ds bringup=False: {'version': 1, 'config': [{'type': 'physical', 'name': 'eth0', 'subnets': [{'type': 'dhcp4'}], 'mac_address': '12:64:78:dd:c8:62'}]}
2018-09-18 22:13:29,211 - stages.py[DEBUG]: not a new instance. network config is not applied.
2018-09-26 10:08:08,367 - stages.py[DEBUG]: not a new instance. network config is not applied.
2018-09-26 10:08:11,458 - stages.py[DEBUG]: not a new instance. network config is not applied.
2018-09-26 11:01:12,917 - stages.py[DEBUG]: not a new instance. network config is not applied.
2018-09-26 11:01:16,011 - stages.py[DEBUG]: not a new instance. network config is not applied.
2018-09-26 11:10:38,782 - stages.py[DEBUG]: not a new instance. network config is not applied.
2018-09-26 11:10:41,871 - stages.py[DEBUG]: not a new instance. network config is not applied.
2018-09-26 11:12:10,407 - stages.py[DEBUG]: not a new instance. network config is not applied.
2018-09-26 11:12:13,475 - stages.py[DEBUG]: not a new instance. network config is not applied.

As you can see, network configuration was only applied on the first boot (at that time, the instance didn't have IPV6 yet).

There is an issue asking to make this behaviour configurable: https://bugs.launchpad.net/cloud-init/+bug/1765801


Here are the steps I took to enable IPV6 on an existing instance on Amazon EC2 for Fedora 28 (Cloud Edition):

  1. Add NETWORKING_IPV6=yes to /etc/sysconfig/network
  2. Add DHCPV6C=yes to /etc/sysconfig/network-scripts/ifcfg-eth0
  3. Run sudo systemctl restart network

After those steps, IPV6 is enabled and it also persists between reboots. However, if for some reason the instance is re-created and cloud-init considers that to be first boot again then changes will be lost. However, cloud-init already generates an IPV6 net config out of the box so you should still be fine.