Tiny C library that hijacks DNS calls
Hooks libc functions (connect, sendto, recvfrom, etc.) to redirect port 53 traffic. Works with node, dig, whatever uses normal DNS calls
Also spoofs response addresses so c-ares doesn't throw a fit
gcc -shared -fPIC -o dns.so dns.c -ldl -lpthreadLD_PRELOAD=./dns.so node server.js
LD_PRELOAD=./dns.so dig google.comBy default dns is deferred to 9.9.9.10, the non-filtering server by Quad9
If you'd like to change that: sed 's/9\.9\.9\.10/X\.Y\.Z\.W/g' dns.c
- IPv4 only
- no DoT/DoH
- basic getaddrinfo implementation
- won't work with statically linked stuff
- might leak memory under awkward circumstances
MIT