SOLVED Using “/scripts/cpdig” as a diagnostic tool for DNS lookups.

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,749
2,205
363
cPanel Access Level
DataCenter Provider
Twitter
Hello :)

We published a new script in cPanel & WHM version 80 to help diagnose DNS issues:
[[email protected] ~]# /scripts/cpdig --help

NAME
cpdig

USAGE
cpdig <name> <type>

DESCRIPTION
This script performs a DNS query using cPanel’s custom DNS resolver. Its
output should yield the same end results as "dig +trace $name $type".

cPanel provides this script solely for diagnostic purposes; no cPanel &
WHM feature requires its use.

[[email protected] ~]#
Below is an example of a command you can enter to check which IP address a domain's "A" record resolves to using Terminal in WHM:

/scripts/cpdig your-domain-here.tld A

Thank you.

Perl:
#!/usr/local/cpanel/3rdparty/bin/perl


# cpanel - scripts/cpdig                           Copyright 2019 cPanel, L.L.C.

#                                                           All rights reserved.

# [email protected]                                         http://cpanel.net

# This code is subject to the cPanel license. Unauthorized copying is prohibited


package scripts::cpdig;


use strict;

use warnings;


=encoding utf-8


=head1 NAME


cpdig


=head1 USAGE


    cpdig <name> <type>


=head1 DESCRIPTION


This script performs a DNS query using cPanel’s custom DNS resolver.

Its output should yield the same end results as C<dig +trace $name $type>.


cPanel provides this script solely for diagnostic purposes; no cPanel

& WHM feature requires its use.


=cut


use parent qw( Cpanel::HelpfulScript );


use Cpanel::DnsRoots::Resolver;


use constant _OPTIONS        => ();

use constant _ACCEPT_UNNAMED => 1;


__PACKAGE__->new(@ARGV)->run() if !caller;


sub run {

    my ($self) = @_;


    my ( $name, $type ) = $self->getopt_unnamed();

    die $self->help() if grep { !$_ } $name, $type;


    my $dns = Cpanel::DnsRoots::Resolver->new();


    $self->_print("$_\n") for $dns->recursive_query( $name, $type );


    return;

}


1;
 
Last edited: