Get Virtualizor

Firewall

API Description

Virtualizor uses linux's iptables to manage the server firewall. The Firewall API allows you to manage the server firewall where you can perform multiple operations such as blocking/allowing ports and restarting firewall and much more. The API response will contain the "output" key which consists of the output of the iptables after execution of the firewall rule.

HTTP Request

curl "https://hostname:4085/index.php?act=firewall"

Parameters

Sample Code

 <?php

    require_once('/usr/local/virtualizor/sdk/admin.php');

    $key =  'your_api_key';
    $pass = 'your_api_pass';
    $ip = 'your_server_ip';

    $admin = new Virtualizor_Admin_API($ip, $key, $pass);

    $post = array();
    $post['status'] = 1;        //here status is set, which will return the status of the firewall

    $output = $admin->firewall($post);

    print_r(json_encode($output));

?>

Output

 {
    "title": "Firewall Services ",
    "output": ["iptables: Firewall is not running."],
    "timenow": "1471411564",
    "time_taken": "0.113"
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list