How to Disable IPv4 and Only Use IPv6

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.

When you enable IPv6 on a Droplet, both the IPv4 and IPv6 interfaces are available. You can disable IPv4 and rely solely on IPv6, although you will still need to have IPv4 available for the localhost so your programs operate as expected.

DigitalOcean blocks all SMTP traffic over IPv6. If you disable IPv4 on a Droplet that hosts a mail server, mail delivery will stop.

Disable IPv4 on Boot

To disable IPv4, you need to modify the file that configures your network at boot. The file you edit and what you change in it depends on which distribution your Droplet is running.

On Ubuntu 18.04, you need to edit /etc/netplan/50-cloud-init.yaml.

If you enabled IPv6 when the Droplet was created, remove the IPv4 address and gateway4 lines. If you enabled IPv6 after creation, you need to add the IPv6 address and gateway6 lines. In both cases, add the IPv6 name servers as well.

When you’re done, the file should look like this:

    version: 2
            - public_ipv6_address/64
            - anchor_ip
            gateway6: public_ipv6_gateway
                macaddress: droplet_mac_address
                - 2001:4860:4860::8844
                - 2001:4860:4860::8888
                search: []
            set-name: eth0


On Debian 9 and Ubuntu 16.04, you need to edit /etc/network/interfaces.d/50-cloud-init.cfg. On Ubuntu 14.04, you need to edit /etc/network/interfaces.

If you enable IPv6 when you created your Droplet, you’ll see two sections beginning with iface eth0, and maybe more if you also enabled private networking. In this case, you should delete or comment out the inet section for eth0 so that only the inet6 section is defined for eth0.

If you enabled IPv6 after creation, you won’t see the iface eth0 inet6 static section. In this case, you should delete or comment out the inet section for eth0 and add in the inet6 section as below.

When you’re done, the file should look like this:

iface eth0 inet6 static
    address public_ipv6_address
    netmask 64
    gateway public_ipv6_gateway
    autoconf 0
    dns-nameservers 2001:4860:4860::8844 2001:4860:4860::8888

# iface eth0 inet static
#    . . .


On CentOS and Fedora, you need to edit /etc/sysconfig/network.

If it isn’t already there, add NETWORKING_IPV6=yes on a new line to enable IPv6:



Next, edit /etc/sysconfig/network-scripts/ifcfg-eth0, which specifies how the network should be configured when it is brought up.

Comment out the IPv4 information so that it isn’t taken into account at boot by adding a # at the beginning of those lines:



If you enabled IPv6 after the Droplet was created, you need to add your IPv6 information (IPV6ADDR=... and IPV6_DEFAULTGW=...) and adjust the DNS directives (DNS1=...) so they point to IPv6 name servers:

. . .


These steps will disable IPv4 at next boot. You can also disable IPv4 immediately.

Disable IPv4 Immediately

To disable IPv4 immediately, you need to delete the rule that configures your IPv4 address.

If you enabled IPv6 after you created your Droplet, you first need to edit the /etc/resolv.conf file to use IPv6 DNS servers. Set the nameserver directives to Google’s IPv6 name servers by changing the file to look like this:

nameserver 2001:4860:4860::8844
nameserver 2001:4860:4860::8888


After the Droplet is set to use IPv6 name servers, find its IPv4 address and CIDR routing prefix.

ip -4 addr show eth0

This is the information after inet, which is in this example:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet brd scope global eth0
If you are connecting to the Droplet through an IPv4 connection, disabling the IPv4 interface will drop your connection. You will need to reconnect using IPv6 (if your local configuration supports it) or log in using the control panel.

To disable IPv4 immediately, remove the rule configuring your IPv4 address, using the Droplet’s IP address and CIDR routing prefix:

ip addr del dev eth0

Unless you disable IPv4 on boot, these changes will be reverted the next time you reboot.