We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on Vesta 2.0 and expect to release it by the end of 2024. Read more about it: https://vestacp.com/docs/vesta-2-development
Add a new IP address through API
-
- Posts: 9
- Joined: Thu Jun 20, 2019 8:27 am
- Os: CentOS 6x
- Web: apache + nginx
Add a new IP address through API
There is anyway to do that?
UPDATE: Nevermind, i created one for who need:
UPDATE: Nevermind, i created one for who need:
Code: Select all
<?php
// Server credentials
$vst_hostname = 'server.vestacp.com';
$vst_username = 'admin';
$vst_password = 'p4ssw0rd';
$vst_command = 'v-add-sys-ip';
// Account
$IP = '1.2.3.4';
$NETMASK = '255.255.255.240';
$INTERFACE = 'eth0';
$USER = 'admin';
$IP_STATUS = '';
$IP_NAME = '';
$NAT_IP = '';
// Prepare POST query
$postvars = array(
'user' => $vst_username,
'password' => $vst_password,
'cmd' => $vst_command,
'arg1' => $IP,
'arg2' => $NETMASK,
'arg3' => $INTERFACE,
'arg4' => $USER,
'arg5' => $IP_STATUS,
'arg6' => $IP_NAME,
'arg7' => $NAT_IP
);
$postdata = http_build_query($postvars);
// Send POST query via cURL
$postdata = http_build_query($postvars);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $vst_hostname . ':8083/api/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl);
// Parse JSON output
$data = json_decode($answer, true);
// Print result
print_r($data);
?>