You can find our user documentation at

Check out our new API beta site!

Child pages
  • WHM API 1 Functions - get_public_ip
Skip to end of metadata
Go to start of metadata


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


 Command Line
whmapi1 get_public_ip ip=


  • Unless otherwise noted, you must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:


 Output (JSON)
  "data": {
      "public_ip": ""
  "metadata": {
    "command": "get_public_ip",
    "reason": "OK",
    "result": 1,
    "version": 1
 Output (XML)


Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.


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.