Aller au contenu

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 available free addresses from those available in this location.
block_ip block IP address Blocks the specified IP address via BIRD or blackhole for a specific server. It can set an expiration period for the block if required.
get_status get port status Returns information about the state of the server's network interface (port), including configuration parameters and current settings.
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 Enables the server's network port, removing associated blocking tags (e.g., 'block'). If the user has the customer role and there is an administrative ban on the port, the operation 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 IPs are removed (depending on backend implementation). Upon successful execution, it returns a list of removed IPs and keys.
show_cacti display cacti graph Returns data for constructing Cacti graphs for a specific server port.
show_ipv4_free get free IPv4 addresses Returns a list of available IPv4 addresses for assignment in the specified VLAN and subnet for a specific server.
unblock_ip unblock IP Removes the block from the specified IP address on the server. If the action is performed by a client, the presence of a corresponding entry in the port description is checked.

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 available free addresses from those 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 Freshness period of IP addresses

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 for a specific server. It can set an expiration period for the block if required.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Action: block_ip or blackhole_ip
token string Authorization token
id integer Server ID (if not specified, it will be found by IP)
ip string IP address to block
description string Reason for blocking (added to the tag)
four_hours integer If > 0, sets a temporary 4-hour block

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=block_ip" \
--data "token=YOUR_TOKEN" \
--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 information about the state of the server's network interface (port), including configuration parameters and current settings.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: get_status
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 Truncation parameters
status integer Port status (-1 by default)
duplex string Duplex mode

Example Request

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

``` { "code": -1, "message": "Server not found or invalid port configuration" }

```

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 Blocking reason (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": "Port management command execution error" }

```

net/port_on

Enables the server's network port, removing associated blocking tags (e.g., 'block'). If the user has the customer role and there is an administrative ban on the port, the operation will be rejected.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: port_on
id int Server ID
port string Port name (e.g., eth0, ipmi)
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": "object"
}
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 IPs are removed (depending on backend implementation). Upon successful execution, it returns a list of removed IPs and keys.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: remove_ipv4
token string Authorization token
id int Server ID
ip string IP address to remove (valid IPv4)
remove_all int Full removal flag for all IPs

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": [
"192.168.1.10"
],
"keys": [
"key_abc123"
]
}
Failure response
{
"code": -1,
"message": "No IP specified",
"action": "remove_ipv4",
"id": 0,
"ips": []
}

net/show_cacti

Returns data for constructing Cacti graphs for a specific server port.

HTTP-method: POST|GET

Parameters:

Parameter Required Type Description
id int Server ID
port string Port name (e.g., eth0)
graph int Cacti graph ID
token string Authorization token

Example Request

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

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

```

net/show_ipv4_free

Returns a list of available IPv4 addresses for assignment in the specified VLAN and subnet 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)
ip_tag string|array Tag for IP search (can be a string or an array from add_ipv4)
show_all integer Show all available addresses (0 or 1). For customers, it is always forced to 0.
fresh_period integer Data freshness period

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=show_ipv4_free" \
--data "id=123" \
--data "ip_tag[]=tag1" \
--data "ip_tag[]=tag2"
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": "can't find appropriate free IP (vlan: 100 tag: bm amount: -1 at NL)" }

```

net/unblock_ip

Removes the block from the specified IP address on the server. If the action is performed by a client, the presence of a corresponding entry in the port description is checked.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: unblock_ip
id integer Server ID
ip string IP address to unblock
token string API authentication token

Example Request

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

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