Get Virtualizor

Edit IP

Use the Edit IP API to edit an IP address present on your server. Using this API you can lock an IP which will prevent it from being used by any VPS. The API response will contain "done" as "1" after successful update of the IP address.

IP addresses used by a VPS cannot be edited.

See also: Edit IP guide.

HTTP Request

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

Parameters

NameMethodValueDescriptionRequired
actGETeditipsThe action specified to carry out the operation and will return "done" as "1" after the ip has been updated successfullyYes
ipPOSTtextNew IP address valueYes
editipPOST1If not set IP will not be updatedYes
ipidPOSTIntID of the Ip address to be editedYes
mac_addrPOSTtextMac address to be updated, If left blank, the MAC address is auto-generatedNo
lockedPOST1/0If enabled IP will be lockedNo
notePOSTtextYou can define the note here, for eg. Why IP is locked or reserved?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['ip'] = '192.168.1.25';
    $post['mac_addr'] = '';
    $post['locked'] = '';
    $post['ipid'] = 536;
    $post['note'] = '';
    $post['editip'] = 1;

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

    print_r(json_encode($output));

?>

Output

{
  "title": "Edit IPs",
  "done": 1,
  "ippools": {
    "0": {
      "ippid": 0,
      "ippool_name": "None",
      "gateway": "",
      "netmask": "",
      "ns1": "",
      "ns2": ""
    },
    "6": {
      "ippid": "6",
      "ipp_serid": "0",
      "ippool_name": "Haproxy pool",
      "gateway": "10.0.0.1",
      "netmask": "255.0.0.0",
      "ns1": "8.8.8.8",
      "ns2": "8.8.4.4",
      "ipv6": "0",
      "nat": "0",
      "nat_name": "",
      "routing": "0",
      "internal": "0",
      "bridge": "HAProxy",
      "mtu": "0",
      "vlan": "1"
    },
    "8": {
      "ippid": "8",
      "ipp_serid": "0",
      "ippool_name": "test_api_int",
      "gateway": "10.10.1.1",
      "netmask": "255.255.255.0",
      "ns1": "4.2.2.1",
      "ns2": "4.2.2.2",
      "ipv6": "0",
      "nat": "0",
      "nat_name": "",
      "routing": "0",
      "internal": "1",
      "bridge": "intbr0",
      "mtu": "0",
      "vlan": "0"
    }
  },
  "ip": {
    "ipid": "536",
    "ippid": null,
    "ip_serid": "0",
    "vpsid": "0",
    "ip": "8.8.8.8",
    "ipv6": null,
    "ipr_netmask": "",
    "primary": "0",
    "ipr_ips": null,
    "mac_addr": "",
    "locked": "0",
    "note": "",
    "ipp_serid": null,
    "ippool_name": null,
    "gateway": null,
    "netmask": null,
    "ns1": null,
    "ns2": null,
    "nat": null,
    "nat_name": null,
    "routing": null,
    "internal": null,
    "bridge": null,
    "mtu": null,
    "vlan": null
  },
  "ipid": 536,
  "timenow": 1535391685,
  "time_taken": "0.211"
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list