Get Virtualizor

Create IP Pool

An IP Pool is a collection of IPs which can be used to create VPS. You should create an IP Pool so that there are no connectivity issues for the VPSes you create. The Create IP Pool API allows you to create an IP pool on your server. You can define parameters like the Netmask, Gateways and Name Servers for the IP pool. The API response will return "done" as "1" on successful creation of the IP pool.

For adding Subnetted IPs on Hetzner Server please refer the Hetzner NAT guide and for additional IPs please refer the Hetzner Additional IPs guide

See also: Create IP Pool Guide

HTTP Request

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

Parameters

NameMethodValueDescriptionRequired
actGETaddippoolThe action specified to carry out operation and return success after ip pool has been addedYes
iptypePOSTInt4 for IPv4, 6 for IPv6Yes
seridPOSTarrayAn array containing server IDsYes
ippool_namePOSTtextThe name for the IP PoolYes
gatewayPOSTIntThe gateway for the IP poolYes
netmaskPOSTIntThe netmask for the IP PoolYes
ns1POSTIntName server address 1Yes
ns2POSTIntName server address 2 if anyYes
firstipPOSTIntThe first IP of the IP rangeYes
lastipPOSTIntThe last IP of the IP rangeYes
natPOST1/0On or off, if nat is supported( Xen and KVM )No
ipsPOSTarrayAn array containing IPs to be addedNo
macsPOSTarrayAn array containing mac addresses for the ipsNo
routingPOST1/0If set then the routing option for the ip pool will be enabledNo
internalPOST1/0If set then the IPs will be used by VPSes for internal communication. Do not check this, if this IP Pool is for Public IPsNo
internal_bridgePOSTtextName of the internal IP bridgeNo
vlanPOST1/0If checked, vlan networking will be usedNo
vlan_bridgePOSTtextName of the vlan bridgeNo
mtuPOSTIntSpecify the Maximum Transmission Unit in bytesNo
uidPOSTIntSpecify the User ID for which you want to assign the pool (Only cloud user can be assigned with billing enabled, internal pool cannot be assigned) (since 3.1.3.1)
No

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;
    $post['serid'] = 0;
    $post['ippool_name'] = 'test_api_ipv4';
    $post['gateway'] = '192.168.1.47';
    $post['netmask'] = '255.255.255.0';
    $post['ns1'] = '8.8.8.8';
    $post['ns2'] = '8.8.4.4';
    $post['firstip'] = '192.168.1.48';
    $post['lastip'] = '192.168.1.55';
    $post['routing'] = 1;       //This is same for both IPv4 and IPv6
    $post['nat'] = 'on';

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

    print_r(json_encode($output));
?>

Output

{
  "title": "Add IP Pool",
  "done": {
    "ippid": "7",
    "range": {
      "465": "192.168.1.48",
      "466": "192.168.1.49",
      "467": "192.168.1.50",
      "468": "192.168.1.51",
      "469": "192.168.1.52",
      "470": "192.168.1.53",
      "471": "192.168.1.54",
      "472": "192.168.1.55"
    },
    "done": 1
  },
  "timenow": 1535370224,
  "time_taken": "0.279"
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list