Description

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

Examples  




https://hostname.example.com:2087/cpsess##########/json-api/get_public_ip?api.version=1&ip=1.2.3.4




https://hostname.example.com:2087/cpsess##########/xml-api/get_public_ip?api.version=1&ip=1.2.3.4




whmapi1 get_public_ip ip=1.2.3.4



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




<result>
    <data>
        <public_ip>1.2.3.4</public_ip>
    </data>
    <metadata>
        <version>1</version>
        <reason>OK</reason>
        <result>1</result>
        <command>get_public_ip</command>
    </metadata>
</result>



Parameters

ParameterTypeDescriptionPossible valuesExample
ipstring

Required

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


Return

ReturnTypeDescriptionPossible valuesExample
public_ipstring

The public IP address.

A valid public IPv4 address.
1.2.3.4