~samiam/MaraDNS

22d6af736567c329714cbfe04e72789548adc781 — Sam Trenholme a month ago fa78ecf 3.5.0019
3.5.0019: Add IP synthesizer to Windows coLunacyDNS docs
2 files changed, 30 insertions(+), 0 deletions(-)

M CHANGELOG
M maradns-win32/coLunacyDNS.txt
M CHANGELOG => CHANGELOG +2 -0
@@ 4,6 4,8 @@ MaraDNS changelog
   This is a stable release of MaraDNS:

     * One line change to zoneserver.c to make it work better with systemd
     * Synthetic IP generator example (e.g. 10.1.2.3.ip4.internal 
       resolves to 10.1.2.3) added to coLunacyDNS documentation

     (2021-03-16)


M maradns-win32/coLunacyDNS.txt => maradns-win32/coLunacyDNS.txt +28 -0
@@ 100,6 100,34 @@ function processQuery(Q) -- Called for every DNS query received
end
--------------------------------------------------------------------------

Here is an example where we can synthesize any IP given to us:
--------------------------------------------------------------------------
-- This script takes a query like 10.1.2.3.ip4.internal. and returns the
-- corresponding IP (e.g. 10.1.2.3 here)
-- We use "internal" because this is the fourth-most commonly used
-- bogus TLD (#1 is "local", #2 is "home", and #3 is "dhcp")

-- Change this is a different top level domain as desired.  So, if this
-- becomes "test", the this configuration script will resolve 
-- "10.1.2.3.ip4.test." names to their IP.
TLD="internal"
-- Change these IPs to the actual IPs the DNS server will run on
bindIp = "127.0.0.1" -- We bind the server to the IP 127.0.0.1
bindIp6 = "::1" -- Localhost for IPv6

function processQuery(Q) -- Called for every DNS query received
  if Q.coQtype == 1 then
    local query = Q.coQuery
    if query:match("^%d+%.%d+%.%d+%.%d+%.ip4%." .. TLD .. "%.$") then
      local ip = query:gsub("%.ip4%." .. TLD .. "%.$","")
      return {co1Type = "A", co1Data = ip}
    end
  else
    return {co1Type = "notThere"}
  end
  return {co1Type = "notThere"}
end
--------------------------------------------------------------------------

Here is a more complicated example:
--------------------------------------------------------------------------