ip.php¶
Module for managing IP addresses and network infrastructure: retrieving IP information, managing PTR records, monitoring traffic, and working with subnets and VLANs.
API Methods¶
| Method | Action | Description |
|---|---|---|
get_client_ip | get client IP | Returns the IP address of the current client making the request. |
get_ip | get IP information | Returns full information about a specific IP address, including network data, mask, and ownership. |
get_ptr | get PTR record | Returns the PTR record (reverse DNS name) for the specified IP address bound to a server. |
get_traffic | get traffic statistics | Returns incoming and outgoing traffic statistics for the specified IP address over a given period. Supports summary mode or detailed breakdown by timestamps. |
list_free_ip | get list of free IPs | Returns a list of unused IP addresses for the specified location or subnet. For clients, the subnet ID is used; for administrators, the location code is used. |
set_main | set main IP | Sets the specified IP address as the primary IP for the server interface. Updates billing data in WHMCS if applicable. |
update_ptr | update PTR record | Sets the reverse DNS record (PTR) for the specified IP address bound to a server. |
ip/get_client_ip¶
Returns the IP address of the current client making the request.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_client_ip |
| token | ✅ | string | Authorization token |
Example Request
ip/get_ip¶
Returns full information about a specific IP address, including network data, mask, and ownership.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_ip |
| token | ✅ | string | Authorization token |
| ip | ✅ | string | IP address to retrieve information for |
| full | ❌ | boolean | Flag to retrieve full data (wrapped in data) |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "ip/get_ip: malformed IP=192.168.1.1 for token abc123" }
```
ip/get_ptr¶
Returns the PTR record (reverse DNS name) for the specified IP address bound to a server.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_ptr |
| token | ✅ | string | Authorization token |
| id | ✅ | integer | Server ID to which the IP belongs |
| ip | ✅ | string | IP address for which to retrieve the PTR record |
| location | ❌ | string | Location (optional, used internally by pdns_get_ptr) |
Example Request
ip/get_traffic¶
Returns incoming and outgoing traffic statistics for the specified IP address over a given period. Supports summary mode or detailed breakdown by timestamps.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_traffic |
| token | ✅ | string | Authorization token |
| ip | ❌ | string | IP address to retrieve traffic statistics for |
| period_start | ❌ | integer | Start of the period in Unix timestamp (default: 24 hours ago) |
| period_stop | ❌ | integer | End of the period in Unix timestamp (default: current time) |
| summary | ❌ | integer | Summary mode: 1 - only total values, 0 - detailed breakdown by timestamps |
| unbilled | ❌ | integer | Payment filter: 1 - only unpaid records, 0 - all records |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "ip/get_traffic: no significant traffic detected for 192.168.1.10 in the period 01-05-2024 - 02-05-2024" }
```
ip/list_free_ip¶
Returns a list of unused IP addresses for the specified location or subnet. For clients, the subnet ID is used; for administrators, the location code is used.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: list_free_ip |
| token | ✅ | string | Authorization token |
| exclude_special | ❌ | int | Exclude special IPs (0/1) |
| id | ❌ | int | Subnet ID (for clients) |
| location | ❌ | string | Location code (for administrators) |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "illegal IP subnet" }
```
ip/set_main¶
Sets the specified IP address as the primary IP for the server interface. Updates billing data in WHMCS if applicable.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: set_main |
| token | ✅ | string | User authorization token |
| id | ✅ | integer | Server ID |
| ip | ✅ | string | IP address to set as primary |
| main | ❌ | integer | Primary IP flag (0 or 1) |
| description | ❌ | string | IP address description |
Example Request
Failure response
``` { "code": -1, "message": "ip/set_main: invalid request" }
```
ip/update_ptr¶
Sets the reverse DNS record (PTR) for the specified IP address bound to a server.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: update_ptr |
| token | ✅ | string | Authorization token |
| id | ✅ | integer | Server ID to which the IP is bound |
| ip | ✅ | string | IP address for which to set the PTR |
| ptr | ❌ | string | PTR record value (hostname) |
| location | ❌ | string | Server location |
Example Request
Failure response
``` { "code": -1, "message": "IP 192.168.1.1 is not assigned for server 123" }