How to Reassign or Unassign Reserved IPs

A DigitalOcean Reserved IP address is a publicly-accessible static IP address that you can assign to a Droplet and then reassign to another Droplet later, as needed. You can implement a failover mechanism with reserved IPs to build a high availability infrastructure.


You can reassign a reserved IP to point it at a different Droplet. You can also unassign it from a Droplet entirely.

Note
Assigned reserved IP addresses are free, but unassigned reserved IP addresses are not. Learn more about reserved IP pricing.

Reassign a Reserved IP Using Automation

How to reassign a reserved IP using the DigitalOcean CLI

To reassign a reserved IP 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, reassign a reserved IP with doctl compute reserved-ip-action assign. The basic usage looks like this, but you'll want to read the usage docs for more details:

                  doctl compute reserved-ip-action assign <reserved-ip> <droplet-id> [flags]
                

    The following example assigns the reserved IP address 203.0.113.25 to a Droplet with the ID 386734086

                   doctl compute reserved-ip-action assign 203.0.113.25 386734086
                
How to reassign a reserved IP using the DigitalOcean API

To reassign a reserved IP 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/reserved_ips/{reserved_ip}/actions

    cURL

    To reassign a reserved IP with cURL, call:

    
                    # Assign a Reserved IP to a Droplet
    curl -X POST \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      -d '{"type":"assign","droplet_id":8219222}' \
      "https://api.digitalocean.com/v2/reserved_ips/45.55.96.47/actions"
    
    # Unassign a Reserved IP
    # curl -X POST \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      -d '{"type":"unassign"}' \
      "https://api.digitalocean.com/v2/reserved_ips/45.55.96.47/actions"

    Go

    Go developers can use Godo, the official DigitalOcean V2 API client for Go. To reassign a reserved IP 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()
    
      // Assign a Reserved IP to a Droplet
        action, _, err := client.ReservedIPActions.Assign(ctx, "45.55.96.47", 8219222)
    
      // Unassign a Reserved IP
      // action, _, err := client.ReservedIPActions.Unassign(ctx, "45.55.96.47")  
    }

    Ruby

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

    
                    require 'droplet_kit'
    token = ENV['DIGITALOCEAN_TOKEN']
    client = DropletKit::Client.new(access_token: token)
    
    # Assign a Reserved IP to a Droplet
    client.reserved_ip_actions.assign(ip: '45.55.96.47', droplet_id: 8219222)
    
    # Unassign a Reserved IP
    # client.reserved_ip_actions.unassign(ip: '45.55.96.47')

    Python

    
                    import os
    from pydo import Client
    
    client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
    
    req={
      "type": "unassign"
    }
    
    resp = client.reserved_ips_actions.post(reserved_ip="49.32.13.21", body=req)

Reassign a Reserved IP Using the Control Panel

To reassign or unassign a reserved IP from the control panel, click Networking in the main navigation, then click Reserved IPs.

This page lists your reserved IPs and their assigned Droplets. Open the More menu of the reserved IP you want to reassign or unassign:

Assigned reserved IP with More menu open

From the More menu, click Unassign to unassign the reserved IP entirely, or click Reassign and pick a new Droplet in the Search for a Droplet text box that opens. You can only reassign reserved IPs to Droplets in the same datacenter.