Skip to content

net.php

Network infrastructure management module: adding and removing IP addresses, blocking traffic, managing network port states, retrieving statistics, and displaying Cacti charts.

API Methods

Method Action Description
add_ipv4 add IPv4 address Adds the specified number of IPv4 addresses to a server in the selected port and VLAN. If no IP is specified, the system selects available free addresses from those available in the current location.
block_ip block IP address Blocks the specified IP address for the server via BIRD or blackhole. If the description parameter is not provided, the system's owner prefix is used.
get_status get port status Returns the current state and parameters of the server's network interface (speed, VLAN, status, security settings).
port_off disable port Disables the server's network port by adding an administrative block with a reason specified in the interface tags.
port_on enable port Enables the server's network port by removing associated blocking tags (e.g., 'block'). If an administrative ban is set on the port, the action will be rejected.
remove_ipv4 remove IPv4 address Removes one or more IPv4 addresses from the server. If the remove_all parameter is specified, all IP addresses are removed (depending on backend implementation logic). Upon successful execution, the PTR record in DNS is cleared.
show_cacti get cacti chart Returns data for displaying Cacti charts for a specific port and graph ID.
show_ipv4_free get free IPv4 addresses Returns a list of available IPv4 addresses for assignment to a specific server, port, and VLAN, taking into account location and tags.
unblock_ip unblock IP Removes the block from the specified IP address via BIRD. If the action is performed by a client, it checks for the presence of a corresponding entry in the interface description.

net/add_ipv4

Adds the specified number of IPv4 addresses to a server in the selected port and VLAN. If no IP is specified, the system selects available free addresses from those available in the current location.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: add_ipv4
token string Authorization token
id integer Server ID
port string Network interface name (e.g., eth0, ipmi)
ips[] array List of IP addresses to add. If empty, selection is performed.
amount integer Number of IP addresses to select (if ips is not specified)
allow_tech_networks integer Allow the use of technical networks (for administrators)

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=add_ipv4" \
--data "token=HOSTKEY_TOKEN" \
--data "id=123" \
--data "port=eth0" \
--data "ips[]=192.168.1.10" \
--data "ips[]=192.168.1.11"
Example of a successful response
{
"result": "OK",
"action": "add_ipv4",
"id": 123,
"ips": [
{
"ip": "192.168.1.10",
"vlan": 100
}
],
"keys": [
"key_abc123"
]
}
Failure response

``` { "code": -1, "message": "failed to add IPv4: error message from service" }

```

net/block_ip

Blocks the specified IP address for the server via BIRD or blackhole. If the description parameter is not provided, the system's owner prefix is used.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Action (block_ip or blackhole_ip)
token string Authorization token
id integer Server ID
ip string IP address to block
description string Reason for blocking (added to the prefix)
four_hours integer Set a time limit (4 hours)

Example Request

curl -s "https://invapi.hostkey.com/net" -X POST \
--data "action=block_ip" \
--data "token=YOUR_TOKEN" \
--data "id=123" \
--data "ip=1.2.3.4" \
--data "description=Spam attack"
Example of a successful response
{
"result": "OK",
"action": "block_ip",
"callback": "7bc29eb23fb1b879b21fce509597f07c"
}
Failure response

``` { "code": -1, "message": "failed to send BIRD management command" }

```

net/get_status

Returns the current state and parameters of the server's network interface (speed, VLAN, status, security settings).

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: get_status
token string Authorization token
id integer Server ID
port string Port name (e.g., eth0)
vlan string VLAN ID
speed string Port speed
port_security string Port security settings
trunc string Traffic parameters (truncation)
status string Port status
duplex string Duplex mode
port_virt_node mixed Virtual port node

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=get_status" \
--data "token=HOSTKEY_TOKEN" \
--data "id=VALUE"
Example of a successful response
{
"result": "OK",
"action": "get_status",
"data": {
"port_id": 123,
"port": "eth0",
"vlan": 100,
"speed": "1000",
"status": "active",
"port_security": 1,
"trunc": "",
"duplex": "full",
"nic_id": 456
}
}
Failure response

``` { "code": -1, "message": "invalid request for server id 0 with port eth0" }

```

