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 addresses Adds the specified number of IPv4 addresses to a server in a given port and VLAN. If no IP is specified, the system selects free addresses available in this location.
block_ip block IP address Blocks the specified IP address via BIRD or blackhole. If the description parameter is not provided, the system prefix of the owner is used.
get_status get port status Returns network interface status information (port status, speed, duplex, etc.) for the specified server.
port_off disable port Disables the server's network port. If a reason (block_reason) is provided, an administrative block tag is created.
port_on enable port Activates the server's network port, removing associated blocking tags (e.g., 'block'), if permitted by security policy.
remove_ipv4 remove IPv4 address Removes one or all IPv4 addresses from the server. If the remove_all parameter is specified, all assigned addresses are removed.
show_cacti get cacti graph Returns data for displaying Cacti charts associated with the server's network interface.
show_ipv4_free get free IPv4 addresses Returns a list of available IPv4 addresses for assignment in the specified VLAN, taking into account tags (tag) for a specific server.
unblock_ip unblock IP Removes the block from the specified IP address on the server via BIRD or other network management mechanisms.

net/add_ipv4

Adds the specified number of IPv4 addresses to a server in a given port and VLAN. If no IP is specified, the system selects free addresses available in this 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 Port name (e.g., eth0, ipmi)
ips[] string[] Array 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 admins)
fresh_period integer IP address freshness period

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_1"
]
}
Failure response
{
"code": -1,
"message": "failed to add IPv4: error while looking for free IP (ip: 1.1.1.1 vlan: 10 tag: bm amount: 1 at US)"
}

net/block_ip

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

HTTP-method: POST

Parameters:

Parameter Required Type Description
token string Authorization token
id integer Server ID (if not specified, IP will be searched by address)
ip string IP address to block
description string Reason for blocking (added to the prefix)
four_hours integer If > 0, sets a temporary 4-hour block via the block_expire tag

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "token=HOSTKEY_TOKEN" \
--data "ip=1.2.3.4"
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 network interface status information (port status, speed, duplex, etc.) for the specified server.

HTTP-method: POST

Parameters:

Parameter Required Type Description
id integer Server ID
port string Port name (e.g., eth0, ipmi)
vlan string VLAN ID
speed string Port speed
port_security integer Port security settings
trunc string Fragmentation/truncation parameters
status integer Port status (-1 by default)
duplex string Duplex mode
port_virt_node integer Virtual port node

Example Request

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

``` { "code": -1, "message": "Server not found or permission denied" }

```

net/port_off

Disables the server's network port. If a reason (block_reason) is provided, an administrative block tag is created.

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 (block_reason)

Example Request

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

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

```

net/port_on

Activates the server's network port, removing associated blocking tags (e.g., 'block'), if permitted by security policy.

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",
"callback": "net_manage_port_result"
}
Failure response

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

```

net/remove_ipv4

Removes one or all IPv4 addresses from the server. If the remove_all parameter is specified, all assigned addresses are removed.

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
remove_all integer Flag to remove all addresses (1 - remove all)

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=remove_ipv4" \
--data "token=HOSTKEY_TOKEN" \
--data "id=VALUE" \
--data "ip=VALUE"
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 associated with the server's network interface.

HTTP-method: POST|GET

Parameters:

Parameter Required Type Description
action string Method identifier: show_cacti
token string Authorization token
id integer Server ID
port string Port name (e.g., eth0)
graph integer 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=VALUE"
Example of a successful response
{
"result": "OK",
"action": "show_cacti",
"callback": "string"
}
Failure response

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

```

net/show_ipv4_free

Returns a list of available IPv4 addresses for assignment in the specified VLAN, taking into account tags (tag) for a specific server.

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)
vlan integer VLAN ID
ip string Specific IP to search for (if not specified, searches all)
tag string Tag (can be a string or an array)
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" \
--data "vlan=100" \
--data "tag[]=val1" \
--data "tag[]=val2"
Example of a successful response
{
"result": "OK",
"action": "show_ipv4_free",
"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": "show_ipv4_free: invalid request - invalid id 0" }

```

net/unblock_ip

Removes the block from the specified IP address on the server via BIRD or other network management mechanisms.

HTTP-method: POST

Parameters:

Parameter Required Type Description
token string Authorization token
id integer Server ID
ip string IP address to unblock

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--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" }

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