[dnsdist] How to modify the DNS response from an upstream server?

Remi Gacogne remi.gacogne at powerdns.com
Tue Oct 13 15:34:35 UTC 2020


Hi Aleksey,

On 10/12/20 1:09 PM, Aleksey Chudov via dnsdist wrote:
> Is there a way to modify the DNS response from an upstream server? I
> especially want to add the RA flag (for testing purposes) if the RD flag
> is set. If this is not possible, I can change the source code. Please
> lead me to the right place in the source code where it is more appropriate.

There is very limited support for editing the content of responses from
dnsdist, but luckily you should be able to do what you want using a bit
of Lua:

function responseHandlerSetRA(dr)
  dr.dh:setRA(true)
  return DNSResponseAction.HeaderModify, ""
end

This code declares a Lua function that will set the RA bit to true, and
return a value indicating that the header has been modified. This
function can be passed to LuaResponseAction so it will be executed for
selected responses. The example below uses the AllRule() selector that
will apply it to all responses, but you could of course use a different
selector:

addResponseAction(AllRule(), LuaResponseAction(responseHandlerSetRA))

Hope that helps,
-- 
Remi Gacogne
PowerDNS.COM BV - https://www.powerdns.com/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.powerdns.com/pipermail/dnsdist/attachments/20201013/bbb2472b/attachment.sig>


More information about the dnsdist mailing list