DNS issue with pkgsMusl.curl in virtualbox

I was seeing a strange DNS error when trying to use a musl-compiled curl in Virtualbox. My host machine is NixOS 21.11 and my guess machine is also NixOS 21.11.

I was seeing the following problem. curl doesn’t appear able to resolve DNS names. I’m using 21.11 commit https://github.com/NixOS/nixpkgs/commit/573095944e7c1d58d30fc679c81af63668b54056:

$ nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/573095944e7c1d58d30fc679c81af63668b54056.tar.gz -p pkgsMusl.curl
$ curl google.com
curl: (6) Could not resolve host: google.com
$ curl -4 google.com  # forcing IPv4 also fails
curl: (6) Could not resolve host: google.com

I tried pkgsMusl.curl from 21.05 commit Merge pull request #150526 from Ma27/signald-cve-2021-44228-21.05 · NixOS/nixpkgs@c5f1ee9 · GitHub and that fails, but slightly differently:

$ nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/c5f1ee982246d09ae7f119c13aafcce90286221d.tar.gz -p pkgsMusl.curl
$ curl google.com
curl: (6) Could not resolve host: google.com
$ curl -4 google.com  # forcing IPv4 succeeds
<html>...

I was able to workaround this problem by going into my VirtualBox settings and changing the network adapter on my guest from Intel PRO/1000 MT Desktop (82540EM) to PCnet-FAST III (Am79C973). I’m not sure why this works (but it appears that DNS is handled slightly differently between the two adapters). I have no problems with curl after changing the network adapter.

Also, I have no problems with glibc-linked curl with either Intel PRO/1000 MT Desktop (82540EM) or PCnet-FAST III (Am79C973).

I’ve found a couple issues that have been reported with similar symptoms, but nothing that exactly says why one VirtualBox network adapter works, and another doesn’t:

My VirtualBox version is 6.1.28 r147628. My host is on NixOS-21.11 at commit Merge pull request #149370 from NixOS/backport-149318-to-release-21.11 · NixOS/nixpkgs@1bd4bbd · GitHub.

What do more standard dns diagnostic tools give your like good old dig, nslookup, tcpdump might actually give you some value, especially if the virtual box emulated driver is mangling packets/frames in some way.

at first look i thought it may be virtual bridging/NAT that Virtual Box sets up, but it works with an older emulated driver. Interesting. Have a check for hardware tcp checksum offloading or Interrupt Coalesce .

also run some ip/ifconfig check for to see if software allocated mac address are not garbage/mangled or colliding with your default gateway.

I assume everything else works apart from dns?

Virtualbox does all kinds bizzare network tricks to get hosts to ‘pretend’… perhaps something doesn’t like a dns proxy that virtual box may be using.

do you get a peep out dmesg or the system journal/logs at all? Might also good to check logs that virtualbox itself spits out from time to time, they have saved me from time to time.

Apart from that, an interesting problem! Some dark magic deep with in the resolver libs and musl/kernel might be at fault! Watching this with interest.

1 Like

okay, i’ve gave it test, virtualbox host on 21.05 , and using a 21.11 iso from a live disc.

DNS works fine in pkgsMusl.curl

mainly defaults set in virutalbox.

so i can’t reproduce the problem right now.

you not backed onto WIFI on the host are you, that causes all sorts of peculiar bridging problems, wifi drivers are not particularly good at L2 bridging , even if your not using virtualisation (LOL).

the channel is
nixos-21.11.334247.573095944e7

on kernel 5.10.81

the mystery continues.

did you managed to get anywhere with this?

Sorry, I didn’t manage to follow-up with this yet. It is disruptive for me to restart my VM (since I have to close all my open editors and nix shells), so I try to do it a little as possible.

However, if I find some time I do intend to dig into this a little more. A bunch of your debugging ideas sound really good.

you not backed onto WIFI on the host are you, that causes all sorts of peculiar bridging problems, wifi drivers are not particularly good at L2 bridging , even if your not using virtualisation

I imagine this is probably the actual problem. I’m on a laptop and my host is connected over wifi.

The host is a Lemur Pro 10 from System 76: Lemur Pro - System76

1 Like