[GH-ISSUE #5] Can't enter multiple NS records #5

Closed
opened 2026-02-26 10:35:24 +03:00 by kerem · 7 comments
Owner

Originally created by @ghost on GitHub (Jan 15, 2016).
Original GitHub issue: https://github.com/PowerDNS-Admin/PowerDNS-Admin/issues/5

If I add a second NS entry for the zone it removes the first one

Originally created by @ghost on GitHub (Jan 15, 2016). Original GitHub issue: https://github.com/PowerDNS-Admin/PowerDNS-Admin/issues/5 If I add a second NS entry for the zone it removes the first one
kerem 2026-02-26 10:35:24 +03:00
Author
Owner

@ivanfilippov commented on GitHub (Feb 8, 2016):

This also affects MX records.

<!-- gh-comment-id:181601866 --> @ivanfilippov commented on GitHub (Feb 8, 2016): This also affects MX records.
Author
Owner

@ivanfilippov commented on GitHub (Feb 9, 2016):

Looks like the PDNS API expects same-type records to be updated as a single 'rrset' in the JSON request (using multiple 'records') instead of over multiple 'rrsets'. This issue will prevent the creation of any records (after the first one) that share a name and type, this includes NS, MX, SRV and TXT entries as well as multiple A and AAAA entries used for round-robin style DNS.

This is what the PDNS API expects:

{
  "rrsets": [
    {
      "name": "test.com",
      "type": "MX",
      "changetype": "REPLACE",
      "records": [
        {
          "content": "10 mx1.test.com",
          "disabled": false,
          "name": "test.com",
          "ttl": 3600,
          "type": "MX"
        },
        {
          "content": "20 mx2.test.com",
          "disabled": false,
          "name": "test.com",
          "ttl": 3600,
          "type": "MX"
        }
      ]
    }
  ]
}

And this is what the PowerDNS-Admin code sends:

{
  "rrsets": [
    {
      "name": "test.com",
      "type": "MX",
      "changetype": "REPLACE",
      "records": [
        {
          "content": "10 mx1.test.com",
          "disabled": false,
          "name": "test.com",
          "ttl": 3600,
          "type": "MX"
        }
      ]
    },
    {
      "name": "test.com",
      "type": "MX",
      "changetype": "REPLACE",
      "records": [
        {
          "content": "20 mx2.test.com",
          "disabled": false,
          "name": "test.com",
          "ttl": 3600,
          "type": "MX"
        }
      ]
    }
  ]
}

The code needing the fix is in 'app/models.py'.

<!-- gh-comment-id:181637576 --> @ivanfilippov commented on GitHub (Feb 9, 2016): Looks like the PDNS API expects same-type records to be updated as a single 'rrset' in the JSON request (using multiple 'records') instead of over multiple 'rrsets'. This issue will prevent the creation of any records (after the first one) that share a name and type, this includes NS, MX, SRV and TXT entries as well as multiple A and AAAA entries used for round-robin style DNS. This is what the PDNS API expects: ``` javascript { "rrsets": [ { "name": "test.com", "type": "MX", "changetype": "REPLACE", "records": [ { "content": "10 mx1.test.com", "disabled": false, "name": "test.com", "ttl": 3600, "type": "MX" }, { "content": "20 mx2.test.com", "disabled": false, "name": "test.com", "ttl": 3600, "type": "MX" } ] } ] } ``` And this is what the PowerDNS-Admin code sends: ``` javascript { "rrsets": [ { "name": "test.com", "type": "MX", "changetype": "REPLACE", "records": [ { "content": "10 mx1.test.com", "disabled": false, "name": "test.com", "ttl": 3600, "type": "MX" } ] }, { "name": "test.com", "type": "MX", "changetype": "REPLACE", "records": [ { "content": "20 mx2.test.com", "disabled": false, "name": "test.com", "ttl": 3600, "type": "MX" } ] } ] } ``` The code needing the fix is in 'app/models.py'.
Author
Owner

@ivanfilippov commented on GitHub (Feb 11, 2016):

I'm not a Python wizard by any means, but I've created a pull request with my solution to this problem. Anyone else wanting to fix the issue before the pull request is accepted can make the code modification listed in the pull request (https://github.com/ngoduykhanh/PowerDNS-Admin/pull/7).

<!-- gh-comment-id:182739158 --> @ivanfilippov commented on GitHub (Feb 11, 2016): I'm not a Python wizard by any means, but I've created a pull request with my solution to this problem. Anyone else wanting to fix the issue before the pull request is accepted can make the code modification listed in the pull request (https://github.com/ngoduykhanh/PowerDNS-Admin/pull/7).
Author
Owner

@ngoduykhanh commented on GitHub (Feb 11, 2016):

Thanks @mortzu for raising this issue and @ivanfilippov for the pull request. I've tried the code in your pull request, it seems not working in all case yet. There was a case that I lose all duplicate records.

I also pushed a new change for fixing this bug, see commit c94e24c985

<!-- gh-comment-id:182787640 --> @ngoduykhanh commented on GitHub (Feb 11, 2016): Thanks @mortzu for raising this issue and @ivanfilippov for the pull request. I've tried the code in your pull request, it seems not working in all case yet. There was a case that I lose all duplicate records. I also pushed a new change for fixing this bug, see commit c94e24c98574da2595729547c9e41decce7ffa26
Author
Owner

@ivanfilippov commented on GitHub (Feb 11, 2016):

Your changes worked on my side, thanks @ngoduykhanh !

<!-- gh-comment-id:182939703 --> @ivanfilippov commented on GitHub (Feb 11, 2016): Your changes worked on my side, thanks @ngoduykhanh !
Author
Owner

@kushalkumar101 commented on GitHub (Jul 25, 2016):

I have added two MX records, If I try to add third MX record it will replace older records.

<!-- gh-comment-id:234861418 --> @kushalkumar101 commented on GitHub (Jul 25, 2016): I have added two MX records, If I try to add third MX record it will replace older records.
Author
Owner

@jon617 commented on GitHub (Jan 17, 2017):

I cannot get three MX records to add. Only the last one is stored.

{
  "rrsets": [
    { 
      "records": [
        { 
          "disabled": false,
          "content": "10 mailserver.com."
        }
      ],
      "changetype": "REPLACE",
      "ttl": 600,
      "type": "MX",
      "name": "me.com."
    },
    { 
      "records": [
        { 
          "disabled": false,
          "content": "20 mailserver2.com."
        }
      ],
      "changetype": "REPLACE",
      "ttl": 600,
      "type": "MX",
      "name": "me.com."
    },
    { 
      "records": [
        { 
          "disabled": false,
          "content": "30 mailserver3.com."
        }
      ],
      "changetype": "REPLACE",
      "ttl": 600,
      "type": "MX",
      "name": "me.com."
    },
}]

Only the last one is stored.

UPDATE I figured it out. Documentation was not that helpful in figuring this out, but I guessed to add all MX records in a single rrset element, and it worked:

  {
    "name": "me.com.",
    "type": "MX",
    "ttl": 600,
    "changetype": "REPLACE",
    "records": [
      { "content": "10 mailserver1.com.", "disabled": false },
      { "content": "20 mailserver2.com.", "disabled": false },
      { "content": "30 mailserver3.com.", "disabled": false }
    ]
  }

I assume the changetype "REPLACE" keys off of the "name" and "type" as its key. So if the name and type are the same (like multiple MX records, or I assume A and AAAA records too), put all under the single "records" array.

Most domains do have multiple MX records, and your documentation does not have any examples of this. You are welcome to add my above example MX record for your documentation.

<!-- gh-comment-id:273317486 --> @jon617 commented on GitHub (Jan 17, 2017): I cannot get three MX records to add. Only the last one is stored. { "rrsets": [ { "records": [ { "disabled": false, "content": "10 mailserver.com." } ], "changetype": "REPLACE", "ttl": 600, "type": "MX", "name": "me.com." }, { "records": [ { "disabled": false, "content": "20 mailserver2.com." } ], "changetype": "REPLACE", "ttl": 600, "type": "MX", "name": "me.com." }, { "records": [ { "disabled": false, "content": "30 mailserver3.com." } ], "changetype": "REPLACE", "ttl": 600, "type": "MX", "name": "me.com." }, }] Only the last one is stored. **UPDATE** I figured it out. Documentation was not that helpful in figuring this out, but I guessed to add all MX records in a single rrset element, and it worked: { "name": "me.com.", "type": "MX", "ttl": 600, "changetype": "REPLACE", "records": [ { "content": "10 mailserver1.com.", "disabled": false }, { "content": "20 mailserver2.com.", "disabled": false }, { "content": "30 mailserver3.com.", "disabled": false } ] } I assume the changetype "REPLACE" keys off of the "name" and "type" as its key. So if the **name** and **type** are the same (like multiple MX records, or I assume A and AAAA records too), put all under the single "records" array. Most domains do have multiple MX records, and your documentation does not have any examples of this. You are welcome to add my above example MX record for your documentation.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/PowerDNS-Admin-PowerDNS-Admin#5
No description provided.