<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">On 30 Oct 2024, at 07:30, Otto Moerbeek <otto@drijf.net> wrote:<br><div><blockquote type="cite"><br class="Apple-interchange-newline"><div><div>On Tue, Oct 29, 2024 at 10:14:29PM +0000, Djerk Geurts via Pdns-users wrote:<br><br><blockquote type="cite">Hi all,<br><br>Is there a way to return NXDOMAIn instead of a valid response?<br><br>test IN LUA CNAME "view({{{'10.0.0.0/16'},{‘ns0.internal.domain.com.'}},{{'0.0.0.0/0'},{''}}})”<br><br>I would like to return NXDOMAIN instead of SERVFAIL for sources outside 10.0/16.<br><br>Thanks,<br>Djerk Geurts<br></blockquote><br>I don't think NXDOMAIN responses are possible from Lua records.<br></div></div></blockquote><div><br></div>I saw a request on GitHub for this from a while ago, so if it could be added, that would be great.</div><div><br><blockquote type="cite"><div><div>I guess a NODATA (rcode NOERROR + empty answer section) is the closest you<br>can come.<br><br>views do not like empty response sets, but this worked for me to get a<br>a NODATA:<br><br>test.example 10 IN LUA A "; if (0==1) then return {'1.2.3.4'} else return {} end"<br><br>Maybe you can work from this.<br><br><span class="Apple-tab-span" style="white-space:pre"> </span>-Otto<br></div></div></blockquote></div><br><div>That’s helpful, but I’ll need to work out how to combine the two. `view()` takes all text literally so `return{}` doesn’t yield NODATA.</div><div><br></div><div>Equally I don’t know how to test for a source address in the if statement. <a href="https://doc.powerdns.com/authoritative/lua-records/">https://doc.powerdns.com/authoritative/lua-records/</a> only gives examples for `if(continent`, but this article has some interesting LUA records: https://blog.powerdns.com/2017/12/15/powerdns-authoritative-lua-records</div><div><br></div><div>I tried this, but it’s not working:</div><div><br></div><div>"if(netmask({'10.0.0.0/16'})) then return {’true.domain.com.'} else return {‘false.domain.com'} end"</div></body></html>