We have a new documentation site for cPanel & WHM! You can find our new documentation site at docs.cpanel.net.

We will continue to maintain our API documentation on this server.

Child pages
  • UAPI Functions - DNS::lookup
Skip to end of metadata
Go to start of metadata

Description

This function returns a domain's DNS information. It returns the similar data as the host command.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/DNS/lookup?domain=example.com


Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Returns a domain's DNS information.
$poll = $cpanel->uapi(
    'DNS', 'lookup',
    array(
        'domain' => 'example.com'
  )
);


Note:

For more information, read our Guide to the LiveAPI System.

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Returns a domain's DNS information.
my $poll = $cpliveapi->uapi(
    'DNS', 'lookup',
    {
        'domain' => 'example.com'
  }
);


Note:

For more information, read our Guide to the LiveAPI System.

 Command Line
uapi --user=username DNS lookup domain=example.com


Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • If you run CloudLinux™, you must use the full path of the uapi command:

    /usr/local/cpanel/bin/uapi


 Output (JSON)
{
	"status": 1,
	"data": ["example.com has address 192.0.2.0", "example.com has IPv6 address 2001:0db8:0:0:1:0:0:1", "example.com mail is handled by 0 ."],
	"errors": null,
	"warnings": null,
	"messages": null,
	"metadata": {
		"transformed": 1
	}
}


Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
domainstring

Required

The domain queried for DNS information.

A valid domain.example.com

Returns

ReturnTypeDescriptionPossible valuesExample
dataarrayA array that contains the domain's DNS information.
  • The domain's IPv4 address.
  • The domain's IPv6 address.
  • The domain's MX priority.
 Click to view...

"example.com has address 192.0.2.0", "example.com has IPv6 address 2001:0db8:0:0:1:0:0:1", "example.com mail is handled by 0 ."