Comment 4 for bug 1657940

Revision history for this message
Scott Moser (smoser) wrote :

ami-6b6f4b0e ubuntu/images-testing-dev/hvm-ssd/ubuntu-xenial-16.04-testing-amd64-server-20170307
ami-6a6f4b0f ubuntu/images-testing/hvm-ssd/ubuntu-yakkety-daily-amd64-server-20170307

I launched an instance in an EC2 region (us-east-2) into a subnet with configured ipv6.

$ rel=$(lsb_release -sc)
$ line=$(awk '$1 == "deb" && $2 ~ /ubuntu.com/ { printf("%s %s %s-proposed main universe\n", $1, $2, rel); exit(0) }; ' "rel=$rel" /etc/apt/sources.list)
$ echo "$line" | sudo tee /etc/apt/sources.list.d/proposed.list
$ sudo apt-get update -q && sudo apt-get install cloud-init -qy
$ dpkg-query --show cloud-init
cloud-init 0.7.9-48-g1c795b9-0ubuntu1~16.04.1

## just show the network info to show the ipv6 section.
$ python3 -c 'from cloudinit import ec2_utils; print(ec2_utils.get_instance_metadata()["network"])'
{'interfaces': {'macs': {'02:30:58:a7:f4:7f': {'vpc-id': 'vpc-87e72bee', 'security-group-ids': 'sg-5a61d333', 'subnet-ipv6-cidr-blocks': '2600:1f16:aeb:b20a::/64', 'vpc-ipv4-cidr-block': '172.31.0.0/16', 'device-number': '0', 'owner-id': '950047163771', 'subnet-ipv4-cidr-block': '172.31.0.0/20', 'vpc-ipv6-cidr-blocks': '2600:1f16:aeb:b200::/56', 'interface-id': 'eni-fa814292', 'local-hostname': 'ip-172-31-6-189.us-east-2.compute.internal', 'public-ipv4s': '52.14.171.177', 'ipv6s': '2600:1f16:aeb:b20a:ab2:9fda:425c:b9e7', 'vpc-ipv4-cidr-blocks': '172.31.0.0/16', 'mac': '02:30:58:a7:f4:7f', 'security-groups': 'wide-open', 'ipv4-associations': {'52.14.171.177': '172.31.6.189'}, 'local-ipv4s': '172.31.6.189', 'subnet-id': 'subnet-cdf821a4', 'public-hostname': 'ec2-52-14-171-177.us-east-2.compute.amazonaws.com'}}}}

I then set default networking for cloud-init to attempt both ipv4 and ipv6.

$ ADDR=$(cat /sys/class/net/eth0/address)
$ sudo tee /etc/cloud/cloud.cfg.d/99-network-config.cfg <<EOF
network:
 version: 1
 config:
  - type: physical
    name: eth0
    mac_address: $ADDR
    subnets:
     - type: dhcp
     - type: dhcp6
EOF

Then, clean the instance, and reboot.

$ sudo rm -Rf /var/log/cloud-init /var/lib/cloud
$ sudo reboot

## When you go back in, look /etc/network/interfaces.d/50-cloud-init.cfg
## and verify it has an ipv6 address and a dhclient6 running.
$ grep -v "^[#]." /etc/network/interfaces.d/50-cloud-init.cfg | grep .
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
iface eth0 inet6 dhcp

$ ip address show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 02:30:58:a7:f4:7f brd ff:ff:ff:ff:ff:ff
    inet 172.31.6.189/20 brd 172.31.15.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 2600:1f16:aeb:b20a:ab2:9fda:425c:b9e7/128 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::30:58ff:fea7:f47f/64 scope link
       valid_lft forever preferred_lft forever

$ ps axw | grep [d]hclient
  888 ? Ss 0:00 /sbin/dhclient -1 -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases -I -df /var/lib/dhcp/dhclient6.eth0.leases eth0
 1052 ? Ss 0:00 /sbin/dhclient -1 -6 -pf /run/dhclient6.eth0.pid -lf /var/lib/dhcp/dhclient6.eth0.leases -I -df /var/lib/dhcp/dhclient.eth0.leases eth0