-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Hi!
Not quite sure if this is a bug or feature request.
Describe the bug
There is a difference between inet_res and the native resolver regarding search domains.
Let's assume the resolv.conf file has a search domain defined: "search e", and we're querying a single-segment name.
The native resolver will first attempt a query for the name without a domain, then with the domain.
inet_res will only try queries with the domains.
To Reproduce
This matters when running inside a Docker container.
For example, let's say the host machine has "search e" in its resolv.conf. Docker will copy this into the container.
docker-compose.yml:
services:
db:
image: debian:13
command: ["/bin/bash", "-c", "sleep 1d"]
server:
image: erlang:28
command: ["/bin/bash", "-c", "sleep 1d"]
root@fbae68c3d16b:/# grep search /etc/resolv.conf
search e
root@fbae68c3d16b:/# echo '{lookup,[dns]}.' > /inetrc
root@fbae68c3d16b:/# ERL_INETRC=/inetrc erl
1> inet_db:get_rc().
[{nameservers,{127,0,0,11}},
{search,["e"]},
{dnssec_ok,undefined},
{resolv_conf,"/etc/resolv.conf"},
{hosts_file,"/etc/hosts"},
{lookup,[dns]}]
2> inet:gethostbyname("db").
{error,nxdomain}
3> inet_gethost_native:gethostbyname("db").
{ok,{hostent,"db",[],inet,4,[{172,18,0,2}]}}
In this example host and container OS version: debian 13 / x86_64
Expected behavior
inet_res will response with IP address.
Affected versions
I checked 27 and 28.
Additional context
I haven't been able to find a satisfactory workaround for this issue. For our tasks, we require inet_res. The search in resolv.conf is real.
Docker does not allow adding a dot "." to the search list: there's no way to add it, you can only define the entire list, and it ignores the dot in dns-search.
Adding a dot to inetrc or via inet_db:add_search/1 also doesn't work – inet_db reads resolv.conf and removes the dot, leaving only ["e"].