The resolv_wrapper library

A wrapper for DNS name resolving or DNS faking.

Clone with git ยท Report a bug

resolv_wrapper makes it possible on most UNIX platforms to contact your own DNS implementation in your test environment. It requires socket_wrapper to be able to contact the server. Alternatively, the wrapper is able to fake DNS queries and return valid responses to your application.


  • Redirects name queries to the nameservers specified in your resolv.conf.
  • Can fake DNS queries using a simple formatted DNS hosts file.

Detailed descriptions

If you want to use your own resolv.conf you can set the environment variable RESOLV_WRAPPER_CONF to point to a file you created. The format of the file is defined in the manpage resolv.conf(5)

If you do not have a DNS server running but still want to be able that your application or a third party library can do DNS queries, we provide a simple way to do that. All you have to do is to set the environment variable RESOLV_WRAPPER_HOSTS.
It must point to a hosts-like text file that specifies fake records for custom queries. The format of the file looks like this:


For example:

    AAAA fd00::5357:5f0a
    SRV 88
    SOA 2014100457 3600 300 1814400

The SRV record can optionally also include priority and weight:

    SRV 389 1 5

If unset, the priority defaults to 1 and weight defaults to 100.