2

I've bought a Public Cloud VPS from OVH and trying to set up ipv6. Also I've found a tutorial on how to set up ipv6 in their documentation. It works until I reboot the VPS.

In this tutorial they want me to update this file /etc/sysconfig/network-scripts/ifcfg-eth0 but inside that file it says "Created by cloud-init on instance boot automatically, do not edit". I've also tried to contact OVH's support, but they responded that they can't help me with that and suggested to ask here.

Can somebody help me with this? I've never worked with cloud-init and don't even know where is a config that generates ifcfg-eth0.

OS: Centos7

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
kironet
  • 121
  • 1
  • 6

3 Answers3

1

In my specific case, my router leases IPv6 addresses to my VMs running in my server (in premisses) via DHCP and so... I don't need to hardcode or generate any IP configuration. I just need to inform a DNS server about the dynamically generated addresses.

The snippet below (from my cloud-config script) creates /etc/sysctl.conf so that it enables IPv6 on a VM running Centos7. It also creates a shell script which updates the current IPv6 address onto FreeDNS every 15mins, requiring the FQDN and a DDNS key which can be obtained when you setup a AAAA record marked as dynamic.

local fqdn="vm.example.com"
local ddnspasswd='obtain-ddns-key-at-dns.he.net'
cat > user-data <<EOF
    # configure IPv6
    write_files:
      - content: |
            net.ipv6.conf.all.disable_ipv6 = 0
            net.ipv6.conf.default.disable_ipv6 = 0
        path: /etc/sysctl.conf
        owner: root:root
        permissions: 0600
      - content: |
            #!/bin/bash

            function ddns_update_ipv4 {
              local fqdn="${fqdn}"
              local ddnspasswd="${ddnspasswd}"

              /usr/bin/curl -4 "https://dyn.dns.he.net/nic/update" -d "hostname=\${fqdn}" -d "password=\${ddnspasswd}" >> /dev/null 2>&1
              local STATUS=\$?

              if [[ \$STATUS -ne 0 ]]; then
                    echo "IPv4 DNS update failed, return code: \$STATUS" >> /var/log/ddns.log
                    return 1
              fi

              return 0
            }

            function ddns_update_ipv6 {
              local fqdn="${fqdn}"
              local ddnspasswd="${ddnspasswd}"

              /usr/bin/curl -6 "https://dyn.dns.he.net/nic/update" -d "hostname=\${fqdn}" -d "password=\${ddnspasswd}" >> /dev/null 2>&1
              local STATUS=\$?

              if [[ \$STATUS -ne 0 ]]; then
                    echo "IPv6 DNS update failed, return code: \$STATUS" >> /var/log/ddns.log
                    return 1
              fi

              return 0
            }


            ddns_update_ipv6
        path: /sbin/ddns-update
        owner: root:root
        permissions: 0500

    # Update IPv6 on FreeDNS (http://dns.he.net/) every 15 mins
    runcmd:
      - systemctl stop network && systemctl start network
      - echo "0,15,30,45 * * * * /sbin/ddns-update" | tee -a /etc/crontab
      - crontab -u root /etc/crontab
EOF
0

The answer to this, is not in OVH's guide however, the following works:

In /etc/cloud/cloud.cfg.d/99-custom-networking.cfg: add

network:
    version: 2
    ethernets:
        eth0:
            dhcp: true
            dhcp6: false
            match:
              name: eth0
            addresses:
              - "ADDRESS"
            gateway6: "GATEWAY"

Make sure you set your gateway, then reboot and reload the config using sudo cloud-init clean -r

Tom B
  • 175
  • 1
  • 1
  • 6
0

Please see my answer here for passing EC2 user-data to simply enable IPv6 when launching an instance:

How do I enable IPv6 in RHEL 7.4 on Amazon EC2

guzzijason
  • 1,370
  • 7
  • 18