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.

Features

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:

TYPE RECORD_NAME RECORD_VALUE

For example:

A dc.cwrap.org 127.0.0.10 AAAA dc.cwrap.org fd00::5357:5f0a CNAME kerberos.cwrap.org dc.cwrap.org SRV _kerberos._tcp.cwrap.org kerberos.cwrap.org 88 SOA cwrap.org ns1.cwrap.org admin.cwrap.org 2014100457 3600 300 1814400

The SRV record can optionally also include priority and weight:

SRV _ldap._tcp.cwrap.org ldap.cwrap.org 389 1 5

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