Skip to content

Instantly share code, notes, and snippets.

@ahupowerdns
Created April 15, 2016 08:27
Show Gist options
  • Save ahupowerdns/d659c0b24704a8960aba7b4b71de38b7 to your computer and use it in GitHub Desktop.
Save ahupowerdns/d659c0b24704a8960aba7b4b71de38b7 to your computer and use it in GitHub Desktop.
malwareips=newNMG()
malwareips:addMasks(dofile("blacklist.ip"))
function postresolve(dq)
-- print("postresolve called for ",dq.qname:toString())
local records = dq:getRecords()
local changed = false
for k,v in pairs(records) do
if v.type == pdns.A or v.type == pdns.AAAA
then
addr=v:getCA()
if malwareips:match(addr)
then
print("filter addr=", addr:toStringWithPort())
if v.type == pdns.A
then
v:changeContent("127.0.0.1")
else
v:changeContent("::1")
end
v.ttl=1
changed = true
end
end
end
if changed
then
dq:setRecords(records)
end
return true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment