]> granicus.if.org Git - pdns/commitdiff
netflix messing with your IPv6? This script has you covered.
authorbert hubert <bert.hubert@netherlabs.nl>
Sun, 5 Jun 2016 08:30:05 +0000 (10:30 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Sun, 5 Jun 2016 08:30:05 +0000 (10:30 +0200)
pdns/recursordist/examples/strip-ipv6-from-domains.lua [new file with mode: 0644]

diff --git a/pdns/recursordist/examples/strip-ipv6-from-domains.lua b/pdns/recursordist/examples/strip-ipv6-from-domains.lua
new file mode 100644 (file)
index 0000000..f49f15f
--- /dev/null
@@ -0,0 +1,39 @@
+--[[ 
+       Sometimes, domains break when IPv6 is used. A common example is
+       Netflix via an IPv6 tunnel, which Netflix interprets as a proxying 
+       attempt.
+       
+       This function strips IPv6 from one or more subdomains. It can be called
+       with a single domain, like "netflix.com", or with a domain set, which
+       is more efficient and scales very well.
+       
+       This file is meant for including, so you can call it from your preresolve.
+       Alternatively, uncomment the activation code below and you can load it
+       directly into your resolver with 'lua-dns-script=strip-ipv6-from-domains.lua'.
+]]--
+
+function preventIPv6ForDomains(dq, domain)
+       local ds=newDS()
+       if(type(domain) == "string") then
+               ds:add{domain}
+       else
+               ds=domain
+       end
+       if(dq.qtype ~= pdns.AAAA) then return false end
+       if(ds:check(dq.qname)) then
+               dq.rcode = 0
+               return true
+       end
+       return false
+end
+
+-- To activate, uncomment the block below:
+
+--[[
+netflix=newDS()
+netflix:add{"netflix.com"}
+
+function preresolve(dq)
+       return preventIPv6ForDomains(dq, "netflix.com")
+end
+]]--
\ No newline at end of file