Using a classic nsswitch.conf configuration :
hosts: files dns
Trying to resolve a name using gethostbyname (or getaddrinfo) could take a while if the DNS does not answer (or is badly configured).
Is there a way to configure a timeout in nsswitch.conf or use an alternative api that manage a timeout ?
There is getaddrinfo_a, but it is Linux-specific GNU glibc specific. Alternatively, you can spawn a thread and call getaddrinfo in it. Don't use gethostbyname in a thread, as it is not thread-safe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With