Hi,

I am using powerdns recursor 4.8.2 and the lua version is Lua 5.1.4

Am trying to achieve the function  to block a list of domains via the below lua 
script and then redirect the request to a local block page

-- Define new Domain Set
 blocked_domains=newDS()
-- Load Domain Set from the file. Format of the file is: 'return {"a.com", 
"b.com", "a.fb.com"}'
 blocked_domains:add(dofile("/etc/pdns-recursor/full_list_13-11-2019.lua"))
-- blocked_domains:add(dofile("/etc/pdns-recursor/blocked_domains.txt"))
-- define a preresolve() function which gets called by PowerDNS to determine 
what to do with a domain
 function preresolve(dq)
  -- If we see that a query name is not part of one of the blocked domains,
         -- or the query is not for an IP(v6) address, we return false and the 
normal resolution process continues.
             if(not blocked_domains:check(dq.qname) or (dq.qtype ~= pdns.A and 
dq.qtype ~= pdns.AAAA)) then
                     return false

                        else

  dq:addAnswer(pdns.A, "192.168.8.48")
return true
end
   end

The thing is that this script only blocks and redirect the user if the site is 
an http domain, if its a https domain no block page is displayed though the 
site does not open

how do i improve the script so that the domain is blocked and redirected to the 
block page even if its a https site, some where on the internet it refered to 
set the code to nxdomain and  then redirect the request to the block page but i 
cant get the code right, some help will be much appreciated.


also currently I have redirected the block page to the IP "192.168.8.48" can i 
also get the code to redirect to a domain name instead of an IP address?

Thanks you

Regards,
Clifford Dsouza

Regards,
Clifford




NOTICE: This message contains privileged and confidential information intended 
only for the use of the addressee named above. If you are not the intended 
recipient of this message you are hereby notified that you must not 
disseminate, copy or take any action in reliance on it. If you have received 
this message in error please notify Microscan Infocommtech Pvt. Ltd. 
immediately. Any views expressed in this message are those of the individual 
sender, except where the sender has the authority to issue and specifically 
states them. Tel - 022-66870600 Fax - 022-66870800
_______________________________________________
Pdns-users mailing list
Pdns-users@mailman.powerdns.com
https://mailman.powerdns.com/mailman/listinfo/pdns-users

Reply via email to