Return public IP address of private IP address

This function returns the public IP address for a specified public or private IP address. You can use this function to determine the system's main public IP address, especially for systems that use a 1:1 NAT configuration.

  • cPanel & WHM uses the main public IP address to perform many different functions. For example, the system uses this IP address to verify the server's license status with cPanel, L.L.C.
  • System administrators can configure the main public IP address in WHM's Basic WebHost Manager Setup interface (Home >> Server Configuration >> Basic WebHost Manager Setup).
Authorizations:
query Parameters
ip
required
string <ipv4>

A valid public or private IP address to query.

Example: ip=192.0.2.0

Responses

Response Schema: application/json
object
object

Request samples

whmapi1 --output=jsonpretty \
  get_public_ip \
  ip='192.0.2.0'

Response samples

Content type
application/json
{
  • "data": {
    • "public_ip": "192.0.2.0"
    },
  • "metadata": {
    • "command": "get_public_ip",
    • "reason": "OK",
    • "result": 1,
    • "version": 1
    }
}