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). 


whmapi1 get_public_ip ip=

  "data": {
      "public_ip": ""
  "metadata": {
    "command": "get_public_ip",
    "reason": "OK",
    "result": 1,
    "version": 1



ParameterTypeDescriptionPossible valuesExample


The IP address to query.

  • A valid public IPv4 address, to return that IP address.
  • A valid private IPv4 address, to return the associated public IP address (for example, for 1:1 NAT systems).


ReturnTypeDescriptionPossible valuesExample

The public IP address.

A valid public IPv4 address.