Skip to content

Instantly share code, notes, and snippets.

@astro
Created February 12, 2009 02:34
Show Gist options
  • Save astro/62454 to your computer and use it in GitHub Desktop.
Save astro/62454 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
HOSTS = %w(hummer astrom dn42 ldap wiefelspuetz astron icq www1 zardoz jabber1 debcache jabber2 unsafe dhcp kdc utur).map{ |s| "#{s}.hq.c3d2.de" }
=begin
Forward-resolves HOSTS and puts their IPv6 addresses suitable for BIND
reverse-lookup zonefiles.
=end
require 'resolv'
Resolv::DNS.open do |dns|
HOSTS.each do |host|
host += '.' unless host =~ /\.$/
ress = dns.getresources host, Resolv::DNS::Resource::IN::AAAA
ress.each { |r|
addr = r.address.to_s
if `sipcalc -r #{addr}` =~ /^(.+?\.ip6\.arpa\.)$/
puts "#{$1}\tIN PTR\t#{host}"
end
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment