4

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?

5 Answers5

5

To configure DHCPv6 on RHEL 7.4 or CentOS 7

  1. Connect to your instance using the instance's public IPv4 address.
  2. Using a text editor of your choice, create a custom file, for example:

    /etc/cloud/cloud.cfg.d/99-custom-networking.cfg

  3. Add the following lines to your file, and save your changes:

    network:
      version: 1
      config:
      - type: physical
        name: eth0
        subnets:
          - type: dhcp6
    
  4. Reboot your instance.

  5. 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

Paul
  • 2,755
  • 6
  • 24
  • 35
Al Pooley
  • 66
  • 1
  • 4
2

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:

#cloud-config
preserve_hostname: false
hostname: centos-01
fqdn: centos-01.example.com
manage_etc_hosts: true
write_files:
  - path: /etc/cloud/cloud.cfg.d/99-custom-networking.cfg
    owner: root:root
    permissions: 0600
    content: |
      network:
        version: 1
        config:
        - type: physical
          name: eth0
          subnets:
            - type: dhcp
            - type: dhcp6
power_state:
  mode: reboot
  delay: now
  message: Rebooting post-config
  timeout: 30
  condition: True

The important parts of this config are the write_files section, which installs the appropriate cloud-init config to enable IPv6, and then power_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:

[centos@centos-01 ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=dhcp
DEVICE=eth0
DHCPV6C=yes
IPV6INIT=yes
IPV6_AUTOCONF=no
ONBOOT=yes
TYPE=Ethernet
USERCTL=no

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.

guzzijason
  • 1,370
  • 7
  • 18
1

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:

NOZEROCONF=yes
DEVTIMEOUT=10

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

and in /etc/sysconfig/network-scripts/ifcfg-eth0:

# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=dhcp
DEVICE=eth0
DHCPV6C=yes
HWADDR=xx:xx:xx:xx:xx:xx
IPV6INIT=yes
ONBOOT=yes
STARTMODE=auto
TYPE=Ethernet
USERCTL=no
luiss
  • 111
  • 1
0

Well I created the following file:

$ cat /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg 
network: {config: disabled}

And edited /etc/sysconfig/network-scripts/ifcfg-eth0 as before, and it all works, but not sure this is the best approach.

0

I finally identified the solution for the issue.

We needed to add external IPv6 address into /etc/sysconfig/network-scripts/ifcfg-eth0 as follows;

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=dhcp
DEVICE=eth0
DHCPV6C=yes
IPV6INIT=yes
IPV6ADDR="xxxx:xxxx:xxxx:xxx:xx:xxx:xx" <--add the external IPv6 here
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
RalfFriedl
  • 3,008
  • 4
  • 12
  • 17