Get Virtualizor

Add IP (IPv4)

Use the Add IP API to add an IPv4 type of IP address on your server. This IP address can be used for the creation of VPS on the server. You can add single IP address or pass in multiple IP addresses as shown. In addition to that MAC IDs can also be passed which will be binded to the IP address.

You cannot add IPs to an IP Pool which has NAT enabled.

See also: Add IP guide.

HTTP Request

https://hostname:4085/index.php?act=addips

Parameters

NameMethodValueDescriptionRequired
actGETaddipsThe action specified to carry out the operation and return data after the ips have been addedYes
iptypePOSTInt4 for IPv4, 6 for IPv6Yes
ipsPOSTarrayAn array containing IPv4 ipsYes
macsPOSTtextAn array containing mac addressesNo
firstipPOSTIPFirst IP of the range if there are multiple IPsNo
lastipPOSTIPLast IP of the range if there are multiple IPsNo
ippidPOSTIntThe IP Pool IDNo
ip_seridPOSTIntThe server ID in which the pool existsNo

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['iptype'] = 4;            //4 for ipv4 & 6 for ipv6
    $post['ips'] = array('192.168.1.200');
    $post['macs'] = array('');
    $post['firstip'] = '';
    $post['lastip'] = '';
    $post['ippid'] = '';
    $post['ip_serid']= 0;

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

    print_r(json_encode($output));
?>

Output

{
  "title": "Add IP",
  "done": {
    "range": {
      "536": "192.168.1.200"
    },
    "done": 1
  },
  "timenow": 1535388434,
  "time_taken": "0.217"
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list