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
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | addips | The action specified to carry out the operation and return data after the ips have been added | Yes |
iptype | POST | Int | 4 for IPv4, 6 for IPv6 | Yes |
ips | POST | array | An array containing IPv4 ips | Yes |
macs | POST | text | An array containing mac addresses | No |
firstip | POST | IP | First IP of the range if there are multiple IPs | No |
lastip | POST | IP | Last IP of the range if there are multiple IPs | No |
ippid | POST | Int | The IP Pool ID | No |
ip_serid | POST | Int | The server ID in which the pool exists | 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; //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"
}