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 WebPros International, LLC.
  • System administrators can configure the main public IP address in WHM's Basic WebHost Manager Setup interface (Home >> Server Configuration >> Basic WebHost Manager Setup).
SecurityBasicAuth
Request
query Parameters
ip
required
string <ipv4>

A valid public or private IP address to query.

Example: ip=192.0.2.0
Responses
200

HTTP Request was successful.

Response Schema: application/json
object
object
get/get_public_ip
Request samples
whmapi1 --output=jsonpretty \
  get_public_ip \
  ip='192.0.2.0'
Response samples
application/json
{
  • "data": {
    • "public_ip": "192.0.2.0"
    },
  • "metadata": {
    • "command": "get_public_ip",
    • "reason": "OK",
    • "result": 1,
    • "version": 1
    }
}