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
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | addippool | The action specified to carry out operation and return success after ip pool has been added | Yes |
iptype | POST | Int | 4 for IPv4, 6 for IPv6 | Yes |
serid | POST | array | An array containing server IDs | Yes |
ippool_name | POST | text | The name for the IP Pool | Yes |
gateway | POST | Int | The gateway for the IP pool | Yes |
netmask | POST | Int | The netmask for the IP Pool | Yes |
ns1 | POST | Int | Name server address 1 | Yes |
ns2 | POST | Int | Name server address 2 if any | Yes |
firstip | POST | Int | The first IP of the IP range | Yes |
lastip | POST | Int | The last IP of the IP range | Yes |
nat | POST | 1/0 | On or off, if nat is supported( Xen and KVM ) | No |
ips | POST | array | An array containing IPs to be added | No |
macs | POST | array | An array containing mac addresses for the ips | No |
routing | POST | 1/0 | If set then the routing option for the ip pool will be enabled | No |
internal | POST | 1/0 | If set then the IPs will be used by VPSes for internal communication. Do not check this, if this IP Pool is for Public IPs | No |
internal_bridge | POST | text | Name of the internal IP bridge | No |
vlan | POST | 1/0 | If checked, vlan networking will be used | No |
vlan_bridge | POST | text | Name of the vlan bridge | No |
mtu | POST | Int | Specify the Maximum Transmission Unit in bytes | No |
uid | POST | Int | Specify 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"
}