ruby / ruby/resolv

Resolv cannot resolve address if `resolv.conf` first `nameserver` answers with `SERVFAIL`

Open
#23 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
56
Forks
41
Avg merge
2h 38m
Merged PRs (30d)
7

Description

in a docker container environment my containers get created with the following resolv.conf

nameserver 172.24.160.1
nameserver 10.81.32.106
nameserver 10.81.32.104

the first one is the gateway machine which cannot resolve any internet names.

nslookup and ping are able to resolve address:

# nslookup google.com
;; Got SERVFAIL reply from 172.24.160.1, trying next server
Server:         10.81.32.106
Address:        10.81.32.106#53

Non-authoritative answer:
Name:   google.com
Address: 142.250.185.206
;; Got SERVFAIL reply from 172.24.160.1, trying next server
Name:   google.com
Address: 2607:f8b0:4006:80e::200e

# ping google.com
PING google.com (142.250.65.174) 56(84) bytes of data.

but resolv fails:

irb(main):001:0> require 'resolv'
=> true
irb(main):002:0> Resolv.getaddresses "google.com"
=> []
irb(main):003:0> Resolv.getaddress "google.com"
Traceback (most recent call last):
        21: from ./.bundle/bin/irb:27:in `<main>'
        20: from ./.bundle/bin/irb:27:in `load'
        19: from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
         2: from (irb):3:in `<main>'
         1: from /usr/local/lib/ruby/2.7.0/resolv.rb:44:in `getaddress'
/usr/local/lib/ruby/2.7.0/resolv.rb:94:in `getaddress': no address for google.com (Resolv::ResolvError)
irb(main):002:0> Resolv::DNS.new(:nameserver => ['10.81.32.104', '10.81.32.106'] ).getaddress "google.com"
=> #<Resolv::IPv4 142.250.65.174>
irb(main):003:0> Resolv::DNS.new(:nameserver => ['172.24.160.1', '10.81.32.104', '10.81.32.106'] ).getaddress "google.com"
Traceback (most recent call last):
        20: from ./.bundle/bin/irb:27:in `<main>'
        19: from ./.bundle/bin/irb:27:in `load'
        18: from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
         1: from (irb):3:in `<main>'
/usr/local/lib/ruby/2.7.0/resolv.rb:379:in `getaddress': DNS result has no information for google.com (Resolv::ResolvError)

and it is also working if i remove the first nameserver in resolv.conf

#nameserver 172.24.160.1
nameserver 10.81.32.106
nameserver 10.81.32.104

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in /usr/local/lib/ruby/2.7.0/resolv.rb, focusing on DNS resolution with multiple nameservers and the handling of a SERVFAIL response. Reproduce the issue using the nameserver order shown in the report, then verify that resolution continues to a later server and succeeds for google.com.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.