Child pages
  • WHM API 1 Functions - get_public_ip

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

Excerpt
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, Inc.
  • System administrators can configure the main public IP address in WHM's Basic WebHost Manager Setup interface (Home >> Server Configuration >> Basic WebHost Manager Setup). 
Panel
bgColor#F2F2F2
borderStylenone

Examples  


Panel
bgColor#FFFFFF
borderStylenone


Expand
titleJSON API


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



Expand
titleXML API


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



Expand
titleCommand Line


Code Block
languagebash
whmapi1 get_public_ip ip=1.2.3.4

Include Page
LIB:_WHMAPI1CLINote
LIB:_WHMAPI1CLINote


Expand
titleOutput (JSON)


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



Expand
titleOutput (XML)


Code Block
languagetext
linenumberstrue
<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>


Include Page
LIB:_WHMAPIShellNote
LIB:_WHMAPIShellNote


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