A tiny DNS library in C
Find a file
2026-05-08 17:00:34 +00:00
examples first batch of files and examples 2026-03-28 19:52:03 +03:00
.gitignore Initial commit 2026-03-28 16:50:33 +00:00
LICENSE Initial commit 2026-03-28 16:50:33 +00:00
README.md Update README.md 2026-03-29 12:46:58 +00:00
resolv.c Update resolv.c 2026-05-08 17:00:34 +00:00
resolv.h first batch of files and examples 2026-03-28 19:52:03 +03:00

tinycdns

A tiny DNS library in C

features

1- can resolve IPV4 domains 2- can resolve TXT records 3- is fully POSIX compliant (Works on MacOS, all the BSD variants, Linux, GNU based systems following the POSIX standard) 4- can bypass OS level DNS restrictions (modifying Hosts file, blocking domains being resolved, etc)

examples

examples can be found in the examples folder

C code example

#include <stdio.h>
#include "resolv.h" // HEADER file of the DNS library

int main(int argc, char *argv[]) {
    if (argc < 2) {
        printf("Usage: %s <hostname>\n", argv[0]);
        return 1;
    }

    const char *host = argv[1];
    char *ip = resolve_ipv4(host);

    if (ip) {
        printf("IPv4 for %s: %s\n", host, ip);
    } else {
        printf("Could not resolve IPv4 for %s\n", host);
    }

    return 0;
}

possible environments to use in

  1. minimal environments without a traditional DNS resolver
  2. places where you dont want to use the default operating system's DNS resolver
  3. to use in IoT projects

where to NOT use (otherwise its a bad idea)

  1. when you're developing for non-POSIX or Windows based systems.
  2. when you expect absolute accuracy and many features, since its quite barebones.