net/port_off

Disables the server's network port by adding an administrative block with a reason specified in the interface tags.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: port_off
token string Authorization token
id integer Server ID
port string Port name (e.g., eth0)
reason string Reason for blocking the port

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=port_off" \
--data "id=12345" \
--data "port=eth0" \
--data "reason=Maintenance"
Example of a successful response
{
"result": "OK",
"action": "port_off"
}
Failure response

``` { "code": -1, "message": "net: action required" }

```

net/port_on

Enables the server's network port by removing associated blocking tags (e.g., 'block'). If an administrative ban is set on the port, the action will be rejected.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: port_on
id integer Server ID
port string Port name (e.g., eth0)
token string Authorization token

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=port_on" \
--data "id=VALUE" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"action": "port_on",
"data": {
"id": 123,
"port": "eth0",
"status": "active"
}
}
Failure response

``` { "code": -1, "message": "admin ban could not be lifted this way, please contact support or abuse team." }

```

net/remove_ipv4

Removes one or more IPv4 addresses from the server. If the remove_all parameter is specified, all IP addresses are removed (depending on backend implementation logic). Upon successful execution, the PTR record in DNS is cleared.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: remove_ipv4
token string Authorization token
id integer Server ID
ip string IP address to remove (in IPv4 format)
remove_all integer Full removal flag for all IPs (0 or 1)

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=remove_ipv4" \
--data "token=HOSTKEY_TOKEN" \
--data "id=123" \
--data "ip=192.168.1.1"
Example of a successful response
{
"result": "OK",
"action": "remove_ipv4",
"id": 123,
"ips": [
{
"ip": "192.168.1.1",
"vlan": 100
}
],
"keys": [
"key_abc123"
]
}
Failure response
{
"code": -1,
"message": "No IP specified",
"action": "remove_ipv4",
"id": 0,
"ips": []
}

net/show_cacti

Returns data for displaying Cacti charts for a specific port and graph ID.

HTTP-method: POST|GET

Parameters:

Parameter Required Type Description
action string Method identifier: show_cacti
token string Authorization token
id int Server/device ID
port string Port name (e.g., eth0)
graph int Cacti graph ID

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=show_cacti" \
--data "token=HOSTKEY_TOKEN" \
--data "id=123" \
--data "port=eth0" \
--data "graph=5"
Example of a successful response
{
"result": "OK",
"action": "show_cacti",
"data": {}
}
Failure response

``` { "code": -1, "message": "invalid request" }

```

net/show_ipv4_free

Returns a list of available IPv4 addresses for assignment to a specific server, port, and VLAN, taking into account location and tags.

HTTP-method: POST|GET

Parameters:

Parameter Required Type Description
action string Method identifier: show_ipv4_free
token string Authorization token
id integer Server ID
port string Interface name (e.g., eth0, ipmi)
ip string Base IP for search
tag string Tag (can be an array or a string)
show_all integer Show all available addresses (0 or 1)
fresh_period integer Data freshness period

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=show_ipv4_free" \
--data "token=HOSTKEY_TOKEN" \
--data "id=123"
Example of a successful response
{
"result": "OK",
"action": "show_ipv4_free",
"id": 123,
"ips": [
{
"ip": "192.168.1.10",
"vlan": 100
}
],
"subnets": [
"192.168.1.0/24"
],
"res": {},
"total_ips": 2,
"fresh": -1
}
Failure response

``` { "code": -1, "message": "can't find approppriate free IP (vlan: 100 tag: bm amount: -1 at US)" }

```

net/unblock_ip

Removes the block from the specified IP address via BIRD. If the action is performed by a client, it checks for the presence of a corresponding entry in the interface description.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: unblock_ip
token string Authorization token
id integer Server ID (if known)
ip string IP address to unblock

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=unblock_ip" \
--data "token=HOSTKEY_TOKEN" \
--data "ip=1.2.3.4"
Example of a successful response
{
"result": "OK",
"action": "unblock_ip",
"callback": "7bc29eb23fb1b879b21fce509597f07c"
}
Failure response

``` { "code": -1, "message": "failed to send BIRD management command", "context": { "id": 123, "ip": "1.2.3.4" } }

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×