blob: 7a4ed7f7fbc382215dcc284f24b0b54ebd287593 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
(use-modules (arunisaac powerdns)
(gnu)
((gnu packages admin) #:select (htop nmap))
((gnu packages curl) #:select (curl))
((gnu packages dns) #:select (knot))
((gnu packages linux) #:select (nftables))
((gnu packages ssh) #:select (openssh-sans-x))
(gnu services networking)
(gnu services ssh)
(gnu services sysctl)
(gnu services vpn)
(gnu services web)
(guix records))
(load "mugam-private.scm")
(define %hrrol-wg-ip
"192.168.2.12")
(define %ragulkanth-wg-ip
"192.168.2.4")
(define %wireguard-peers
(cons* (wireguard-peer
(name 'ragulkanth)
(public-key "2FSShF/tVYoPYmIjZQk3Uqv53QFKoXb78kD4vyLVVmM=")
(allowed-ips (list (string-append %ragulkanth-wg-ip "/32"))))
(wireguard-peer
(name 'hrrol)
(public-key "QfPQwNHMr6o6iqt/EzPm1JZOrZRik6LGRpdJOyIiK3g=")
(allowed-ips (list (string-append %hrrol-wg-ip "/32"))))
%wireguard-private-peers))
;;;
;;; DNS Server
;;;
(define-record-type* <zone>
zone make-zone
zone?
(name zone-name)
(file zone-file))
;; TODO: Backup zone files.
(define %zones
(list (zone
(name "arohonline.in")
(file "/etc/powerdns/zones/arohonline.in"))
(zone
(name "arohonline.org")
(file "/etc/powerdns/zones/arohonline.org"))
(zone
(name "cosmobird.me")
(file "/etc/powerdns/zones/cosmobird.me"))
(zone
(name "issuesofconcern.in")
(file "/etc/powerdns/zones/issuesofconcern.in"))
(zone
(name "ragulkanth.dev")
(file "/etc/powerdns/zones/ragulkanth.dev"))
(zone
(name "solariiknight.org")
(file "/etc/powerdns/zones/solariiknight.org"))
(zone
(name "systemreboot.net")
(file "/etc/powerdns/zones/systemreboot.net"))))
(define (named.conf-gexp zones)
"Return a G-expression that computes a named.conf with ZONES, a list
of <zone> records."
#~(begin
(call-with-output-file #$output
(lambda (port)
(for-each (lambda (name file)
(format port "zone ~s {
file ~s;
};
"
name file))
'#$(map zone-name zones)
'#$(map zone-file zones))))))
;;;
;;; operating-system definition
;;;
(operating-system
(host-name "mugam")
(timezone "Europe/London")
(locale "ta_IN.utf8")
(bootloader (bootloader-configuration
(bootloader grub-bootloader)))
(file-systems (cons (file-system
(mount-point "/")
(device "/dev/vda1")
(type "ext4"))
%base-file-systems))
(users (cons* (user-account
(name "arunisaac")
(comment "Arun Isaac")
(group "users"))
(user-account
(name "cosmovpndns")
(comment "Ganesh")
(group "users"))
(user-account
(name "ragulkanth")
(comment "Ragulkanth")
(group "users"))
%base-user-accounts))
(packages
(cons* curl
htop
(list knot "tools")
nftables
nmap
%base-packages))
(services
(cons* (service dhcpcd-service-type)
(service nftables-service-type
(nftables-configuration
(ruleset (mixed-text-file "mugam-nftables.conf"
"define hrrol = " %hrrol-wg-ip "\n"
"define ragulkanth = " %ragulkanth-wg-ip "\n" "\n"
"include \"" (local-file "mugam-nftables-rules.conf") "\"\n"))))
(service wireguard-service-type
(wireguard-configuration
(addresses (list "192.168.2.1/24"))
(peers %wireguard-peers)))
(service openssh-service-type
(openssh-configuration
(openssh openssh-sans-x)
(password-authentication? #f)
(permit-root-login #t)
(allow-agent-forwarding? #f)
(authorized-keys
`(("root" ,(local-file "ssh-keys/arunisaac.pub"))
("arunisaac" ,(local-file "ssh-keys/arunisaac.pub"))
("cosmovpndns" ,(local-file "ssh-keys/cosmovpndns.pub"))
("ragulkanth" ,(local-file "ssh-keys/ragulkanth.pub"))))))
(service powerdns-service-type
(powerdns-configuration
(backends (list "bind"))
(bind-config
(computed-file "named.conf"
(named.conf-gexp %zones)))
(bind-check-interval 60)))
(service nginx-service-type
(nginx-configuration
(server-blocks
(list (nginx-server-configuration
(listen (list "80"))
(server-name (list ".arohonline.in"
".arohonline.org"
".issuesofconcern.in"
".solariiknight.org"
".systemreboot.net"))
(locations
(list (nginx-location-configuration
(uri "/")
(body (list (string-append "proxy_pass http://"
%hrrol-wg-ip
";")
"proxy_set_header Host $http_host;"))))))
(nginx-server-configuration
(listen (list "80"))
(server-name (list ".dev-il.xyz"
".ragulkanth.dev"))
(locations
(list (nginx-location-configuration
(uri "/")
(body (list (string-append "proxy_pass http://"
%ragulkanth-wg-ip
";")
"proxy_set_header Host $http_host;"))))))))
(stream
(nginx-stream-configuration
(upstream-blocks
(list (nginx-upstream-configuration
(name "hrrol_https")
(servers (list (string-append %hrrol-wg-ip ":443"))))
(nginx-upstream-configuration
(name "ragulkanth_https")
(servers (list (string-append %ragulkanth-wg-ip ":443"))))))
(server-blocks
(list (nginx-server-configuration
(listen (list "443"))
(raw-content (list "ssl_preread on;"
"proxy_pass $upstream;")))))
(extra-content
(list "map $ssl_preread_server_name $upstream {
hostnames;
.arohonline.in hrrol_https;
.arohonline.org hrrol_https;
.issuesofconcern.in hrrol_https;
.solariiknight.org hrrol_https;
.systemreboot.net hrrol_https;
.dev-il.xyz ragulkanth_https;
.ragulkanth.dev ragulkanth_https;
}
"))))))
(modify-services %base-services
(guix-service-type
config => (guix-configuration
(inherit config)
(authorized-keys (cons (local-file "/etc/guix/signing-key.pub")
%default-authorized-guix-keys))))
(sysctl-service-type
config => (sysctl-configuration
(settings '(("net.ipv4.ip_forward" . "1")))))))))
|