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 | |
44 | ("@" "" "IN" "NS" "ns") |
45 | ("@" "" "IN" "NS" "ns2") |
46 | ("ns" "" "IN" "A" hermes-ip4) |
47 | ("ns" "" "IN" "AAAA" hermes-ip6) |
48 | ("ns2" "" "IN" "A" ene-ip4) |
49 | |
50 | ("@" "" "IN" "MX" "10 courriel") |
51 | ("@" "" "IN" "MX" "50 b.courriel") |
52 | ("b.courriel" "" "IN" "A" hermes-ip4) |
53 | ("b.courriel" "" "IN" "AAAA" hermes-ip6) |
54 | ("courriel" "" "IN" "A" ene-ip4) |
55 | ("imap" "" "IN" "CNAME" "courriel") |
56 | ("smtp" "" "IN" "CNAME" "b.courriel") |
57 | ("@" "" "IN" "TXT" "v=spf1 mx a ~all") |
58 | ("@" "" "IN" "SPF" "v=spf1 mx a ~all")) |
59 | |
60 | (define-zone-entries ipv4-reverse.zone |
61 | ("@" "" "IN" "PTR" "lepiller.eu.") |
62 | ("@" "" "IN" "NS" "ns.lepiller.eu.") |
63 | ("@" "" "IN" "NS" "ns2.lepiller.eu.")) |
64 | |
65 | (define-zone-entries ipv6-reverse.zone |
66 | ("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0" "" "IN" "PTR" "lepiller.eu.") |
67 | ("@" "" "IN" "NS" "ns.lepiller.eu.") |
68 | ("@" "" "IN" "NS" "ns2.lepiller.eu.")) |
69 | |
70 | (define lepiller-master-zone |
71 | (knot-zone-configuration |
72 | (domain "lepiller.eu") |
73 | ;(dnssec-policy "default") |
74 | (zone (zone-file |
75 | (origin "lepiller.eu") |
76 | (entries lepiller.eu.zone) |
77 | (serial 2019041201))))) |
78 | |
79 | (define ipv6-reverse-master-zone |
80 | (let* ((ip6 (string->list (substring (string-delete hermes-ip6 #\:) 0 12))) |
81 | (rev-ip6-lst (fold (lambda (elem acc) |
82 | (cons* #\. elem acc)) |
83 | '() |
84 | ip6)) |
85 | (rev-ip6 (list->string (cdr rev-ip6-lst))) |
86 | (domain (string-append rev-ip6 ".ip6.arpa"))) |
87 | (knot-zone-configuration |
88 | (domain domain) |
89 | (zone (zone-file |
90 | (origin domain) |
91 | (entries ipv6-reverse.zone) |
92 | (ns "ns.lepiller.eu.") |
93 | (mail "hostmaster.lepiller.eu.") |
94 | (serial 1)))))) |
95 | |
96 | (define ipv4-reverse-master-zone |
97 | (let ((domain (string-append |
98 | (string-join (reverse (string-split hermes-ip4 #\.)) ".") |
99 | ".in-addr.arpa"))) |
100 | (knot-zone-configuration |
101 | (domain domain) |
102 | (zone (zone-file |
103 | (origin domain) |
104 | (entries ipv4-reverse.zone) |
105 | (ns "ns.lepiller.eu.") |
106 | (mail "hostmaster.lepiller.eu.") |
107 | (serial 1)))))) |
108 |