I have a pretty simple use case - I'm are doing 1:1 NAT for a /16 and need to manipulate A and PTR records to make sure DNS aligns with NAT.
Modifying A records was easy with Lua & powerdns recursor, however PTR is causing some issues.
I’m using this code:
if (dq.qtype ==pdns.PTR and endswith(dq.qname:toString(),".232.10.in-addr.arpa."))
print("PTR mapping for "..dq.qname:toString())
local newptr=string.gsub(dq.qname:toString(), ".232.10.i", ".51.10.i")
dq.rcode = 0
dq:addAnswer(pdns.TXT, "\"Source PTR "..newptr.."\"", 3600)
So basically if we do a DNS lookup for 10.232.x.y it returns the PTR for 10.51.x.y - Simple right?
The issue is that powerdns returns both the CNAME and the PTR, so our upstream DNS server ends up with y.x.15.10.in-addr.arpa in it’s cache which conflicts with other 10.51/16 records (which is why we're doing NAT in the first place).
;; ANSWER SECTION:
22.214.171.124.in-addr.arpa. 3590 IN CNAME 126.96.36.199.in-addr.arpa.
188.8.131.52.in-addr.arpa. 1190 IN PTR server.domain.com.
184.108.40.206.in-addr.arpa. 3590 IN TXT "Source PTR 220.127.116.11.in-addr.arpa."
Is there an easy way to get PowerDNS to just return the PTR record, or can I do a query for the 10.51.x.y PTR inside Lua and just respond with that record?
If there is a better way to accomplish what I’m intending, I’m open to suggestions!