No description
- Go 100%
| exe | ||
| pkg | ||
| .gitignore | ||
| .tool-versions | ||
| go.mod | ||
| go.sum | ||
| README.md | ||
dnstarrasq
A toy DNS resolver written on a train because of a captive WiFi portal.
Why
When riding České dráhy trains, you might get a WiFi signal. Don't get excited yet.
- it might not be connected to anything if the train is not physically in the Czech Republic
- you might be using Cloudflare DNS
- or Google's DNS
- or a Pihole
- or anything other than CDWiFi's one hallowed DNS resolver
The natural response to this atrocity is building split-horizon DNS resolver that routes cdwifi.cz to the train's DNS server (hallowed be its name), and everything else to Cloudflare. While still on the train. It takes a while to get anywhere, anyway.
Does it even work right
Darn tootin'. For select few values of "work" and "right", respectively.
{"time":"2026-03-21T17:50:18.08919+01:00","level":"INFO","msg":"Listening","addr":":1053"}
{"time":"2026-03-21T17:50:24.325298+01:00","level":"INFO","msg":"recvfrom returned","len":40,"addr":"127.0.0.1:58245"}
{"time":"2026-03-21T17:50:24.325339+01:00","level":"DEBUG","msg":"Packet header","ID":58482,"QDCOUNT":1,"ANCOUNT":0,"NSCOUNT":0,"ARCOUNT":1}
{"time":"2026-03-21T17:50:24.325402+01:00","level":"DEBUG","msg":"-> Flags","Kind":0,"Opcode":0,"Truncated?":false,"RecursionDesired?":true,"RecursionAvailable?":false,"Response":0}
{"time":"2026-03-21T17:50:24.325613+01:00","level":"DEBUG","msg":"-> QuestionSection","num":0,"qname":"example.com","qtype":1,"qclass":1}
{"time":"2026-03-21T17:50:24.365466+01:00","level":"INFO","msg":"upstream returned","remoteLen":72,"remoteAddr":{"IP":"1.1.1.1","Port":53,"Zone":""}}
{"time":"2026-03-21T17:50:24.36571+01:00","level":"INFO","msg":"Responded locally","len":72}
{"time":"2026-03-21T17:50:39.482435+01:00","level":"INFO","msg":"recvfrom returned","len":38,"addr":"127.0.0.1:63215"}
{"time":"2026-03-21T17:50:39.482473+01:00","level":"DEBUG","msg":"Packet header","ID":51400,"QDCOUNT":1,"ANCOUNT":0,"NSCOUNT":0,"ARCOUNT":1}
{"time":"2026-03-21T17:50:39.482486+01:00","level":"DEBUG","msg":"-> Flags","Kind":0,"Opcode":0,"Truncated?":false,"RecursionDesired?":true,"RecursionAvailable?":false,"Response":0}
{"time":"2026-03-21T17:50:39.482507+01:00","level":"DEBUG","msg":"-> QuestionSection","num":0,"qname":"cdwifi.cz","qtype":1,"qclass":1}
{"time":"2026-03-21T17:50:39.486383+01:00","level":"INFO","msg":"upstream returned","remoteLen":54,"remoteAddr":{"IP":"10.200.0.1","Port":53,"Zone":""}}
{"time":"2026-03-21T17:50:39.486452+01:00","level":"INFO","msg":"Responded locally","len":54}
No but seriously, why
- I wanted to check if I can (I could)
- I wanted to write code without an LLM for a change (and see if I still know how to)
- I wanted to understand more about DNS (though probably not this much)
What about all the rest of DNS
Didn't need to parse it, so don't care
What about TCP DNS requests
Sounds like a you problem pull requests welcome (although why would you)
How do I run this
You don't. WHY WOULD YOU WANT TO. Use dnsmasq or coredns or something. Get help.