3

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?

4

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

  • Those instructions do not work. – Aram Hăvărneanu Aug 31 '18 at 22:11
  • Oh yes they do, but it's NOT eth0. In my case it's ens5. I wonder if that is stable... – Aram Hăvărneanu Aug 31 '18 at 22:25
  • If you want to maintain your IPv4 connectivity make sure to include both: - type: dhcp - type: dhcp6 – MerlinTheMagic Oct 23 '18 at 11:44
1

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.