doctl Verified current stable Not installed? Security

Doctl / Add Firewall Rule Database

Add Firewall Rule Database

Adds a firewall rule to the specified database for security enforcement.

$
Terminal
doctl d fw a <database_id> --rule <droplet|k8s|ip_addr|tag|app>:<value>

When To Use

Before deploying applications to ensure proper access control.

Pro Tip

Double-check rule specificity; overly broad rules can expose vulnerabilities.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
doctl d fw a <database_id> --rule <droplet|k8s|ip_addr|tag|app>:<value>

Anatomy of Output

Understanding the result

Added Rule: droplet:123456 New Rule Confirmation

Specifies the rule that has been successfully added.

Database ID: 56789 Associated Database

Confirms the database tied to the new rule.

Status: success Operation Outcome

Indicates the successful application of the rule.

Power User Variants

Optimized versions

doctl databases fw append 56789 --rule ip:172.16.0.1

Adds an IP-based firewall rule.

doctl databases fw append 56789 --rule tag:my-cloud-tag

Adds a rule based on a given cloud tag.

Troubleshooting

Common pitfalls

Error: Invalid rule format

Solution: Check the syntax of the rule and re-enter.

Error: Database not found

Solution: Verify that the specified database ID is correct.

Error: Rule already exists

Solution: No changes made; check existing rules.

Command Breakdown

What each part is doing

doctl
Base Command
The executable that performs this operation. Here it runs Doctl before the shell applies any redirect operators.
d
d|databases
The value supplied for d|databases.
fw
fw|firewalls
The value supplied for fw|firewalls.
a
a|append
The value supplied for a|append.
<database_id>
database id
The value supplied for database id.
<droplet|k8s|ip_addr|tag|app>
droplet|k8s|ip addr|tag|app
The value supplied for droplet|k8s|ip addr|tag|app.
<value>
value
The value supplied for value.
--rule
Command Option
Tool-specific option used by this command invocation.

Alternative Approaches

Comparable commands in other tools

Alternative security tools for the same job.