forked from PowerDNS/pdns
-
Notifications
You must be signed in to change notification settings - Fork 3
Example configuration
Nick Saika edited this page Oct 17, 2017
·
9 revisions
Save this config file somewhere as dnsdist.conf
, then run with:
./dnsdist --config /path/to/dnsdist.conf
-- Set the local listening address.
setLocal("127.0.0.1:5300")
newServer({address="8.8.8.8"})
newServer({address="8.8.4.4"})
-- Create a named cache, and bind it to a CDB file that can keep up to 2 million
-- entries in its in-memory cache.
getNamedCache("block"):bindToCDB("/path/to/blacklist.cdb")
-- Define a function that checks the "block" named cache.
--
-- As with any other Lua rule-type function, its lone argument is a DNSQuestion table.
function checkNamedCache(dq)
local result = getNamedCache("block"):lookupQ(dq)
for k, v in pairs(result) do
print(k, v)
end
if result.found then
-- If there is an entry found in the "block" named cache, do not let later rules
-- process the request, and return an NXDomain response.
return DNSAction.Nxdomain, ""
end
-- There was no match in the named cache; allow rule processing to continue.
return DNSAction.None, ""
end
--
-- Rules
--
-- Add a rule to call the checkNamedCache function, for each request.
addLuaAction(AllRule(), checkNamedCache)