Skip to content

Instantly share code, notes, and snippets.

@strzibny
Created December 8, 2015 18:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strzibny/634de660ae7dd04fbb1e to your computer and use it in GitHub Desktop.
Save strzibny/634de660ae7dd04fbb1e to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubydns'
INTERFACES = [
[:udp, "0.0.0.0", 53],
[:tcp, "0.0.0.0", 53]
]
Name = Resolv::DNS::Name
IN = Resolv::DNS::Resource::IN
# Use upstream DNS for name resolution.
UPSTREAM = RubyDNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])
LANDRUSH = RubyDNS::Resolver.new([[:udp, "127.0.0.1", 10053], [:tcp, "127.0.0.1", 10053]])
# Start the RubyDNS server
RubyDNS::run_server(:listen => INTERFACES) do
match(/\.vm/, IN::A) do |transaction|
transaction.passthrough!(LANDRUSH)
end
# Default DNS handler
otherwise do |transaction|
transaction.passthrough!(UPSTREAM)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment