How to Enable IPv6 on Droplets

IP addresses let machines communicate across a network. DigitalOcean Droplets are assigned IPv4 addresses by default. Enabling IPv6 on a Droplet gives you access to its 16 additional IPv6 addresses.


You can enable IPv6 on a Droplet when you create it or after you create it.

Enabling IPv6 during Droplet creation automatically configures the Droplet’s network interfaces. We recommend this option because it’s faster and avoids manual configuration errors.

You can still enable IPv6 on an existing Droplet by manually configuring its network interface.

Enable IPv6 During Droplet Creation Using the CLI

You can enable IPv6 on Droplets during creation by setting the --enable-ipv6 flag to true when using the doctl compute droplet create command.

How to create a Droplet using the DigitalOcean CLI

To create a Droplet via the command-line, follow these steps:

  1. Install doctl, the DigitalOcean command-line tool.

  2. Create a personal access token, and save it for use with doctl.

  3. Use the token to grant doctl access to your DigitalOcean account.

                  doctl auth init
                
  4. Finally, create a Droplet with doctl compute droplet create. The basic usage looks like this, but you'll want to read the usage docs for more details:

                  doctl compute droplet create <droplet-name>... [flags]
                

Enable IPv6 During Droplet Creation Using the API

You can enable IPv6 on Droplets during creation by setting the ipv6 field to true when using the Droplet creation call.

How to create a Droplet using the DigitalOcean API

To create a Droplet using the DigitalOcean API, follow these steps:

  1. Create a personal access token, and save it for use with the API.

  2. Send a POST request to https://api.digitalocean.com/v2/droplets

    cURL

    To create a Droplet with cURL, call:

    
                    curl -X POST \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      -d '{"name":"example.com","region":"nyc3","size":"s-1vcpu-1gb","image":"ubuntu-20-04-x64","ssh_keys":[289794,"3b:16:e4:bf:8b:00:8b:b8:59:8c:a9:d3:f0:19:fa:45"],"backups":true,"ipv6":true,"monitoring":true,"tags":["env:prod","web"],"user_data":"#cloud-config\nruncmd:\n  - touch /test.txt\n","vpc_uuid":"760e09ef-dc84-11e8-981e-3cfdfeaae000"}' \
      "https://api.digitalocean.com/v2/droplets"

    Go

    Go developers can use Godo, the official DigitalOcean V2 API client for Go. To create a Droplet with Godo, use the following code:

    
                    import (
        "context"
        "os"
    
        "github.com/digitalocean/godo"
    )
    
    func main() {
        token := os.Getenv("DIGITALOCEAN_TOKEN")
    
        client := godo.NewFromToken(token)
        ctx := context.TODO()
    
        createRequest := &godo.DropletCreateRequest{
            Name:   "example.com",
            Region: "nyc3",
            Size:   "s-1vcpu-1gb",
            Image: godo.DropletCreateImage{
                Slug: "ubuntu-20-04-x64",
            },
            SSHKeys: []godo.DropletCreateSSHKey{
                godo.DropletCreateSSHKey{ID: 289794},
                godo.DropletCreateSSHKey{Fingerprint: "3b:16:e4:bf:8b:00:8b:b8:59:8c:a9:d3:f0:19:fa:45"}
            },
            Backups: true,
            IPv6: true,
            Monitoring: true,
            Tags: []string{"env:prod","web"},
            UserData: "#cloud-config\nruncmd:\n  - touch /test.txt\n",
            VPCUUID: "760e09ef-dc84-11e8-981e-3cfdfeaae000",
        }

    Ruby

    Ruby developers can use DropletKit, the official DigitalOcean V2 API client for Ruby. To create a Droplet with DropletKit, use the following code:

    
                    require 'droplet_kit'
    token = ENV['DIGITALOCEAN_TOKEN']
    client = DropletKit::Client.new(access_token: token)
    
    droplet = DropletKit::Droplet.new(
      name: 'example.com',
      region: 'nyc3',
      size: 's-1vcpu-1gb',
      image: 'ubuntu-20-04-x64',
      ssh_keys: [289794,"3b:16:e4:bf:8b:00:8b:b8:59:8c:a9:d3:f0:19:fa:45"],
      backups: true,
      ipv6: true,
      monitoring: true,
      tags: ["env:prod","web"],
      user_data: "#cloud-config\nruncmd:\n  - touch /test.txt\n",
      vpc_uuid: "760e09ef-dc84-11e8-981e-3cfdfeaae000",
    )
    client.droplets.create(droplet)

    Python

    
                    import os
    from pydo import Client
    
    client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
    
    req = {
      "name": "example.com",
      "region": "nyc3",
      "size": "s-1vcpu-1gb",
      "image": "ubuntu-20-04-x64",
      "ssh_keys": [
        289794,
        "3b:16:e4:bf:8b:00:8b:b8:59:8c:a9:d3:f0:19:fa:45"
      ],
      "backups": True,
      "ipv6": True,
      "monitoring": True,
      "tags": [
        "env:prod",
        "web"
      ],
      "user_data": "#cloud-config\nruncmd:\n  - touch /test.txt\n",
      "vpc_uuid": "760e09ef-dc84-11e8-981e-3cfdfeaae000"
    }
    
    resp = client.droplets.create(body=req)

Enable IPv6 During Droplet Creation Using the Control Panel

To create a Droplet with IPv6 enabled, open the Create menu from your DigitalOcean Control Panel and select Droplets.

The create menu

On the Create Droplet page, in the Advanced Options section, check the box next to Enable IPv6.

The advanced options section of the Droplet creation page, which includes the Enable IPv6 checkbox.

When you’ve selected all of your options, click the Create Droplet button at the bottom.

Once you’ve created the Droplet, the header displays the Droplet’s IPv6 address. To view more IPv6 information, including the public IPv6 address, gateway address, and configurable address range, click the Droplet’s name, then click Networking in the side navigation.

At this point, your new IPv6 address is ready for use.

Enable IPv6 on Existing Droplets

You need to power down your Droplet to enable IPv6. To safely do this, log into your Droplet and use the shutdown command with the -h flag, which instructs the system to shut down and then halt:

sudo shutdown -h now

Once the Droplet is off, the next step is to enable IPv6 from the control panel. This assigns IPv6 address information to the Droplet that you need to configure the Droplet’s network interface.

On the Droplets page, click the name of the Droplet, then click Networking in the side navigation. In the Public Network section, click Enable. This assigns an IPv6 address to the Droplet.

The Droplet Networking page with the IPv6 enable button highlighted

Once enabled, click the OFF button to switch the Droplet back ON. The page will automatically update with the IPv6 network information.

Powering on the Droplet by clicking the On/Off switch in the control panel

When you enable IPv6 on an existing Droplet, you need to manually configure the IPv6 network interface on the Droplet itself. This involves adding information to the Droplet’s network configuration file, including the Droplet’s static IPv6 address, gateway address, IPv6 name servers, and disabling its automatic network configuration.

Click on Console to access your Droplet directly. The file you edit and the way you add information depends on which Linux distribution your Droplet is running.

On Ubuntu 22.04 and Ubuntu 21.10, open the /etc/netplan/50-cloud-init.yaml configuration file in a text editor and make the following changes:

  • In the eth0 stanza, under addresses:, add the Droplet’s IPv6 address on a new line followed by the netmask value, /64.

  • In the nameservers stanza, add two lines for IPv6 name servers, 2001:4860:4860::8844 and 2001:4860:4860::8888.

  • In the eth0 stanza, under routes, add two new gateway connection stanzas as seen in the following example, substituting the gateway address from the Droplet’s IPv6 networking page.

The file looks like this when you’re done:

    
        
            
network:
    version: 2
    ethernets:
        eth0:
            addresses:
            - 164.92.68.109/20
            - 10.48.0.9/16
            - substitute_your_primary_ipv6_address/64
            match:
                macaddress: 86:4d:f9:5e:7b:d2
            mtu: 1500
            nameservers:
                addresses:
                - 67.207.67.2
                - 67.207.67.3
                - 2001:4860:4860::8844
                - 2001:4860:4860::8888
                search: []
            routes:
            -   to: 0.0.0.0/0
                via: 164.92.64.1
            -   to: substitute_your_ipv6_gateway
                scope: link
            -   to: default
                via: substitute_your_ipv6_gateway
                on-link: true
            set-name: eth0

        
    

To locate your Droplet’s IPv6 address and gateway address in the control panel, click Droplets, then click the Droplet’s name from the list. From the Droplet’s page, click Networking in the side navigation. The Public Network section lists your Droplet’s IPv6 information.

Once you’ve edited and saved the file, run the following command to check the configuration’s syntax and temporarily apply the network changes:

sudo netplan apply --debug

On Ubuntu 18.04 and 20.04, open the /etc/netplan/50-cloud-init.yaml configuration file in a text editor and make the following changes:

  • In the eth0 stanza, under addresses:, add the Droplet’s IPv6 address on a new line followed by the netmask value, /64.

  • In the etho0 stanza, on a new line, add gateway6 and the gateway address from the Droplet’s IPv6 networking page.

  • In the nameservers stanza, add two lines for IPv6 name servers, 2001:4860:4860::8844 and 2001:4860:4860::8888.

The file looks like this when you’re done:

    
        
            
network:
    version: 2
    ethernets:
        eth0:
            addresses:
            - substitute_your_primary_ipv6_address/64
            - 203.0.113.213/20
            - 192.0.2.11/16
        gateway4: 206.189.208.1
        gateway6: substitute_your_ipv6_gateway
        match:
            macaddress: 5e:5x:5a:2m:8p:le
        nameservers:
            addresses:
                - 67.207.67.2
                - 67.207.67.3
                - 2001:4860:4860::8844
                - 2001:4860:4860::8888
                search: []
        set-name: eth0

        
    

To locate your Droplet’s IPv6 address and gateway address in the control panel, click Droplets, then click the Droplet’s name from the list. From the Droplet’s page, click Networking in the side navigation. The Public Network section lists your Droplet’s IPv6 information.

Once you’ve edited and saved the file, run the following command to check the configuration’s syntax and temporarily apply the network changes:

sudo netplan apply --debug

If you receive the error Cannot call Open vSwitch: ovsdb-server.service is not running., you need to install the openvswitch-switch-dpdk package on the Droplet. Open vSwitch is a virtual switch licensed under the open source Apache 2.0 license. It helps more efficiently forward packets via the kernel space data path. Run sudo apt-get install openvswitch-switch-dpdk to install the package and then run netplan apply again.

On Debian and Ubuntu 14.04, open the /etc/network/interfaces configuration file in a text editor.

Add the entire stanza below, substituting the address variable for your Droplet’s IPv6 address, and the gateway variable for your Droplet’s gateway address:

    
        
            
iface eth0 inet6 static
    address substitute_your_primary_ipv6_address
    netmask 64
    gateway substitue_your_ipv6_gateway
    autoconf 0
    dns-nameservers 2001:4860:4860::8844 2001:4860:4860::8888 209.244.0.3

        
    

Once you’ve edited and saved the file, run the following command to check the configuration’s syntax and temporarily apply the network changes:

sudo systemctl restart networking

On FreeBSD, open the /etc/network/interfaces configuration file in a text editor.

Add the entire stanza below, substituting the address variable for your Droplet’s IPv6 address, and the gateway variable for your Droplet’s gateway address:

    
        
            
iface eth0 inet6 static
    address substitute_your_primary_ipv6_address
    netmask 64
    gateway substitue_your_ipv6_gateway
    autoconf 0
    dns-nameservers 2001:4860:4860::8844 2001:4860:4860::8888 209.244.0.3

        
    
Warning
If your configuration file has syntax errors, it may disrupt connectivity or lock you out of your Droplet. Please ensure your configuration file is correct before proceeding. Currently, you can only access FreeBSD via ssh. However, when enabling IPv6 via ssh, you cannot reset network or routing to verify your syntax without terminating your connection to the Droplet.

On Fedora, use the Network Manager’s CLI to add the new IPv6 route to the Droplet’s network configuration.

To do this, first add the Droplet’s IPv6 address, followed by its /64 netmask value, to the eht0 interface:

nmcli connection modify "cloud-init eth0" ipv6.address <your-ipv6-address>/64

Then add the Droplet’s IPv6 gateway address to the configuration:

nmcli connection modify "cloud-init eth0" ipv6.gateway <your-gateway-address>

Lastly, add DigitalOcean’s DNS servers to the configuration:

nmcli connection modify "cloud-init eth0" ipv6.dns "2001:4860:4860::8844 2001:4860:4860::8888"

Once you have added all of the Droplet’s IPv6 information into the network configuration, restart the eth0 interface.

nmcli connection up "cloud-init eth0"

On CentOS 8/9 and Rocky Linux, open the /etc/sysconfig/network-scripts/ifcfg-eth0 configuration file in a text editor.

Add the following block, substituting the IPV6ADDR variable for your Droplet’s IPv6 address, and the IPV6_DEFAULTGW variable for your Droplet’s gateway address.

    
        
            
IPV6INIT=yes
IPV6ADDR=primary_ipv6_address/64
IPV6_DEFAULTGW=ipv6_gateway
IPV6_AUTOCONF=no
DNS1=2001:4860:4860::8844
DNS2=2001:4860:4860::8888
DNS3=209.244.0.3

        
    

To locate your Droplet’s IPv6 address and gateway address in the control panel, click Droplets, then click the Droplet’s name from the list. From the Droplet’s page, click Networking in the menu on the left. The Public Network section lists your Droplet’s IPv6 information.

Once you’ve edited and saved the file, run the following command to check the configuration’s syntax and temporarily apply the network changes:

sudo systemctl restart NetworkManager.service

On CentOS 7, open the /etc/sysconfig/network-scripts/ifcfg-eth0 configuration file in a text editor.

Add the following block, substituting the IPV6ADDR variable for your Droplet’s IPv6 address, and the IPV6_DEFAULTGW variable for your Droplet’s gateway address.

    
        
            
IPV6INIT=yes
IPV6ADDR=primary_ipv6_address/64
IPV6_DEFAULTGW=ipv6_gateway
IPV6_AUTOCONF=no
DNS1=2001:4860:4860::8844
DNS2=2001:4860:4860::8888
DNS3=209.244.0.3

        
    

To locate your Droplet’s IPv6 address and gateway address in the control panel, click Droplets, then click the Droplet’s name from the list. From the Droplet’s page, click Networking in the menu on the left. The Public Network section lists your Droplet’s IPv6 information.

Once you’ve edited and saved the file, run the following command to check the configuration’s syntax and temporarily apply the network changes:

sudo systemctl restart network

The verification will print any errors in the syntax on the screen. When the syntax is correct, the command will return you to the command prompt with no output.

Finally, reboot the server to apply the changes.

reboot

If you become locked out of your Droplet, you can access your Droplet from the Recovery Console to repair the file.

Verify the Configuration

Note

To use IPv6, both ends of the connection must be configured to send and receive IPv6 traffic. Not all ISPs offer IPv6 addresses for customers, so you may not be able to connect to an IPv6 address directly from your local machine. For example, if your local machine does not have an IPv6 address, you will not be able to connect to your Droplet using its IPv6 address.

You can locate your public IPv6 address using test-ipv6.com.

To test the IPv6 configuration, try pinging the Google IPv6 name server from the Droplet:

ping6 2001:4860:4860::8888

If IPv6 is working correctly, you’ll receive output like this, which means the Droplet can communicate across the internet with other IPv6-enabled sites and servers.

PING 2001:4860:4860::8888(2001:4860:4860::8888) 56 data bytes
64 bytes from 2001:4860:4860::8888: icmp_seq=1 ttl=57 time=3.16 ms
64 bytes from 2001:4860:4860::8888: icmp_seq=2 ttl=57 time=2.79 ms
64 bytes from 2001:4860:4860::8888: icmp_seq=3 ttl=57 time=2.85 ms
64 bytes from 2001:4860:4860::8888: icmp_seq=4 ttl=57 time=2.83 ms
64 bytes from 2001:4860:4860::8888: icmp_seq=5 ttl=57 time=2.88 ms
Copy
To exit, press q.

If you receive the output ping: sendmsg: Network is unreachable, verify that you used ping6 and not ping. If you still can’t connect, check the changes you made to the configuration file for errors, then reboot and test again.