Skip to main content

update SOA of DNS zone record with API

Comments

3 comments

  • cPRex Jurassic Moderator

    Hey there!  To update the main TTL of the zone, you can use a command like this:

    whmapi1 editzonerecord domain="domain.com" line="3" ttl="300"

    assuming Line 3 is the main TTL in the zone file, which I find that is typically the case.

    To update the SOA fields, let's get that line number from the zone:

    whmapi1 dumpzone domain="domain.com"

    and we can see that is all on line 4 based on that output:

            - 
              Line: 4
              Lines: 6
              class: IN
              expire: 1209600
              minimum: 86400
            mname: ns1.nameserver.com
            name: domain.com.
              refresh: 3600
              retry: 1800
            rname: email\.address.net
              serial: '2024123005'
              ttl: 86400
              type: SOA
          -

    We can then create an API command that updates one record in the zone.  Let's say we want to adjust only the email:

    whmapi1 editzonerecord domain="sitejettest.com" line="4" rname="newaddress\.newdomain.com"

    That would give us a new entry there if we check the file:

    domain.com.    86400    IN    SOA    ns1.nameserver.com.    newaddress\.newdomain.com.    (

    We could then do the same for mname, the nameserver record:

    whmapi1 editzonerecord domain="domain.com" line="4" mname="newnameserver.nameserver.com"

    and now we see our update in place:

    domain.com.    86400    IN    SOA    newnameserver.nameserver.com.    newaddress\.newdomain.com.    (

    Can you let me know if that's what you're looking for?

    0
  • Ali HBZ

    base on dumpzone document page it has deprecated and say use parse_dns_zone instead. in the response of parse_dns_zone we got:

    ...

    -
          data_b64:
            - bnMxMJ6LmNvbS4=
            - ZXNcLhaWwuY29tLg==
            - MjAyNwMg==
            - MzYA==
            - MTwMA==
            - MTIMA==
            - ODYDA=
          dname_b64: YWxmNvbS4=
          line_index: 3
          record_type: SOA
          ttl: 86400
          type: record

    ...

    as you can see recored_type: SOA from parse_dns_zone line is 3. but after try with dumpzone in the response show line 4, for SOA!

    that is the point. what action must use? deprecated dumpzone or recommended parse_dns_zone.

    why SOA line is different in these response?

     

    thank cPRex

    0
  • cPRex Jurassic Moderator

    Even though it's technically deprecated you should still be using that to get the correct line number at this time.  It still works, and still provides the correct line number.

    0

Please sign in to leave a comment.