Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rDNS might not work on latest macos #166

Closed
richstokes opened this issue Apr 15, 2020 · 18 comments
Closed

rDNS might not work on latest macos #166

richstokes opened this issue Apr 15, 2020 · 18 comments
Labels
bug Something isn't working discussion

Comments

@richstokes
Copy link

sudo bandwhich                                                            
Password:
Error: Could not initialize the DNS resolver. Are you offline?
bandwhich                                                                         
Error:

 lo0: No such file or directory (os error 2)
 en5: No such file or directory (os error 2)
 en0: No such file or directory (os error 2)
 awdl0: No such file or directory (os error 2)
 llw0: No such file or directory (os error 2)
 utun0: No such file or directory (os error 2)
 utun1: No such file or directory (os error 2)
 utun2: No such file or directory (os error 2)
 utun3: No such file or directory (os error 2)
uname -a                                                                                    
Darwin RMBP.local 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar  4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64
bandwhich -V                                                                     
bandwhich 0.13.0

Installed via homebrew

@imsnif
Copy link
Owner

imsnif commented Apr 16, 2020

Hey, thanks for reporting this. That's quite odd.
Would you mind helping me out with a little bit of debugging to find the issue? (I don't have access to a mac)

If you run bandwhich with the -n flag like this sudo bandwhich -n does it work? Do you see traffic? (This turns off the reverse DNS resolution, which is what's failing here).

@richstokes
Copy link
Author

That works!

@imsnif
Copy link
Owner

imsnif commented Apr 19, 2020

Hey @richstokes, so if you use the same terminal window from which you run bandwhich (when it doesn't work, without the -n flag) in order to do a ping github.com, does it work for you?
This error essentially means that bandwhich failed to contact your DNS server, and I'm wondering why?

@imsnif imsnif changed the title Doesnt work on latest MacOS rDNS might not work on latest macos Apr 19, 2020
@imsnif imsnif added bug Something isn't working discussion labels Apr 19, 2020
@richstokes
Copy link
Author

Yep, DNS works fine for other apps;

sudo bandwhich                                      
Password:
Error: Could not initialize the DNS resolver. Are you offline?

nslookup google.com                                       
Server:		9.9.9.9
Address:	9.9.9.9#53

Non-authoritative answer:
Name:	google.com
Address: 172.217.0.46

@imsnif
Copy link
Owner

imsnif commented Apr 20, 2020

Hum... just for debugging, would you be willing to try setting your dns server to 1.1.1.1 and seeing if it works out (with both bandwhich and nslookup)?

@richstokes
Copy link
Author

Sure. Switched DNS to 1.1.1.1, cleared cache, retried, same error.

@imsnif
Copy link
Owner

imsnif commented Apr 20, 2020

Thanks! I'd like to give you a debug branch that'll give us a more verbose error in this case with a quick hack. Would you be comfortable running such a branch from this repo? I can provide some instructions if you're unfamiliar with rust.

@richstokes
Copy link
Author

Can do when I have a few moments spare - not used Rust so would need info on how to compile/run

@DianaNites
Copy link

Same error here on Arch Linux, Could not initialize the DNS resolver, using systemd-resolved and googles DNS, 8.8.8.8, the -n flag works tho.

@Ma27
Copy link
Contributor

Ma27 commented Sep 11, 2020

@richstokes @DianaNites any chance you're running systemd-networkd at v246? It seems as the resolv-conf doesn't support the trust-ad option in /etc/resolv.conf at version 0.6.2 (which is the one we're using here).

The problem gets fixed on master (hickory-dns/resolv-conf@83c0f25), so it should be possible to fix this issue by updating the resolv-conf crate to this revision.

I stumbled upon this issue after my latest OS update (which included systemd-246) which uses options trust-ad in their /etc/resolv.conf-stub for resolvectl. See systemd/systemd@a742f98.

@imsnif I only confirmed that resolv-conf master fixes the issue. I'll try to fix the dependency for bandwhich and open a PR then :)

Ma27 added a commit to Ma27/bandwhich that referenced this issue Sep 11, 2020
This fixes the parsing of `/etc/resolv.conf` with `options trust-ad`
which is e.g. used in `systemd-resolved-v246`[1].

Refs imsnif#166

[1] systemd/systemd@a742f98
Ma27 added a commit to NixOS/nixpkgs that referenced this issue Sep 11, 2020
ChangeLogs:

* https://github.com/imsnif/bandwhich/releases/tag/0.18.1
* https://github.com/imsnif/bandwhich/releases/tag/0.18.0

Also applied a fix[1] for rDNS support which broke with `systemd-v246`
because the `resolv-conf` crate didn't support the `options
trust_ad`-declaration in systemd's `/etc/resolv.conf`[2].

[1] imsnif/bandwhich#184
[2] imsnif/bandwhich#166 (comment)
Ma27 added a commit to NixOS/nixpkgs that referenced this issue Sep 11, 2020
ChangeLogs:

* https://github.com/imsnif/bandwhich/releases/tag/0.18.1
* https://github.com/imsnif/bandwhich/releases/tag/0.18.0

Also applied a fix[1] for rDNS support which broke with `systemd-v246`
because the `resolv-conf` crate didn't support the `options
trust_ad`-declaration in systemd's `/etc/resolv.conf`[2].

[1] imsnif/bandwhich#184
[2] imsnif/bandwhich#166 (comment)

(cherry picked from commit 8149ab1)
@imsnif
Copy link
Owner

imsnif commented Sep 11, 2020

Thanks very much for finding this @Ma27, and for the quick fix. My apologies for not finding the time for debugging this myself.

@Ma27
Copy link
Contributor

Ma27 commented Sep 11, 2020

Hmm I'm actually realizing now that the reporter has the issue on macos, so I don't if they have the same issue. However my patch fixes the issue for me.

Ma27 added a commit to Ma27/bandwhich that referenced this issue Sep 11, 2020
This fixes the parsing of `/etc/resolv.conf` with `options trust-ad`
which is e.g. used in `systemd-resolved-v246`[1].

Refs imsnif#166

[1] systemd/systemd@a742f98
@imsnif
Copy link
Owner

imsnif commented Sep 11, 2020

At the very least we'll get clearer errors after your patch on this.

imsnif pushed a commit that referenced this issue Sep 11, 2020
…conf` crate (#184)

* Show the error cause if initializing a DNS resolver fails

* Manually bump `resolv-conf` to `master` at rev `83c0f25`

This fixes the parsing of `/etc/resolv.conf` with `options trust-ad`
which is e.g. used in `systemd-resolved-v246`[1].

Refs #166

[1] systemd/systemd@a742f98
@black-puppydog
Copy link

FWIW I was seeing this on an ubuntu install (rolling rhino, thieir kinda rolling release) and installing from git with the patch for resolv.conf actually did fix it for me

@DianaNites
Copy link

DianaNites commented Sep 29, 2020

@Ma27 I'm on Arch Linux, which indeed uses systemd-networkd 246.

The latest bandwhich version, 0.19.0, does not fix it for me, though the error is now more detailed.

Error: Could not initialize the DNS resolver. Are you offline?

Reason: ResolveError { inner: Custom { kind: Other, error: "Error parsing resolv.conf: InvalidOption(17)" }

io error }

/etc/resolv.conf looks like this

nameserver 127.0.0.53
options edns0 trust-ad

@imsnif
Copy link
Owner

imsnif commented Oct 1, 2020

Hey @DianaNites (and others experiencing this issue),

I added a feature that would allow users to explicitly specify a dns server to use for the rDNS lookups as a workaround. Something like bandwhich --dns-server 1.1.1.1

I'm going to release a new version with it in the next few days (I'm waiting on another fix I'd like to see in that version too). Thanks for your patience. :)

@imsnif
Copy link
Owner

imsnif commented Oct 15, 2020

New version released. Starting from version 0.20.0, you can now use the --dns-server flag eg. bandwhich -d 1.1.1.1 to manually specify a DNS server as a workaround for this issue.

@cyqsimon
Copy link
Collaborator

Closing this issue as completed. If you disagree please comment/reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working discussion
Projects
None yet
Development

No branches or pull requests

6 participants