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 Adds one or multiple IPv4 addresses to a specific server interface. If no IP is provided, the system searches for available free IPs based on location and VLAN.
block_ip block ip Blocks a specific IP address using BIRD or blackhole mode. If an expiration time is set, it adds a block_expire tag to the server.
get_status get status / shape net Manages network port states (on/off), bandwidth shaping, and interface configurations for a specific server.
port_off turn off port Disables a specific network port on the target device.
port_on turn on port Enables a specific network port on the target device.
remove_ipv4 remove IPv4 address from a server Removes a specific IPv4 address or all IPv4 addresses from the specified server.
show_cacti get cacti graph Retrieves a specific Cacti graph for the given resource ID.
show_ipv4_free get free ipv4 addresses Returns a list of available IPv4 addresses for a specific server, interface (port), and VLAN, considering ownership and subnet constraints.
unblock_ip unblock ip Removes an IP block from a specific server using BIRD or blackhole management.

net/add_ipv4

Adds one or multiple IPv4 addresses to a specific server interface. If no IP is provided, the system searches for available free IPs based on location and VLAN.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action ✅ string The action to perform
token ❌ string Authentication token
id ✅ integer Server ID
port ✅ string Interface name or type (e.g., 'eth0', 'ipmi')
ips[] ❌ array Specific IP addresses to add. If empty, system searches for free IPs.
ip_tag ❌ string|array Tag used for searching/filtering IPs
amount ❌ integer Number of free IPs to search for if 'ips' is not provided
allow_tech_networks ❌ integer Admin option to allow adding IPs from non-customer networks

Example Request

curl -s "https://invapi.hostkey.com/net" -X POST \
--data "action=add_ipv4" \
--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
},
{
"ip": "192.168.1.11",
"vlan": 100
}
],
"keys": [
"key_abc123"
]
}
Failure response
{
"code": -1,
"message": "failed to add IPv4: error message",
"context": {
"id": 123,
"port": "eth0"
}
}

net/block_ip

Blocks a specific IP address using BIRD or blackhole mode. If an expiration time is set, it adds a block_expire tag to the server.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action ✅ string The action to perform (block_ip or blackhole_ip)
token ✅ string Authentication token
ip ✅ string The IP address to block
id ❌ int Server ID. If not provided, the system attempts to find it via eq_search using the IP.
description ❌ string Description for the block entry

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=Malicious traffic"
Example of a successful response
{
"result": "OK",
"action": "block_ip",
"callback": "7bc29eb23fb1b879b21fce509597f07c"
}
Failure response
{
"code": -1,
"message": "Invalid IP"
}

net/get_status

Manages network port states (on/off), bandwidth shaping, and interface configurations for a specific server.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action ✅ string The action to perform (e.g., port_on, port_off, shape_net)
id ✅ int Server ID
port ❌ string Port notation (e.g., eth0, ipmi)
vlan ❌ int VLAN ID
speed ❌ string Interface speed
port_security ❌ int Port security setting
trunc ❌ int Trunking configuration
status ❌ string Port status
token ❌ string Authentication token
duplex ❌ int Duplex mode
nic_id ❌ int Network Interface Card ID
port_virt_node ❌ string Virtual node port information

Example Request

curl -s "https://invapi.hostkey.com/net" -X POST \
--data "action=get_status" \
--data "id=123" \
--data "port=eth0"
Example of a successful response
{
"result": "OK",
"action": "get_status",
"data": {
"status": "active",
"port_id": 123,
"current_vlan": 100
}
}
Failure response
{
"code": -1,
"message": "no IP assigned for server 123 or invalid server id"
}

net/port_off

Disables a specific network port on the target device.

HTTP Method: POST

Parameters:

Parameter Required Type Description
token ✅ string Authentication token for verifying user session
id ✅ int The unique identifier of the port to be disabled

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "token=HOSTKEY_TOKEN" \
--data "id=VALUE"
Example of a successful response
{
"result": "OK",
"action": "port_off",
"callback": "7bc29eb23b879b21fce509597f07c"
}
Failure response
{
"code": -1,
"message": "Access denied"
}

net/port_on

Enables a specific network port on the target device.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action ✅ string The action to perform
token ✅ string Authentication token
params[id] ✅ integer The ID of the port to enable

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=port_on" \
--data "token=YOUR_TOKEN" \
--data "params[id]=123"
Example of a successful response
{
"result": "OK",
"action": "port_on",
"data": {
"id": 123,
"status": "active",
"callback": "7bc29eb23b879b21fce509597f07c"
}
}
Failure response
{
"code": -1,
"message": "Action required"
}

net/remove_ipv4

Removes a specific IPv4 address or all IPv4 addresses from the specified server.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action ✅ string The action to perform
token ❌ string Authentication token
params[id] ✅ int The ID of the server
params[ip] ❌ string The IPv4 address to remove
params[remove_all] ❌ boolean Whether to remove all IPv4 addresses from the server

Example Request

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

net/show_cacti

Retrieves a specific Cacti graph for the given resource ID.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action ✅ string Method identifier: show_cacti
id ✅ int The unique identifier of the network resource (e.g., switch or device).
port ❌ string Port identifier for the graph.

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=show_cacti" \
--data "id=VALUE"
Example of a successful response
{
"result": "OK",
"action": "show_cacti",
"data": {
"graph": "string"
}
}
Failure response
{
"code": -1,
"message": "invalid request"
}

net/show_ipv4_free

Returns a list of available IPv4 addresses for a specific server, interface (port), and VLAN, considering ownership and subnet constraints.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action ✅ string Method identifier: show_ipv4_free
token ❌ string Authentication token for the session
id ✅ integer The ID of the server
port ✅ string Interface name (e.g., 'ipmi')
ip ❌ string IP address to check against
amount ❌ integer Number of IP addresses requested
show_all ❌ integer Whether to show all available IPs (0 or 1). Customers are restricted to 0.

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=show_ipv4_free" \
--data "id=VALUE" \
--data "port=VALUE"
Example of a successful response
{
"result": "OK",
"action": "show_ipv4_free",
"id": 123,
"ips": [
{
"ip": "192.168.1.10",
"subnet": "255.255.255.0"
},
{
"ip": "192.168.1.11",
"subnet": "255.255.255.0"
}
],
"subnets": [
"192.168.1.0/24"
],
"res": {},
"total_ips": 2,
"fresh": 3600
}
Failure response
{
"code": -1,
"message": "invalid request - invalid id 0",
"context": {
"id": 0,
"port": "eth0"
}
}

net/unblock_ip

Removes an IP block from a specific server using BIRD or blackhole management.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action ✅ string The action to perform (e.g., unblock_ip)
token ❌ string Authentication token
ip ✅ string The IP address to unblock
id ❌ int Server ID. If not provided, the system attempts to find the server by IP

Example Request

curl -s "https://invapi.hostkey.com/net.php" -X POST \
--data "action=unblock_ip" \
--data "token=YOUR_TOKEN" \
--data "ip=1.2.3.4" \
--data "id=123"
Example of a successful response
{
"result": "OK",
"action": "unblock_ip",
"callback": "7bc29eb23fb1b879b21fce509597f07c"
}
Failure response
{
"code": -1,
"message": "net/unblock_ip: failed to send BIRD management command"
}
question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×