Sha256: 4f9230b28174a638d8893e2a2f07661eda0bdc779ce1e30fc08984b057e93764

Contents?: true

Size: 772 Bytes

Versions: 9

Compression:

Stored size: 772 Bytes

Contents

module Landrush
  module Cap
    module Linux
      module RedirectDns
        def self.redirect_dns(machine, target={})
          dns_servers = machine.guest.capability(:configured_dns_servers)
          %w[tcp udp].each do |proto|
            dns_servers.each do |dns_server|
              machine.guest.capability(
                :add_iptables_rule,
                _redirect_dns_rule(proto, dns_server, target.fetch(:host), target.fetch(:port))
              )
            end
          end
        end

        def self._redirect_dns_rule(protocol, original_server, target_server, target_port)
          "OUTPUT -t nat -p #{protocol} -d #{original_server} --dport 53 -j DNAT --to-destination #{target_server}:#{target_port}"
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
landrush-0.19.0 lib/landrush/cap/linux/redirect_dns.rb
landrush-0.18.0 lib/landrush/cap/linux/redirect_dns.rb
landrush-0.17.0 lib/landrush/cap/linux/redirect_dns.rb
landrush-0.16.0 lib/landrush/cap/linux/redirect_dns.rb
landrush-0.15.4 lib/landrush/cap/linux/redirect_dns.rb
landrush-0.15.3 lib/landrush/cap/linux/redirect_dns.rb
landrush-0.15.2 lib/landrush/cap/linux/redirect_dns.rb
landrush-0.15.1 lib/landrush/cap/linux/redirect_dns.rb
landrush-0.15.0 lib/landrush/cap/linux/redirect_dns.rb