libDnsCommunication is a C++ library enabling DNS-based message tunneling.
It encodes arbitrary data into DNS TXT records so a client and server can exchange messages over standard DNS infrastructure.
- UDP DNS client and server implementation.
- Message fragmentation and reassembly using JSON and hex encoding.
- TXT, CNAME, MX, A and AAAA records handled consistently for both encoding and decoding.
- Random subdomain generation and utility helpers.
- Cross-platform support for Linux and Windows.
# linux
mkdir build && cd build
cmake ..
make
#windows
mkdir build && cd build
cmake ..
msbuild Dnscommunication.slnA dedicated binary fonctionalTest is provided to validate client/server communication.
Server mode
./fonctionalTest server --domain ns.example.com [--port 53] [--test-msg "text"] [--run-seconds 5]Client mode
./fonctionalTest client --dns <resolver_ip> --host ns.example.com --send "text" [--timeout 5] [--expect "expected-reply"]You can test locally without a real DNS server:
-
Pick a fake domain (e.g.,
test.dnstestdomain). -
Add it to
/etc/hostspointing to127.0.0.1:127.0.0.1 test.dnstestdomain -
Run the server:
./fonctionalTest server --domain test.dnstestdomain --port 5353 --run-seconds 60 --test-msg "hello" -
Run the client, pointing to localhost (
127.0.0.1):./fonctionalTest client --dns 127.0.0.1 --host test.dnstestdomain --send "hello" --expect "hello" --port 5353
If the message is received correctly, the client will print EXPECTATION OK and exit with code 0.
This setup is useful for CI pipelines or quick validation without relying on external resolvers.
The repository also provides a tiny helper that sends a raw DNS query to any resolver and decodes the answer with the library:
cmake --build build --target publicDnsClient
./publicDnsClient 8.8.8.8 example.com TXTAny RR type supported by the library can be supplied as the optional third argument (for example CNAME, MX, AAAA, …). The tool prints the textual view of the first answer as well as the raw hexadecimal payload, which makes it easy to verify interoperability with public DNS services.
Unit tests are provided in the tests directory. After building, run:
./utilsTestMIT