You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+45-35Lines changed: 45 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,36 +2,40 @@
2
2
A simple DNS server that extracts IP address (or cname) from the requested domain name and sends it back in the response.
3
3
4
4
# Encoding rules
5
-
DNS server parses requested name to extract the requested mode, IP or CNAME by the following rules:
5
+
Since RIP extracts the response from the request, it's important to understand the encoding rules.
6
+
RIP has three kinds of entities:
7
+
- rr - something that generate response (e.g. IP, CNAME and so on):
6
8
```
7
-
<optional-prefix>.<IPv4>.4.<zone> -> returns A record with <IPv4> address
8
-
<optional-prefix>.<IPv6>.6.<zone> -> returns AAAA record with <IPv6> address
9
-
<proxy-name>.p.<zone> -> resolve proxy name and returns it
10
-
<ip1>.<ip2>.r.<zone> -> pick random <ip1> or <ip2>
11
-
<ip1>.<ip2>.l.<zone> -> loop over <ip1> and <ip2>
12
-
<ip1>.<ip2>.s.<zone> -> "sticky" - <ip1> for first request, then <ip2> in sticky TTL (30 sec by default)
13
-
<cname>.c.<zone> -> return CNAME record with <cname>
14
-
<any-name>.<zone> -> returns default address
15
-
[(<IPv4>.4|<IPv6>.6)...(<IPv4>.4|<IPv6>.6)].m.<zone> -> returns multiple address according to order and type
9
+
<IP> - returns IP address (guesses IPv4/IPv6)
10
+
<IPv4>.[4|v4] - strictly returns IPv4 address only
11
+
<IPv6>.[6|v6] - strictly returns IPv6 address only
12
+
<cname>.[c|cname] - return CNAME record with <cname>
13
+
<target>.[p|proxy] - resolve <target> name and returns it
14
+
```
15
+
- container - something that holds rr's (or another container), picked one on each request and response with it:
16
+
```
17
+
<rr>.<container>.[r|random] - pick random rr/container
18
+
<rr>.<container>.[l|loop] - iterate over rr/container
19
+
<rr1>.<rr0>.[s|sticky] - alias for loop container: <rr1-ttl-30>.<rr0-cnt-1>.l
20
+
```
21
+
- limit modifier - something that limit this kind of responses:
22
+
```
23
+
cnt-<num> - use rr <num> requests. e.g.:
24
+
* 1-1-1-1.v4-cnt-10 - returns 1.1.1.1 10 times
25
+
ttl-<duration> - use rr <duration> duration:
26
+
* 2-2-2-2.v4-ttl-20s - returns 2.2.2.2 20 seconds from first v4-rr response
16
27
```
17
28
29
+
Also, RIP allowing to use any prefixes (see examples below).
30
+
18
31
# IP address format
19
32
IP address can be presented in two variants - dash-delimited and base16-form. For example, ips `0a000001` and `10-0-0-1` are equal and points to `10.0.0.1`
20
33
You can also use the built-in converter to encode IP address:
21
34
```
22
-
$ rip ip2hex fe80::fa94:c2ff:fee5:3cf6 127.0.0.1
35
+
$ rip encode fe80::fa94:c2ff:fee5:3cf6 127.0.0.1
23
36
fe80000000000000fa94c2fffee53cf6 7f000001
24
37
```
25
38
26
-
27
-
# Cname/ProxyName format
28
-
`cname` and `proxy` modes support two name resolution logic - prefixed and dash-delimited:
29
-
Eg:
30
-
```
31
-
something.victim.com.c.evil.com -> CNAME to something.victim.com
32
-
something.victim-com.c.evil.com -> CNAME to victim.com
33
-
```
34
-
35
39
# Usage
36
40
Run NS server for zone `example.com` with default IP `77.88.55.70` and `2a02:6b8: a:: a`:
0a000002.0a000001.r.example.com -> random between 10.0.0.1 and 10.0.0.2
62
+
0a000002.0a000001.random.example.com -> random between 10.0.0.1 and 10.0.0.2
63
+
0a000003.0a000002.0a000001.random.example.com -> random between 10.0.0.1 and 10.0.0.2
55
64
56
65
# Loop
57
-
8ba299a7.8ba299a8.l.example.com -> loop over 139.162.153.167 and 139.162.153.168
66
+
8ba299a7.8ba299a8.loop.example.com -> loop over 139.162.153.168 and 139.162.153.167
67
+
8ba299a7.v4-ttl-5s.8ba299a8.v4-cnt-5.loop.example.com -> 139.162.153.168 (first 5 requests), then 139.162.153.167 (next 5s), then 139.162.153.168 (next 5 requests), and so on
68
+
8ba299a7.v4-ttl-5s.b32-onxw2zlunbuw4zzomnxw63bnmnxs44tv.c-cnt-5.loop.example.com -> CNAME "something.cool.co.ru." (first 5 requests), then 139.162.153.167 (next 5s), CNAME "something.cool.co.ru." (first 5 requests), and so on
69
+
8ba299a6.v4.8ba299a7.v4.loop-ttl-5s.8ba299a8.v4-cnt-5.loop.example.com -> 139.162.153.168 (first 5 requests), then 139.162.153.167/139.162.153.166 (next 5s), then 139.162.153.168 (next 5 requests) and so on
58
70
59
71
# Sticky
60
-
8ba299a7.8ba299a8.s.example.com -> 139.162.153.167 then 139.162.153.168, then 139.162.153.168 and so on
72
+
8ba299a7.8ba299a8.s.example.com -> 139.162.153.168 (first A request) then 139.162.153.167 (30s), then 139.162.153.168 (next A request) and so on
61
73
62
74
# Cname
63
-
ya.ru.c.example.com -> canonical name ya.ru
64
-
google.com.c.example.com -> canonical name google.com
75
+
ya-ru.c.example.com -> canonical name ya.ru
76
+
google-com.c.example.com -> canonical name google.com
77
+
b32-onxw2zlunbuw4zzomnxw63bnmnxs44tv.c.example.com -> canonical name something.cool.co.ru
65
78
66
79
# Proxy
67
-
ya.ru.p.example.com -> 87.250.250.242 and 2a02:6b8::2:242
68
-
google.com.p.example.com -> 64.233.164.102 and 2a00:1450:4010:c07::64
0 commit comments