Created
April 15, 2016 08:27
-
-
Save ahupowerdns/d659c0b24704a8960aba7b4b71de38b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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