Vps

Firewall

Configure firewall rules and policies to secure your virtual machines.

Firewall

Configure firewall rules and policies to secure your virtual machines.

Get Firewall Configuration

GET /projects/{project}/products/{product}/vps/firewall

Retrieve the complete firewall configuration including policies, rules, and network interfaces.

Path Parameters

NameTypeDescription
projectstringUnique project identifier
productstringUnique product/VM identifier

Headers

NameTypeDescription
AuthorizationstringBearer token for authentication
PermissionstringREAD_FIREWALL

Response

200 - Success

{
  "enabled": true,
  "policy_in": "ACCEPT", 
  "policy_out": "ACCEPT",
  "rules": [
    {
      "pos": 0,
      "comment": "SSH Access",
      "type": "in",
      "enabled": true,
      "protocol": "tcp",
      "source": "0.0.0.0/0",
      "interface": "net0", 
      "action": "ACCEPT",
      "destionation": null,
      "ipVersion": null,
      "dport": "22",
      "sport": null
    }
  ],
  "interfaces": [
    {
      "name": "net0",
      "vlan": "111",
      "ips": ["192.121.119.100", "2001:67c:bec:b::100/128"]
    }
  ]
}

Update Firewall Policies

POST /projects/{project}/products/{product}/vps/firewall

Update the default firewall policies for incoming and outgoing traffic.

⚠️ Important: Changing the default policy to DROP or REJECT without proper rules may lock you out of your VM. Ensure you have appropriate access rules before applying restrictive policies.

Path Parameters

NameTypeDescription
projectstringUnique project identifier
productstringUnique product/VM identifier

Headers

NameTypeDescription
AuthorizationstringBearer token for authentication
PermissionstringWRITE_FIREWALL

Request Body

NameTypeDescription
policy_instringDefault policy for incoming traffic (ACCEPT, DROP, REJECT)
policy_outstringDefault policy for outgoing traffic (ACCEPT, DROP, REJECT)

Policy Options:

  • ACCEPT - Allow all traffic by default
  • DROP - Silently drop unmatched traffic
  • REJECT - Reject unmatched traffic with error response

Example Request:

{
  "policy_in": "DROP",
  "policy_out": "ACCEPT"
}

Response

200 - Success

{
  "success": true
}

Add Firewall Rule

POST /projects/{project}/products/{product}/vps/firewall/rules

Add a new firewall rule to control network traffic.

Path Parameters

NameTypeDescription
projectstringUnique project identifier
productstringUnique product/VM identifier

Headers

NameTypeDescription
AuthorizationstringBearer token for authentication
PermissionstringWRITE_FIREWALL

Request Body

NameTypeDescription
posnumberRule position in the firewall list
commentstringOptional. Description of the rule
typestringTraffic direction (in, out)
enabledbooleanWhether the rule is active
protocolstringNetwork protocol (tcp, udp, icmp, etc.)
sourcestringOptional. Source IP address or range
interfacestringNetwork interface name
actionstringAction to take (ACCEPT, DROP, REJECT)
destionationstringOptional. Destination IP address or range
dportstringOptional. Destination port(s)
sportstringOptional. Source port(s)

Common Protocols:

  • tcp - TCP traffic
  • udp - UDP traffic
  • icmp - ICMP traffic (ping, etc.)

Example Request (Web Traffic):

{
  "pos": 1,
  "comment": "Web Traffic",
  "type": "in",
  "enabled": true,
  "protocol": "tcp",
  "source": "0.0.0.0/0",
  "interface": "net0",
  "action": "ACCEPT",
  "dport": "80,443"
}

Example Request (SSH from Specific IP):

{
  "pos": 0,
  "comment": "SSH Access from Office",
  "type": "in",
  "enabled": true,
  "protocol": "tcp",
  "source": "203.0.113.0/24",
  "interface": "net0",
  "action": "ACCEPT",
  "dport": "22"
}

Response

200 - Success

{
  "success": true
}

Update Firewall Rule

PUT /projects/{project}/products/{product}/vps/firewall/rules/{pos}

Update an existing firewall rule.

Path Parameters

NameTypeDescription
projectstringUnique project identifier
productstringUnique product/VM identifier
posnumberRule position to update

Headers

NameTypeDescription
AuthorizationstringBearer token for authentication
PermissionstringWRITE_FIREWALL

Request Body

Use the same request body format as Add Firewall Rule.

Response

200 - Success

{
  "success": true
}

Delete Firewall Rule

DELETE /projects/{project}/products/{product}/vps/firewall/rules/{pos}

Remove a firewall rule.

Path Parameters

NameTypeDescription
projectstringUnique project identifier
productstringUnique product/VM identifier
posnumberRule position to delete

Headers

NameTypeDescription
AuthorizationstringBearer token for authentication
PermissionstringWRITE_FIREWALL

Response

200 - Success

{
  "success": true
}

Firewall Best Practices

🔒 Security Recommendations

  1. Start Restrictive: Begin with a DROP default policy and explicitly allow only required traffic
  2. Limit SSH Access: Restrict SSH access to specific IP ranges when possible
  3. Use Comments: Always add descriptive comments to your firewall rules
  4. Regular Reviews: Periodically review and remove unused rules

📝 Common Rule Examples

Allow SSH from specific network:

{
  "comment": "SSH from office network",
  "type": "in",
  "protocol": "tcp",
  "source": "198.51.100.0/24",
  "action": "ACCEPT",
  "dport": "22"
}

Allow web traffic:

{
  "comment": "HTTP/HTTPS traffic",
  "type": "in", 
  "protocol": "tcp",
  "source": "0.0.0.0/0",
  "action": "ACCEPT",
  "dport": "80,443"
}

Allow ping:

{
  "comment": "ICMP ping",
  "type": "in",
  "protocol": "icmp",
  "source": "0.0.0.0/0",
  "action": "ACCEPT"
}