Skip to main content

[cPanel UAPI] How to get the serial of a DNS zone

Comments

6 comments

  • cPRex Jurassic Moderator
    Hey there! I reached out to the team and there is not an API call available that will provide the serial number. Most people use a grep/awk combination to pull that information manually. If you'd like to see us add this, could you use the link in my signature to submit a feature request and I'll make sure the development team approves that?
    0
  • Anindya Sundar Mandal
    I have submitted the feature request:
    0
  • cPRex Jurassic Moderator
    Thanks for submitting that. It's up to the team to decide if they want to add it, but I'll be sure to bring it up during next weeks' features meeting.
    0
  • santrix
    Maybe I'm missing something here, but you can just use whmapi1 dumpzone, then look through the .data -> zone[0] -> record objects for type == 'SOA', then you will find serial in there as a key/value. Or rip it out directly e.g. perl perl -0777 -ne 'if ($_ =~ m/^([^;][^\n]+\bSOA\b.*?)(\b[0-9]+)/ms){ if ($2 =~ m/([0-9]+)/){print "$ARGV:$1\n"}}' /var/named/domain.db
    0
  • RadWebHosting
    Maybe I'm missing something here, but you can just use whmapi1 dumpzone, then look through the .data -> zone[0] -> record objects for type == 'SOA', then you will find serial in there as a key/value. Or rip it out directly e.g. perl perl -0777 -ne 'if ($_ =~ m/^([^;][^\n]+\bSOA\b.*?)(\b[0-9]+)/ms){ if ($2 =~ m/([0-9]+)/){print "$ARGV:$1\n"}}' /var/named/domain.db

    Yeah, I am unclear as to what benefit the UAPI would give since your method could easily be iterated/scaled. Maybe OP can enlighten us.
    0
  • gonzadiaz
    Hi, i had that problem that i needed the serial number to use the update zone API. After some investigation i got here and tried the perl script solution. But after sometime experimenting i have found a better way. Using the "parse_zone" api i get all dns records. Filtering the SOA registry i found in the data field the serial number. The SOA registry has 6 strings inside data_b64 array, the third value in the array is the serial number.
    0

Please sign in to leave a comment.