1

I have code that performs DNS lookups using Ruby's built-in Resolve::DNS functionality and it works perfectly to resolve IP addresses to names (or any other type of applicable DNS lookup).

It is working against our internal nameservers, however occasionally I would like to see what external DNS is reporting.

In order to bounce an IP address up against Google's public DNS (8.8.8.8 / https://dns.google.com/), for example, I need to be able to make requests through our authenticated proxy.

I have tried setting http_proxy and HTTPS_PROXY at the command line (using known good syntax that works outside of Resolv::DNS. I have also tried specifically using ENV['http_proxy'] = 'http://username:password@hostname:port' (with both capitalization for the environment variable, of course).

Does anyone know how to make requests through a proxy with Resolv::DNS?

Please note that I have other code that depends on using Resolv::DNS so I am not looking for answers that attempt to leverage other Ruby gems/libraries for this task.

Here is my code that works when query internal DNS nameservers, but it will not work against Google DNS (it will just time out after a long period of time):

 dns = Resolv::DNS.new(:nameserver => '8.8.8.8')

 dns_ptr = dns.getnames('107.23.199.237') # logitech.com

 p dns_ptr

Expected Output:

[#<Resolv::DNS::Name: ec2-ip-address-and-name-of-logitech.com-in-aws.com.>]
Cœur
  • 37,241
  • 25
  • 195
  • 267
Kurt W
  • 321
  • 2
  • 15
  • Was anyone able to review this question? Thanks in advance! – Kurt W Jun 29 '16 at 14:48
  • Still hoping to find an answer here. Thanks! – Kurt W Jul 18 '16 at 20:54
  • Your example code worked for me: irb(main):001:0> require 'resolv' irb(main):002:0> dns=Resolv::DNS.new(:nameserver => '8.8.8.8') irb(main):003:0> dns_ptr = dns.getnames('107.23.199.237') irb(main):004:0> p dns_ptr [#] How is this different from what you are expecting? This is with Ruby 2.0.0p648 (2015-12-16) on Amazon Linux. Note that DNS doesn't really have the concept of "proxies", you are just providing an alternative resolver, in this case Google's public DNS. – opsmason Dec 19 '17 at 16:06

0 Answers0