Amazon provides instructions on how to enable IPv6 on RHEL 7 and Centos 7: http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-migrate-ipv6.html#ipv6-dhcpv6-rhel
These instructions work on RHEL 7-7.3 and Centos 7-7.3, but do not work on RHEL 7.4 (and presumably neither on Centos 7.4, when it will become available).
The problem is that the file /etc/sysconfig/network-scripts/ifcfg-eth0
is user-writable on the older versions, but on RHEL 7.4 this file becomes managed by cloud-init instead.
$ sed 1q /etc/sysconfig/network-scripts/ifcfg-eth0
# Created by cloud-init on instance boot automatically, do not edit.
I find it very unexpected that merely upgrading from 7.3 to 7.4 would require such a fundamental change to managing networking. I am not sure if this change is specific to Amazon EC2 or not, I can't find anything in the RHEL 7.4 release notes, so it might be specific to Amazon.
So how are you supposed to enable IPv6 on RHEL 7.4 and Centos 7.4 in the cloud-init model?
To configure DHCPv6 on RHEL 7.4 or CentOS 7
Using a text editor of your choice, create a custom file, for example:
/etc/cloud/cloud.cfg.d/99-custom-networking.cfg
Add the following lines to your file, and save your changes:
Reboot your instance.
Reconnect to your instance and use the ifconfig command to verify that the IPv6 address is configured on the network interface.
Source: https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-migrate-ipv6.html#ipv6-dhcpv6-rhel
I found a good solution to this. I've been using terraform to launch and do initial configuration of my instances using cloud-init user-data, and the following EC2 user-data file works well for me:
The important parts of this config are the
write_files
section, which installs the appropriate cloud-init config to enable IPv6, and thenpower_state
, which triggers an immediate post-config reboot, which then applies the network config changes.After reboot, this is what the network config looks like:
I'm happy with the solution, although I'm not entirely sure why I couldn't simply specify the network config in my user-data directly rather than having to write it to a file and reboot. At any rate, this works and is rather painless.
The cloud-init scripts that setup networking once run once on initial boot. If you can figure out which module sets it up, you can try appending
, always
after its name in the/etc/cloud/cloud.cfg
file and reboot after assigning your EC2 instance an IPv6 address.If you want IPv6 setup correctly in the first place, make sure your subnet is set to auto-assign IPv6 addresses. To do this, right click on your subnet in the list of subnet and select "Modify auto-assign IP settings".
Lastly, when this works, this is what I see in
/etc/sysconfig/network
:and in
/etc/sysconfig/network-scripts/ifcfg-eth0
:Well I created the following file:
And edited
/etc/sysconfig/network-scripts/ifcfg-eth0
as before, and it all works, but not sure this is the best approach.I finally identified the solution for the issue.
We needed to add external IPv6 address into
/etc/sysconfig/network-scripts/ifcfg-eth0
as follows;