dns.scm
1 | ;;; Tyreunom's system administration and configuration tools. |
2 | ;;; |
3 | ;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu> |
4 | ;;; |
5 | ;;; This program is free software: you can redistribute it and/or modify |
6 | ;;; it under the terms of the GNU General Public License as published by |
7 | ;;; the Free Software Foundation, either version 3 of the License, or |
8 | ;;; (at your option) any later version. |
9 | ;;; |
10 | ;;; This program is distributed in the hope that it will be useful, |
11 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | ;;; GNU General Public License for more details. |
14 | ;;; |
15 | ;;; You should have received a copy of the GNU General Public License |
16 | ;;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | |
18 | ;; |
19 | ;; DNS services |
20 | ;; |
21 | |
22 | (define-module (config dns) |
23 | #:use-module (data dns) |
24 | #:use-module (gnu services) |
25 | #:use-module (gnu services dns) |
26 | #:use-module (srfi srfi-1) |
27 | #:export (ipv4-reverse-master-zone |
28 | ipv6-reverse-master-zone |
29 | lepiller-master-zone)) |
30 | |
31 | (define-zone-entries lepiller.eu.zone |
32 | ;; Name TTL Class Type Data |
33 | ("ene" "" "IN" "A" ene-ip4) |
34 | ("hermes" "" "IN" "A" hermes-ip4) |
35 | ("hermes" "" "IN" "AAAA" hermes-ip6) |
36 | ("xana" "" "IN" "A" xana-ip4) |
37 | ("@" "" "IN" "A" hermes-ip4) |
38 | ("@" "" "IN" "AAAA" hermes-ip6) |
39 | ("www" "" "IN" "CNAME" "lepiller.eu.") |
40 | |
41 | ("avatar" "" "IN" "CNAME" "ene") |
42 | ("rennes" "" "IN" "CNAME" "ene") |
43 | ("nani" "" "IN" "CNAME" "xana") |
44 | |
45 | ("@" "" "IN" "NS" "ns") |
46 | ("@" "" "IN" "NS" "ns2") |
47 | ("ns" "" "IN" "A" hermes-ip4) |
48 | ("ns" "" "IN" "AAAA" hermes-ip6) |
49 | ("ns2" "" "IN" "A" ene-ip4) |
50 | |
51 | ("@" "" "IN" "MX" "10 courriel") |
52 | ("@" "" "IN" "MX" "50 b.courriel") |
53 | ("b.courriel" "" "IN" "A" hermes-ip4) |
54 | ("b.courriel" "" "IN" "AAAA" hermes-ip6) |
55 | ("courriel" "" "IN" "A" ene-ip4) |
56 | ("imap" "" "IN" "CNAME" "courriel") |
57 | ("smtp" "" "IN" "CNAME" "b.courriel") |
58 | ("@" "" "IN" "TXT" "v=spf1 mx a ~all") |
59 | ("@" "" "IN" "SPF" "v=spf1 mx a ~all")) |
60 | |
61 | (define-zone-entries ipv4-reverse.zone |
62 | ("@" "" "IN" "PTR" "lepiller.eu.") |
63 | ("@" "" "IN" "NS" "ns.lepiller.eu.") |
64 | ("@" "" "IN" "NS" "ns2.lepiller.eu.")) |
65 | |
66 | (define-zone-entries ipv6-reverse.zone |
67 | ("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0" "" "IN" "PTR" "lepiller.eu.") |
68 | ("@" "" "IN" "NS" "ns.lepiller.eu.") |
69 | ("@" "" "IN" "NS" "ns2.lepiller.eu.")) |
70 | |
71 | (define lepiller-master-zone |
72 | (knot-zone-configuration |
73 | (domain "lepiller.eu") |
74 | ;(dnssec-policy "default") |
75 | (zone (zone-file |
76 | (origin "lepiller.eu") |
77 | (entries lepiller.eu.zone) |
78 | (serial 2019041202))))) |
79 | |
80 | (define ipv6-reverse-master-zone |
81 | (let* ((ip6 (string->list (substring (string-delete hermes-ip6 #\:) 0 12))) |
82 | (rev-ip6-lst (fold (lambda (elem acc) |
83 | (cons* #\. elem acc)) |
84 | '() |
85 | ip6)) |
86 | (rev-ip6 (list->string (cdr rev-ip6-lst))) |
87 | (domain (string-append rev-ip6 ".ip6.arpa"))) |
88 | (knot-zone-configuration |
89 | (domain domain) |
90 | (zone (zone-file |
91 | (origin domain) |
92 | (entries ipv6-reverse.zone) |
93 | (ns "ns.lepiller.eu.") |
94 | (mail "hostmaster.lepiller.eu.") |
95 | (serial 1)))))) |
96 | |
97 | (define ipv4-reverse-master-zone |
98 | (let ((domain (string-append |
99 | (string-join (reverse (string-split hermes-ip4 #\.)) ".") |
100 | ".in-addr.arpa"))) |
101 | (knot-zone-configuration |
102 | (domain domain) |
103 | (zone (zone-file |
104 | (origin domain) |
105 | (entries ipv4-reverse.zone) |
106 | (ns "ns.lepiller.eu.") |
107 | (mail "hostmaster.lepiller.eu.") |
108 | (serial 1)))))) |
109 |