Created
April 17, 2012 20:02
-
-
Save xergio/2408644 to your computer and use it in GitHub Desktop.
DNS for development purposes
This file contains 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 characters
#!/usr/bin/env ruby | |
# git clone https://github.com/ioquatix/rubydns | |
require 'rubygems' | |
require 'rubydns' | |
$R = Resolv::DNS.new | |
$H = Resolv::Hosts.new | |
Name = Resolv::DNS::Name | |
RubyDNS::run_server do | |
match(/^cms\-[a-z0-9]+\..*$/, :A) do |match_data, transaction| | |
begin | |
transaction.respond!($H.getaddress(transaction.name)) | |
logger.info "CMS en /etc/hosts: #{transaction.name}" | |
rescue | |
transaction.respond!("10.10.22.111") | |
logger.info "CMS: #{transaction.name}" | |
end | |
end | |
match(/^(?!lab\-)[a-z0-9]+\-[a-z0-9]+\.mediafusion\.es$/, :A) do |match_data, transaction| | |
begin | |
transaction.respond!($H.getaddress(transaction.name)) | |
logger.info "Generic en /etc/hosts: #{transaction.name}" | |
rescue | |
transaction.respond!("10.10.22.107") | |
logger.info "Generic: #{transaction.name}" | |
end | |
end | |
otherwise do |transaction| | |
begin | |
transaction.respond!($H.getaddress(transaction.name)) | |
logger.info "Unknown en /etc/hosts: #{transaction.name}" | |
rescue | |
logger.info "Unknown: #{transaction.name}" | |
transaction.passthrough!($R) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment