Created
May 1, 2013 17:47
Revisions
-
hamstar created this gist
May 1, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ #!/usr/bin/env ruby require 'rubygems' require 'rubydns' $R = Resolv::DNS.new Name = Resolv::DNS::Name IN = Resolv::DNS::Resource::IN Hosts = "/etc/dnsserv/hosts" RubyDNS::run_server(:listen => [[:udp, "0.0.0.0", 5300]]) do # For this exact address record, return an IP address match(/.*/) do |transaction| line = `grep "#{transaction.name}" #{Hosts}`.split("\n").first transaction.passthrough!($R) if $?.exitstatus != 0 ip = line.split("\t").first transaction.respond!(ip) end # Default DNS handler otherwise do |transaction| transaction.passthrough!($R) end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ 10.0.0.80 dev.test.org 8.8.8.8 dns.gg.com