Restrict ssh to anycast and static mirrors
[mirror/dsa-puppet.git] / modules / ferm / manifests / per_host.pp
1 class ferm::per_host {
2         if $::hostname in [zandonai,zelenka] {
3                 include ferm::zivit
4         }
5
6         if (getfromhash($site::nodeinfo, 'hoster', 'name') == "aql") {
7                 include ferm::aql
8         }
9
10         case $::hostname {
11                 czerny,clementi: {
12                         @ferm::rule { 'dsa-upsmon':
13                                 description     => 'Allow upsmon access',
14                                 rule            => '&SERVICE_RANGE(tcp, 3493, ( 82.195.75.64/26 192.168.43.0/24 ))'
15                         }
16                 }
17                 bendel: {
18                         @ferm::rule { 'listmaster-ontp-in':
19                                 description => 'ONTP has a broken mail setup',
20                                 table       => 'filter',
21                                 chain       => 'INPUT',
22                                 rule        => 'source 188.165.23.89/32 proto tcp dport 25 jump DROP',
23                         }
24                         @ferm::rule { 'listmaster-ontp-out':
25                                 description => 'ONTP has a broken mail setup',
26                                 table       => 'filter',
27                                 chain       => 'OUTPUT',
28                                 rule        => 'destination 78.8.208.246/32 proto tcp dport 25 jump DROP',
29                         }
30                 }
31                 lotti,lully,loghost-grnet-01: {
32                         @ferm::rule { 'dsa-syslog':
33                                 description     => 'Allow syslog access',
34                                 rule            => '&SERVICE_RANGE(tcp, 5140, $HOST_DEBIAN_V4)'
35                         }
36                         @ferm::rule { 'dsa-syslog-v6':
37                                 domain          => 'ip6',
38                                 description     => 'Allow syslog access',
39                                 rule            => '&SERVICE_RANGE(tcp, 5140, $HOST_DEBIAN_V6)'
40                         }
41                         @ferm::rule { 'fastly-syslog':
42                                 description     => 'Allow syslog access',
43                                 rule            => '&SERVICE_RANGE(tcp, 5141, $HOST_FASTLY)'
44                         }
45                 }
46                 kaufmann: {
47                         @ferm::rule { 'dsa-hkp':
48                                 domain          => '(ip ip6)',
49                                 description     => 'Allow hkp access',
50                                 rule            => '&SERVICE(tcp, 11371)'
51                         }
52                 }
53                 gombert: {
54                         @ferm::rule { 'dsa-infinoted':
55                                 domain          => '(ip ip6)',
56                                 description     => 'Allow infinoted access',
57                                 rule            => '&SERVICE(tcp, 6523)'
58                         }
59                 }
60                 draghi: {
61                         @ferm::rule { 'dsa-finger':
62                                 domain          => '(ip ip6)',
63                                 description     => 'Allow finger access',
64                                 rule            => '&SERVICE(tcp, 79)'
65                         }
66                         @ferm::rule { 'dsa-ldap':
67                                 domain          => '(ip ip6)',
68                                 description     => 'Allow ldap access',
69                                 rule            => '&SERVICE(tcp, 389)'
70                         }
71                         @ferm::rule { 'dsa-ldaps':
72                                 domain          => '(ip ip6)',
73                                 description     => 'Allow ldaps access',
74                                 rule            => '&SERVICE(tcp, 636)'
75                         }
76                 }
77                 sonntag: {
78                         @ferm::rule { 'dsa-bugs-search':
79                                 description  => 'port 1978 for bugs-search from bug web frontends',
80                                 rule         => '&SERVICE_RANGE(tcp, 1978, ( 140.211.166.26 209.87.16.39 ))'
81                         }
82                 }
83                 default: {}
84         }
85
86         # redirect snapshot into varnish
87         case $::hostname {
88                 sibelius: {
89                         @ferm::rule { 'dsa-snapshot-varnish':
90                                 rule            => '&SERVICE(tcp, 6081)',
91                         }
92                         @ferm::rule { 'dsa-nat-snapshot-varnish':
93                                 table           => 'nat',
94                                 chain           => 'PREROUTING',
95                                 rule            => 'proto tcp daddr 193.62.202.30 dport 80 REDIRECT to-ports 6081',
96                         }
97                 }
98                 lw07: {
99                         @ferm::rule { 'dsa-snapshot-varnish':
100                                 rule            => '&SERVICE(tcp, 6081)',
101                         }
102                         @ferm::rule { 'dsa-nat-snapshot-varnish':
103                                 table           => 'nat',
104                                 chain           => 'PREROUTING',
105                                 rule            => 'proto tcp daddr 185.17.185.185 dport 80 REDIRECT to-ports 6081',
106                         }
107                 }
108                 default: {}
109         }
110         case $::hostname {
111                 bm-bl1,bm-bl2: {
112                         @ferm::rule { 'dsa-vrrp':
113                                 rule            => 'proto vrrp daddr 224.0.0.18 jump ACCEPT',
114                         }
115                         @ferm::rule { 'dsa-conntrackd':
116                                 rule            => 'interface vlan2 daddr 225.0.0.50 jump ACCEPT',
117                         }
118                         @ferm::rule { 'dsa-bind-notrack-in':
119                                 domain      => 'ip',
120                                 description => 'NOTRACK for nameserver traffic',
121                                 table       => 'raw',
122                                 chain       => 'PREROUTING',
123                                 rule        => 'proto (tcp udp) daddr 5.153.231.24 dport 53 jump NOTRACK'
124                         }
125
126                         @ferm::rule { 'dsa-bind-notrack-out':
127                                 domain      => 'ip',
128                                 description => 'NOTRACK for nameserver traffic',
129                                 table       => 'raw',
130                                 chain       => 'OUTPUT',
131                                 rule        => 'proto (tcp udp) saddr 5.153.231.24 sport 53 jump NOTRACK'
132                         }
133
134                         @ferm::rule { 'dsa-bind-notrack-in6':
135                                 domain      => 'ip6',
136                                 description => 'NOTRACK for nameserver traffic',
137                                 table       => 'raw',
138                                 chain       => 'PREROUTING',
139                                 rule        => 'proto (tcp udp) daddr 2001:41c8:1000:21::21:24 dport 53 jump NOTRACK'
140                         }
141
142                         @ferm::rule { 'dsa-bind-notrack-out6':
143                                 domain      => 'ip6',
144                                 description => 'NOTRACK for nameserver traffic',
145                                 table       => 'raw',
146                                 chain       => 'OUTPUT',
147                                 rule        => 'proto (tcp udp) saddr 2001:41c8:1000:21::21:24 sport 53 jump NOTRACK'
148                         }
149                 }
150                 default: {}
151         }
152
153         # postgres stuff
154         case $::hostname {
155                 ullmann: {
156                         @ferm::rule { 'dsa-postgres-udd':
157                                 description     => 'Allow postgress access',
158                                 # quantz, moszumanska, master, coccia
159                                 rule            => '&SERVICE_RANGE(tcp, 5452, ( 5.153.231.28/32 5.153.231.21/32 82.195.75.110/32 5.153.231.11/32 ))'
160                         }
161                         @ferm::rule { 'dsa-postgres-udd6':
162                                 domain          => '(ip6)',
163                                 description     => 'Allow postgress access',
164                                 rule            => '&SERVICE_RANGE(tcp, 5452, ( 2001:41c8:1000:21::21:28/128 2001:41b8:202:deb:216:36ff:fe40:4001/128 2001:41c8:1000:21::21:11/32 2001:41c8:1000:21::21:21/128 ))'
165                         }
166                 }
167                 fasolo: {
168                         @ferm::rule { 'dsa-postgres-fasolo':
169                                 description     => 'Allow postgress access',
170                                 rule            => '&SERVICE_RANGE(tcp, 5433, ( 5.153.231.10/32 ))'
171                         }
172                         @ferm::rule { 'dsa-postgres-fasolo6':
173                                 domain          => 'ip6',
174                                 description     => 'Allow postgress access',
175                                 rule            => '&SERVICE_RANGE(tcp, 5433, ( 2001:41c8:1000:21::21:10/128 ))'
176                         }
177
178                         @ferm::rule { 'dsa-postgres-backup':
179                                 description     => 'Allow postgress access',
180                                 rule            => '&SERVICE_RANGE(tcp, 5433, ( $HOST_PGBACKUPHOST_V4 ))'
181                         }
182                         @ferm::rule { 'dsa-postgres-backup6':
183                                 domain          => 'ip6',
184                                 description     => 'Allow postgress access',
185                                 rule            => '&SERVICE_RANGE(tcp, 5433, ( $HOST_PGBACKUPHOST_V6 ))'
186                         }
187                 }
188                 bmdb1: {
189                         @ferm::rule { 'dsa-postgres-main':
190                                 description     => 'Allow postgress access',
191                                 rule            => '&SERVICE_RANGE(tcp, 5435, ( 5.153.231.23/32 5.153.231.25/32 209.87.16.38/32 5.153.231.26/32 5.153.231.18/32 5.153.231.28/32 5.153.231.249/32 5.153.231.29/32 5.153.231.43/32 5.153.231.33/32 ))'
192                         }
193                         @ferm::rule { 'dsa-postgres-main6':
194                                 domain          => 'ip6',
195                                 description     => 'Allow postgress access',
196                                 rule            => '&SERVICE_RANGE(tcp, 5435, ( 2001:41c8:1000:21::21:23/128 2001:41c8:1000:21::21:25/128 2607:f8f0:614:1::1274:38/128 2001:41c8:1000:21::21:26/128 2001:41c8:1000:21::21:18/128 2001:41c8:1000:21::21:28/128 2001:41c8:1000:20::20:249/128 2001:41c8:1000:21::21:29/128 2001:41c8:1000:21::21:43/128 2001:41c8:1000:21::21:33/128 ))'
197                         }
198                         @ferm::rule { 'dsa-postgres-dak':
199                                 description     => 'Allow postgress access',
200                                 rule            => '&SERVICE_RANGE(tcp, 5434, ( 5.153.231.11/32 5.153.231.28/32 209.87.16.26/32 5.153.231.21/32 5.153.231.18/32 5.153.231.29/32 128.31.0.69/32 ))'
201                         }
202                         @ferm::rule { 'dsa-postgres-dak6':
203                                 domain          => 'ip6',
204                                 description     => 'Allow postgress access',
205                                 rule            => '&SERVICE_RANGE(tcp, 5434, ( 2001:41c8:1000:21::21:11/128 2001:41c8:1000:21::21:28/128 2607:f8f0:614:1::1274:26/128 2001:41c8:1000:21::21:21/128 2001:41c8:1000:21::21:18/128 2001:41c8:1000:21::21:29/128 ))'
206                         }
207                         @ferm::rule { 'dsa-postgres-wannabuild':
208                                 # wuiet, ullmann
209                                 description     => 'Allow postgress access',
210                                 rule            => '&SERVICE_RANGE(tcp, 5436, ( 5.153.231.18/32 209.87.16.38/32 ))'
211                         }
212                         @ferm::rule { 'dsa-postgres-wannabuild6':
213                                 domain          => 'ip6',
214                                 description     => 'Allow postgress access',
215                                 rule            => '&SERVICE_RANGE(tcp, 5436, ( 2001:41c8:1000:21::21:18/128 2607:f8f0:614:1::1274:38/128 ))'
216                         }
217                         @ferm::rule { 'dsa-postgres-bacula':
218                                 # dinis
219                                 description     => 'Allow postgress access1',
220                                 rule            => '&SERVICE_RANGE(tcp, 5437, ( 5.153.231.19/32 93.94.130.161/32 ))'
221                         }
222                         @ferm::rule { 'dsa-postgres-bacula6':
223                                 domain          => 'ip6',
224                                 description     => 'Allow postgress access1',
225                                 rule            => '&SERVICE_RANGE(tcp, 5437, ( 2001:41c8:1000:21::21:19/128 2a02:158:380:280::161/128 ))'
226                         }
227
228                         @ferm::rule { 'dsa-postgres-backup':
229                                 description     => 'Allow postgress access',
230                                 rule            => '&SERVICE_RANGE(tcp, (5435 5436 5440), ( $HOST_PGBACKUPHOST_V4 ))'
231                         }
232                         @ferm::rule { 'dsa-postgres-backup6':
233                                 domain          => 'ip6',
234                                 description     => 'Allow postgress access',
235                                 rule            => '&SERVICE_RANGE(tcp, (5435 5436 5440), ( $HOST_PGBACKUPHOST_V6 ))'
236                         }
237
238                         @ferm::rule { 'dsa-postgres-dedup':
239                                 # ubc, wuit
240                                 description     => 'Allow postgress access',
241                                 rule            => '&SERVICE_RANGE(tcp, (5439), ( 5.153.231.17/32 ))'
242                         }
243                         @ferm::rule { 'dsa-postgres-dedup6':
244                                 domain          => 'ip6',
245                                 description     => 'Allow postgress access',
246                                 rule            => '&SERVICE_RANGE(tcp, (5439), ( 2001:41c8:1000:21::21:17/128 ))'
247                         }
248
249                         @ferm::rule { 'dsa-postgres-debsources':
250                                 description     => 'Allow postgress access',
251                                 rule            => '&SERVICE_RANGE(tcp, (5440), ( 5.153.231.38/32 ))'
252                         }
253                         @ferm::rule { 'dsa-postgres-debsources6':
254                                 domain          => 'ip6',
255                                 description     => 'Allow postgress access',
256                                 rule            => '&SERVICE_RANGE(tcp, (5440), ( 2001:41c8:1000:21::21:38/128 ))'
257                         }
258                 }
259                 danzi: {
260                         @ferm::rule { 'dsa-postgres-danzi':
261                                 # ubc, wuit
262                                 description     => 'Allow postgress access',
263                                 rule            => '&SERVICE_RANGE(tcp, 5433, ( 206.12.19.0/24 209.87.16.0/24 5.153.231.18/32 ))'
264                         }
265                         @ferm::rule { 'dsa-postgres-danzi6':
266                                 domain          => 'ip6',
267                                 description     => 'Allow postgress access',
268                                 rule            => '&SERVICE_RANGE(tcp, 5433, ( 2607:f8f0:610:4000::/64 2607:f8f0:614:1::/64 2001:41c8:1000:21::21:18/128 ))'
269                         }
270
271                         @ferm::rule { 'dsa-postgres2-danzi':
272                                 description     => 'Allow postgress access2',
273                                 rule            => '&SERVICE_RANGE(tcp, 5437, ( 206.12.19.0/24 209.87.16.0/24 ))'
274                         }
275                         @ferm::rule { 'dsa-postgres3-danzi':
276                                 description     => 'Allow postgress access3',
277                                 rule            => '&SERVICE_RANGE(tcp, 5436, ( 206.12.19.0/24 209.87.16.0/24 ))'
278                         }
279                         @ferm::rule { 'dsa-postgres4-danzi':
280                                 description     => 'Allow postgress access4',
281                                 rule            => '&SERVICE_RANGE(tcp, 5438, ( 206.12.19.0/24 209.87.16.0/24 ))'
282                         }
283
284                         @ferm::rule { 'dsa-postgres-backup':
285                                 description     => 'Allow postgress access',
286                                 rule            => '&SERVICE_RANGE(tcp, 5433, ( $HOST_PGBACKUPHOST_V4 ))'
287                         }
288                         @ferm::rule { 'dsa-postgres-backup6':
289                                 domain          => 'ip6',
290                                 description     => 'Allow postgress access',
291                                 rule            => '&SERVICE_RANGE(tcp, 5433, ( $HOST_PGBACKUPHOST_V6 ))'
292                         }
293                 }
294                 seger: {
295                         @ferm::rule { 'dsa-postgres-backup':
296                                 description     => 'Allow postgress access',
297                                 rule            => '&SERVICE_RANGE(tcp, 5432, ( $HOST_PGBACKUPHOST_V4 ))'
298                         }
299                         @ferm::rule { 'dsa-postgres-backup6':
300                                 domain          => 'ip6',
301                                 description     => 'Allow postgress access',
302                                 rule            => '&SERVICE_RANGE(tcp, 5432, ( $HOST_PGBACKUPHOST_V6 ))'
303                         }
304                 }
305                 sibelius: {
306                         @ferm::rule { 'dsa-postgres-backup':
307                                 description     => 'Allow postgress access',
308                                 rule            => '&SERVICE_RANGE(tcp, 5433, ( $HOST_PGBACKUPHOST_V4 ))'
309                         }
310                         @ferm::rule { 'dsa-postgres-backup6':
311                                 domain          => 'ip6',
312                                 description     => 'Allow postgress access',
313                                 rule            => '&SERVICE_RANGE(tcp, 5433, ( $HOST_PGBACKUPHOST_V6 ))'
314                         }
315                         @ferm::rule { 'dsa-postgres-replication':
316                                 description     => 'Allow postgress access',
317                                 rule            => '&SERVICE_RANGE(tcp, 5433, ( 185.17.185.187/32 ))'
318                         }
319                         @ferm::rule { 'dsa-postgres-replication6':
320                                 domain          => 'ip6',
321                                 description     => 'Allow postgress access',
322                                 rule            => '&SERVICE_RANGE(tcp, 5433, ( 2001:1af8:4020:b030:deb::187/128 ))'
323                         }
324                 }
325                 lw07: {
326                         @ferm::rule { 'dsa-postgres-snapshot':
327                                 description     => 'Allow postgress access',
328                                 rule            => '&SERVICE_RANGE(tcp, 5439, ( 185.17.185.176/28 ))'
329                         }
330                         @ferm::rule { 'dsa-postgres-snapshot6':
331                                 domain          => 'ip6',
332                                 description     => 'Allow postgress access',
333                                 rule            => '&SERVICE_RANGE(tcp, 5439, ( 2001:1af8:4020:b030::/64 ))'
334                         }
335                 }
336                 default: {}
337         }
338         # vpn fu
339         case $::hostname {
340                 draghi: {
341                         @ferm::rule { 'dsa-vpn':
342                                 description     => 'Allow openvpn access',
343                                 rule            => '&SERVICE(udp, 17257)'
344                         }
345                         @ferm::rule { 'dsa-routing':
346                                 description     => 'forward chain',
347                                 chain           => 'FORWARD',
348                                 rule            => 'policy ACCEPT;
349 mod state state (ESTABLISHED RELATED) ACCEPT;
350 interface tun+ ACCEPT;
351 REJECT reject-with icmp-admin-prohibited
352 '
353                         }
354                         @ferm::rule { 'dsa-vpn-mark':
355                                 table           => 'mangle',
356                                 chain           => 'PREROUTING',
357                                 rule            => 'interface tun+ MARK set-mark 1',
358                         }
359                         @ferm::rule { 'dsa-vpn-nat':
360                                 table           => 'nat',
361                                 chain           => 'POSTROUTING',
362                                 rule            => 'outerface !tun+ mod mark mark 1 MASQUERADE',
363                         }
364                 }
365                 ubc-enc2bl01,ubc-enc2bl02,ubc-enc2bl09,ubc-enc2bl10: {
366                         @ferm::rule { 'dsa-luca-fixme':
367                                 description     => 'Allow ssh access from mnt and vpn networks',
368                                 rule            => '&SERVICE_RANGE(tcp, 22, ( 172.29.40.0/22 172.29.203.0/24 ))',
369                         }
370                 }
371                 default: {}
372         }
373         # tftp
374         case $::hostname {
375                 abel: {
376                         @ferm::rule { 'dsa-tftp':
377                                 description     => 'Allow tftp access',
378                                 rule            => '&SERVICE_RANGE(udp, 69, ( 172.28.17.0/24 ))'
379                         }
380                 }
381                 master: {
382                         @ferm::rule { 'dsa-tftp':
383                                 description     => 'Allow tftp access',
384                                 rule            => '&SERVICE_RANGE(udp, 69, ( 82.195.75.64/26 192.168.43.0/24 ))'
385                         }
386                 }
387         }
388 }