This file contains 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
-- load this and the previous snippet as 'lua-dns-script=macfilter.lua' | |
function macPrint(a) | |
return string.format("%02x:%02x:%02x:%02x:%02x:%02x", a:byte(1), a:byte(2), a:byte(3), a:byte(4), a:byte(5), a:byte(6)) | |
end | |
function preresolve(dq) | |
print("Got question for "..dq.qname:toString().." from "..dq.remoteaddr:toString().." to "..dq.localaddr:toString()) | |
local a=dq:getEDNSOption(65001) | |
if(a ~= nil) then | |
print("There is an EDNS option 65001 present: "..macPrint(a)) | |
if(filter[dq.remoteaddr:toString()][macPrint(a)] and baddomains:check(dq.qname)) then | |
print("Wanted filtering") | |
dq:addAnswer(pdns.CNAME, "blockingserver.powerdns.com") | |
return true | |
end | |
-- an obvious enhancement is to implement a 'default' mac address describing the default | |
-- filtering an IP address wants | |
end | |
return false | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I'm a PowerDNS newbie, and after many time of work on your script I realize that there is missing code after
dq:addAnswer(pdns.CNAME, "blockingserver.powerdns.com")
Maybe 2 lines of code must be inserted
Please, tell me if this is correct or no.
Regards
Pasquale