Skip to content

Instantly share code, notes, and snippets.

@icy
Created December 13, 2019 07:21
Show Gist options
  • Save icy/fb31929d14793efd17423f6d41095c82 to your computer and use it in GitHub Desktop.
Save icy/fb31929d14793efd17423f6d41095c82 to your computer and use it in GitHub Desktop.
my-dns-resolver.rb
#!/usr/bin/env ruby
require 'rubydns'
INTERFACES = [
[:udp, "0.0.0.0", 53],
[:tcp, "0.0.0.0", 53],
]
IN = Resolv::DNS::Resource::IN
UPSTREAM = RubyDNS::Resolver.new(
[
[:udp, "127.0.0.1", 52], # dnscrypt-prỏxy
[:tcp, "127.0.0.1", 52], # dnscrypt-proxy
#[:tcp, "8.8.8.8", 53],
#[:tcp, "1.1.1.1", 53],
#[:tcp, "10.24.35.42", 53],
## BVG
])
RubyDNS::run_server(INTERFACES) do
match("incoming.telemetry.mozilla.org") do |t|
t.respond!("127.0.0.1")
end
match(%r{kyanh.net}, IN::A) do |t|
my_ip = "192.168.192.168"
my_ip = "127.0.0.1"
STDERR.puts "client #{t.options[:remote_address].ip_address} asked #{t.question} got #{my_ip}"
t.respond!(my_ip)
end
otherwise do |t|
t.passthrough!(UPSTREAM)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment