How can I specify DNS Resolver as environment variable or command line argument
*Describe the feature you'd like
As the title, because cloudflared uses go dns resolver, it looks for /etc/resolv.conf (for linux binaries) when try to resolve domains - which not the case on Android systems.
If it doen't find that file, it sets the default name server to localhost:53
https://github.com/golang/go/blob/e335a2665f5e322a7da8baa22fe816b6ef9aaf24/src/net/dnsconfig.go#L14
Which cause problems as here:
There's a few possible solutions:
- On rooted Android phone, we could just create the
/etc/resolv.conffile - Another way is to add a static entry to
/etc/hostsfor our domainns - Building a non-staticly linked version
cloudflared. If we build a binary linked to libc it will use that to do name resolution which will probably fix this issue.
The first two require the device/emulator to be rooted.
The third one is too annoying because cloudflared is constantly updated, and adding a release build/fork for this is waste time.
Describe alternatives you've considered Are there any alternatives to solving this problem? If so, what was your experience with them? I think environment variable or command line argument is the best way in a scripting context.
`2025-02-21T03:29:54Z ERR Initiating shutdown error="Could not lookup srv records on _v2-origintunneld._tcp.argotunnel.com: lookup argotunnel.com on 192.168.6.1:53: cannot unmarshal DNS message"
2025-02-21T03:29:54Z INF Metrics server stopped
Could not lookup srv records on _v2-origintunneld._tcp.argotunnel.com: lookup argotunnel.com on 192.168.6.1:53: cannot unmarshal DNS message `