Skip to content

Instantly share code, notes, and snippets.

@rtldg
Created June 14, 2023 18:39
Show Gist options
  • Save rtldg/67af56b773cb3af80fd745f93d646ff0 to your computer and use it in GitHub Desktop.
Save rtldg/67af56b773cb3af80fd745f93d646ff0 to your computer and use it in GitHub Desktop.
how many recursive CNAME records does your dns resolver resolve?
well there's an easy way and a hard way to figure out...
let's start with the hard way:
- search golang dns server
- end up with https://gist.github.com/walm/0d67b4fb2d5daf3edd4fad3e13b162cb and save main.go to a folder
- search how to build a golang project and download imports because you don't remember
- edit it to parse the deepest subdomain as an int and return a CNAME minus one of it
- and also return a real A record if the int is 0
- acquire a vps and scp your built binary to it
- search how to fix it not running because glibc version stuff (fix with `CGO_ENABLED=0 go build`)
- open port 53 in your vps firewall
- set dns records like so:
```
ns-cnametest A 0.0.0.0 ; YOUR VPS IP HERE OBVIOUSLY
cnametest NS ns-cnametest.example.org.
```
- and wow now if your run your dns server and `ping 05.cnametest.example.org` it might work!
- and proceed to debug why your vpn is eating dig and host and all your dns queries
well that was fun but now the easy way:
- spend two minutes typing out a zone file with cnames you can import into your dns provider
```
00.cnametest.example.org. 300 IN A 1.1.1.1
01.cnametest.example.org. 300 IN CNAME 00.cnametest.example.org.
02.cnametest.example.org. 300 IN CNAME 01.cnametest.example.org.
03.cnametest.example.org. 300 IN CNAME 02.cnametest.example.org.
04.cnametest.example.org. 300 IN CNAME 03.cnametest.example.org.
05.cnametest.example.org. 300 IN CNAME 04.cnametest.example.org.
06.cnametest.example.org. 300 IN CNAME 05.cnametest.example.org.
07.cnametest.example.org. 300 IN CNAME 06.cnametest.example.org.
08.cnametest.example.org. 300 IN CNAME 07.cnametest.example.org.
09.cnametest.example.org. 300 IN CNAME 08.cnametest.example.org.
10.cnametest.example.org. 300 IN CNAME 09.cnametest.example.org.
11.cnametest.example.org. 300 IN CNAME 10.cnametest.example.org.
12.cnametest.example.org. 300 IN CNAME 11.cnametest.example.org.
13.cnametest.example.org. 300 IN CNAME 12.cnametest.example.org.
14.cnametest.example.org. 300 IN CNAME 13.cnametest.example.org.
15.cnametest.example.org. 300 IN CNAME 14.cnametest.example.org.
16.cnametest.example.org. 300 IN CNAME 15.cnametest.example.org.
17.cnametest.example.org. 300 IN CNAME 16.cnametest.example.org.
18.cnametest.example.org. 300 IN CNAME 17.cnametest.example.org.
19.cnametest.example.org. 300 IN CNAME 18.cnametest.example.org.
20.cnametest.example.org. 300 IN CNAME 19.cnametest.example.org.
```
- `ping 10.cnametest.example.org` and see if it works
- now `ping 15.cnametest.example.org` and see if that works (20 might work if you're lucky!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment