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