Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Children Display
alltrue
styleh3
pageSuperb Cloud API

POST /virtual_machines/:virtual_machine_id/firewall_rules 

Adds a firewall rule to specified VS

Sections:

Table of Contents
maxLevel4
minLevel2
includeResponse.*|JSON.*|XML.*

Request Parameters

address* - Set the IP address for which this rule is active.

  • Leave the empty field to apply this rule to all IPs
  • Enter hyphen-separated IPs to apply the rule to an IP range (e.g. 192.168.1.1-192.168.1.10)
  • Enter the IPs with slash to apply the rule to CIDR (e.g. 192.168.1.1/24)

command* - sets the command to ACCEPT or DROP the above mentioned IPs

port - sets the port addresses

  • Leave the empty field to apply the rule to all ports
  • Enter colon-separated ports to apply the rule to a port range (e.g. 1024:1028)
  • Enter comma-separated ports to apply the rule to the list of ports (e.g. 80,443,21)

protocol* - protocol type (TCP or UDP)

network_interface_id* - interface of the network

Response Parameters

Info
201 status on and the newly created firewall rule is returned on success

JSON Request example

Code Block
languagebash
themeRDark
 curl -i -X POST -H 'Accept: application/json' -H 'Content-type: application/json' -u user:userpass -d '{"firewall_rule":{"address":"","command":"DROP","protocol":"TCP","network_interface_id":"105","port":""}}' --url <api_url>/virtual_machines/:virtual_machine_id/firewall_rules.json

JSON Response

Code Block
 {"firewall_rule":{"address":"192.168.1.1/32","command":"DROP","created_at":"2015-09-10T23:21:47+00:00","description":null,"destination_ip":null,"enable_logging":null,"enabled":null,"firewall_service_id":null,"id":214,"identifier":"njkrvksjg7iwys","network_interface_id":513,"port":"31","position":3,"protocol":"TCP","source_port":null,"updated_at":"2015-09-10T23:21:47+00:00"}}

XML Request example

Code Block
languagebash
themeRDark
 curl -i -X POST -H 'Accept: application/xml' -H 'Content-type: application/xml' -u user:userpass -d '<?xml version="1.0" encoding="UTF-8"?><firewall_rule><address></address><command>DROP</command><port></port><protocol>TCP</protocol><network_interface_id>105</network_interface_id></firewall_rule>' --url <api_url>/virtual_machines/:virtual_machine_id/firewall_rules.xml