The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XML-API: List all domains on a server along with their assigned IP

Discussion in 'cPanel Developers' started by stards, Jan 12, 2014.

  1. stards

    stards Registered

    Joined:
    Jan 11, 2014
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi

    Is there a way to list all domains on a server along with their cpanel-assigned IP? I know there's "resolvedomainname?api.version=1&domain=example.com" but this one does a DNS resolve (not a straight out pull from the cpanel server itself like httpd.conf).

    I'd hate to have to pull info out of vhosts from httpd.conf.

    There's this perl module:

    /usr/local/cpanel/Cpanel/UserDomainIp.pm

    Is there way to leverage this piece of code reliably without it breaking in the future? If so what's the proper way to pull the info out?

    Please help!

    Thanks
     
  2. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    You'd think so but frustratingly, something so simple is not available. There's listaccts (List Accounts) which will show the primary domain and IP for each account but it does not provide sub/parked/addon domains.

    The only place in the UI that shows all domains and their IPs is https://<hostname>:2087/cpsessXXXXXX/scripts/ipusage

    You could parse this page for the information.

    You could also write your own custom API module to gather this data: Writing cPanel Modules



    You could write a custom API module that is a wrapper around UserDomainIP::getdomainip(). However, there's no guarantee that this function won't change in the future (though it hasn't in a long time).

    Custom API module docs: Writing cPanel Modules
     
  3. stards

    stards Registered

    Joined:
    Jan 11, 2014
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator

    Thanks! At the very least now I have a sense of direction...
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Note that you are also welcome to open a feature request to see a more direct way of obtaining this information through our API:

    Submit A Feature Request

    Thank you.
     
Loading...

Share This Page