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
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:
- musl-1.2.1-r0 and/or busybox-1.32.0-r2 breaks nslookup return value (#11879) · Issues · alpine / aports
- Alpine edge DNS issues in D4M but not on Linux host. · Issue #5020 · docker/for-mac · GitHub
- centos - Why am I getting "Curl (6) Could not resolve host" after I did a "yum -y update"? - Unix & Linux Stack Exchange
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.