How to Destroy Firewalls

DigitalOcean Cloud Firewalls are a network-based, stateful firewall service for Droplets provided at no additional cost. Cloud firewalls block all traffic that isn’t expressly permitted by a rule.


Destroy a Firewall Using the CLI

The destroy command requires the firewall’s ID to be destroyed. To retrieve a list of firewalls and their IDs, use the doctl compute firewall list command.

How to Destroy a Firewall Using the DigitalOcean CLI
  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, run doctl compute firewall delete. Basic usage looks like this, but you can read the usage docs for more details:

                doctl compute firewall delete <firewall-id>... [flags]
              

    The following example deletes a cloud firewall with the ID f81d4fae-7dec-11d0-a765-00a0c91e6bf6:

                  doctl compute firewall delete f81d4fae-7dec-11d0-a765-00a0c91e6bf6
                

Destroy a Firewall Using the API

The destroy call requires the firewall’s ID to be destroyed. To retrieve a list of firewalls and their IDs, use the /v2/firewalls firewalls endpoint.

How to Destroy a Firewall Using the DigitalOcean API
  1. Create a personal access token and save it for use with the API.

  2. Send a DELETE request to https://api.digitalocean.com/v2/firewalls/{firewall_id}

    cURL

    Using cURL:

                    curl -X DELETE \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      "https://api.digitalocean.com/v2/firewalls/bb4b2611-3d72-467b-8602-280330ecd65c"
                  

    Go

    Using Godo, the official DigitalOcean V2 API client for Go:

                    import (
        "context"
        "os"
    
        "github.com/digitalocean/godo"
    )
    
    func main() {
        token := os.Getenv("DIGITALOCEAN_TOKEN")
    
        client := godo.NewFromToken(token)
        ctx := context.TODO()
    
        _, err := client.Firewalls.Delete(ctx, 'bb4b2611-3d72-467b-8602-280330ecd65c')
    }
                  

    Ruby

    Using DropletKit, the official DigitalOcean V2 API client for Ruby:

                    require 'droplet_kit'
    token = ENV['DIGITALOCEAN_TOKEN']
    client = DropletKit::Client.new(access_token: token)
    
    client.firewalls.delete(id: 'bb4b2611-3d72-467b-8602-280330ecd65c')
                  

    Python

                    import os
    from pydo import Client
    
    client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
    
    resp = client.firewalls.delete(firewall_id= "as9di9d")
                  

Destroy a Firewall Using the Control Panel

To destroy a firewall, from the Networking section of the control panel, click the Firewalls tab. Open the More menu of the firewall you want to destroy and click Destroy.

Firewall with more menu open and Destroy option visible

In the Destroy Firewall window that opens, click Confirm to destroy the firewall. Destroying a firewall does not destroy the Droplets that were associated with it.