-
Notifications
You must be signed in to change notification settings - Fork 43
/
main.yml
1046 lines (926 loc) · 43 KB
/
main.yml
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
#
# ipr-cnrs.nftables default variables
# ===================================
# Packages and installation [[[
# -----------------------------
# .. envvar:: nft_enabled [[[
#
# Enable or disable support for Nftables on a given host. Disabling this
# option does not remove existing installation and configuration.
#
nft_enabled: true
# ]]]
# .. envvar:: nft_pkg_state [[[
#
# What is the desired state for Nftables packages ? Possible options :
#
# ``present``
# Default. Nftables packages will be installed.
#
# ``absent``
# Ensure to remove Nftables related packages.
nft_pkg_state: 'present'
# ]]]
# .. envvar:: nft_update_repositories [[[
#
# Enable or disable updating of repositories on a given host. Disabling this
# option enables using this role on hosts with limited outgoing connections.
#
nft_update_repositories: true
# ]]]
# .. envvar:: nft_old_pkg_list [[[
#
# List of old Iptables packages to remove to avoid duplicate firewall.
#
nft_old_pkg_list:
- 'iptables'
- 'libiptc0'
# ]]]
# .. envvar:: nft_old_pkg_state [[[
#
# What is the desired state for Iptables packages ? Possible options :
#
# ``absent``
# Default. Ensure to remove Iptables related packages.
#
# ``present``
# Iptables packages will be kept.
nft_old_pkg_state: 'absent'
# ]]]
# .. envvar:: nft_old_pkg_manage [[[
#
# If the old Iptables packages should be managed ? Possible options :
#
# ``true``
# Default. Ensure to apply the required state for Iptables related packages.
#
# ``false``
# Iptables packages will not be touched.
nft_old_pkg_manage: true
# ]]]
# ]]]
# Nftables global rules [[[
# -------------------------
# .. envvar:: nft_global_default_rules [[[
#
# List of global rules (applied on all tables) to configure for all hosts
# inherited from this role.
nft_global_default_rules:
005 established: "{{ nft_templates.allow_established }}"
006 invalid: "{{ nft_templates.drop_invalid_log_no_rst }}"
# ]]]
# .. envvar:: nft_global_rules [[[
#
# List of global rules (applied on all tables) to configure for all hosts
# in the Ansible inventory.
nft_global_rules: {}
# ]]]
# .. envvar:: nft_merged_groups [[[
#
# Enable or disable the ability to merge multiple firewall group variables
nft_merged_groups: false
# ]]]
# .. envvar:: nft_merged_groups_dir [[[
#
# The directory to read the group firewall rules from.
# Relative to the playbook directory.
nft_merged_groups_dir: vars/
# ]]]
# .. envvar:: nft_global_group_rules [[[
#
# List of global rules (applied on all tables) to configure for hosts in
# specific Ansible inventory group.
nft_global_group_rules: {}
# ]]]
# .. envvar:: nft_global_host_rules [[[
#
# List of global rules (applied on all tables) to configure for specific hosts
# in the Ansible inventory.
nft_global_host_rules: {}
# ]]]
# .. envvar:: nft__custom_content [[[
#
# Custom content (tables, include,…) to add in Nftables configuration.
nft__custom_content: ''
# ]]]
# .. envvar:: nft_custom_includes [[[
#
# Custom includes to add into the main Nftables filter configuration.
nft_custom_includes: ''
# ]]]
# .. envvar:: nft_conf_dir_path [[[
#
# Path to the sub directory for Nftables configuration files.
#
# Should be an absolut path and this var will be used in all *_path vars.
nft_conf_dir_path: '/etc/nftables.d'
# ]]]
# .. envvar:: nft_main_conf_path [[[
#
# Path to the main configuration file called by the Systemd Nftables service.
#
# Should be an absolut path.
nft_main_conf_path: '/etc/nftables.conf'
# ]]]
# .. envvar:: nft_main_conf_content [[[
#
# Template used to provide the previous main configuration file.
#
# Must be a relative path from default/ directory of this role or from your
# Ansible inventory directory.
nft_main_conf_content: 'etc/nftables.conf.j2'
# ]]]
# ]]]
# Nftables vars definition [[[
# ----------------------------
#
# These lists allow to define some vars that can be used in nftables rules.
# See the official Nftables wiki page for more informations and examples :
# https://wiki.nftables.org/wiki-nftables/index.php/Scripting#Defining_variables
# .. envvar:: nft_define_default [[[
#
# List of vars definition to configure for all hosts inherited from this role.
nft_define_default:
broadcast and multicast:
desc: 'broadcast and multicast'
name: badcast_addr
value: '{ 255.255.255.255, 224.0.0.1, 224.0.0.251 }'
ip6 broadcast and multicast:
desc: 'broadcast and multicast'
name: ip6_badcast_addr
value: '{ ff02::16 }'
input tcp accepted:
name: in_tcp_accept
value: '{ ssh }'
output tcp accepted:
name: out_tcp_accept
value: '{ http, https, hkp }'
output udp accepted:
name: out_udp_accept
value: '{ bootps, domain, ntp }'
# ]]]
# .. envvar:: nft_define [[[
#
# List of vars definition to configure for all hosts in the Ansible inventory.
nft_define: {}
# ]]]
# .. envvar:: nft_define_group [[[
#
# List of vars definition to configure for hosts in specific
# Ansible inventory group.
nft_define_group: {}
# ]]]
# .. envvar:: nft_define_host [[[
#
# List of vars definition to configure for specific hosts
# in the Ansible inventory.
nft_define_host: {}
# ]]]
# .. envvar:: nft_define_conf_path [[[
#
# Path to the defined vars file to include in the main configuration file
# in order to use the previous defined lists.
#
# Should include the '{{ nft_conf_dir_path }}' var or be an absolut path.
nft_define_conf_path: '{{ nft_conf_dir_path }}/defines.nft'
# ]]]
# .. envvar:: nft_define_conf_content [[[
#
# Template used to provide the previous defined vars file.
#
# Must be a relative path from default/ directory of this role or from your
# Ansible inventory directory.
nft_define_conf_content: 'etc/nftables.d/defines.nft.j2'
# ]]]
# ]]]
# Nftables sets definition [[[
# ----------------------------
#
# These "set" lists allow to define sets that can be used in Nftables rules.
# See the official Nftables wiki page for more informations and examples :
# https://wiki.nftables.org/wiki-nftables/index.php/Sets
# .. envvar:: nft_define_default [[[
#
# List of sets to configure for all hosts inherited from this role.
nft_set_default:
blackhole:
- type ipv4_addr;
- elements = $badcast_addr
ip6blackhole:
- type ipv6_addr;
- elements = $ip6_badcast_addr
in_tcp_accept:
- type inet_service; flags interval;
- elements = $in_tcp_accept
out_tcp_accept:
- type inet_service; flags interval;
- elements = $out_tcp_accept
out_udp_accept:
- type inet_service; flags interval;
- elements = $out_udp_accept
# ]]]
# .. envvar:: nft_set [[[
#
# List of sets to configure for all hosts in the Ansible inventory.
nft_set: {}
# ]]]
# .. envvar:: nft_set_group [[[
#
# List of sets to configure for hosts in specific Ansible inventory group.
nft_set_group: {}
# ]]]
# .. envvar:: nft_set_host [[[
#
# List of sets to configure for specific hosts in the Ansible inventory.
nft_set_host: {}
# ]]]
# .. envvar:: nft_set_conf_path [[[
#
# Path to the "sets" file to include in the main configuration file
# in order to use the previous defined lists.
#
# Should include the '{{ nft_conf_dir_path }}' var or be an absolut path.
nft_set_conf_path: '{{ nft_conf_dir_path }}/sets.nft'
# ]]]
# .. envvar:: nft_set_conf_content [[[
#
# Template used to provide the previous "sets" file.
#
# Must be a relative path from default/ directory of this role or from your
# Ansible inventory directory.
nft_set_conf_content: 'etc/nftables.d/sets.nft.j2'
# ]]]
# ]]]
# Nftables conntrack definition [[[
# ----------------------------
#
# These "conntrack" lists allow to define conntracks that can be used in Nftables.
# See the official Nftables wiki page for more informations and examples :
# https://wiki.nftables.org/wiki-nftables/index.php/Setting_packet_connection_tracking_metainformation
# .. envvar:: nft_conntrack_default [[[
#
# List of conntrack to configure for all hosts inherited from this role.
nft_conntrack_default: {}
# ]]]
# .. envvar:: nft_conntrack [[[
#
# List of conntrack to configure for all hosts in the Ansible inventory.
nft_conntrack: {}
# ]]]
# .. envvar:: nft_conntrack_group [[[
#
# List of conntrack to configure for hosts in specific Ansible inventory group.
nft_conntrack_group: {}
# ]]]
# .. envvar:: nft_conntrack_host [[[
#
# List of conntrack to configure for specific hosts in the Ansible inventory.
nft_conntrack_host: {}
# ]]]
# .. envvar:: nft_conntrack_conf_path [[[
#
# Path to the "conntrack" file to include in the main configuration file
# in order to use the previous defined lists.
#
# Should include the '{{ nft_conf_dir_path }}' var or be an absolut path.
nft_conntrack_conf_path: '{{ nft_conf_dir_path }}/conntrack.nft'
# ]]]
# .. envvar:: nft_conntrack_conf_content [[[
#
# Template used to provide the previous "conntrack" file.
#
# Must be a relative path from default/ directory of this role or from your
# Ansible inventory directory.
nft_conntrack_conf_content: 'etc/nftables.d/conntrack.nft.j2'
# ]]]
# ]]]
# inet filter table rules [[[
# ---------------------------
#
# All these rules will be set up in an inet table in order to filter the
# input and output traffic.
# .. envvar:: nft_input_default_rules [[[
#
# List of input rules to configure for all hosts inherited from this role.
nft_input_default_rules:
000 policy:
- type filter hook input priority 0; policy drop;
001 global:
- jump global
002 localhost: "{{ nft_templates.allow_in_localhost }}"
011 dhcp4: "{{ nft_templates.allow_in_dhcp4 }}"
012 dhcp6: "{{ nft_templates.allow_in_dhcp6 }}"
010 drop unwanted:
- ip daddr @blackhole counter drop
011 drop unwanted ipv6:
- ip6 daddr @ip6blackhole counter drop
013 icmpv6: "{{ nft_templates.icmpv6_in_must_allow }}"
014 icmp: "{{ nft_templates.icmp_in_must_allow }}"
015 ipv4 deprecated: "{{ nft_templates.ip_drop_deprecated }}"
016 ipv6 deprecated: "{{ nft_templates.ip6_drop_deprecated }}"
210 input tcp accepted:
- tcp dport @in_tcp_accept ct state new accept
900 log:
- counter log prefix "IN "
# ]]]
# .. envvar:: nft_input_rules [[[
#
# List of input rules to configure for all hosts in the Ansible inventory.
nft_input_rules: {}
# ]]]
# .. envvar:: nft_input_group_rules [[[
#
# List of input rules to configure for hosts in specific Ansible inventory group.
nft_input_group_rules: {}
# ]]]
# .. envvar:: nft_input_host_rules [[[
#
# List of input rules to configure for specific hosts in the Ansible inventory.
nft_input_host_rules: {}
# ]]]
# .. envvar:: nft_input_conf_path [[[
#
# Path to the input rules file for the filter table to include in the main
# configuration file in order to use the previous defined lists.
#
# Should include the '{{ nft_conf_dir_path }}' var or be an absolut path.
nft_input_conf_path: '{{ nft_conf_dir_path }}/filter-input.nft'
# ]]]
# .. envvar:: nft_input_conf_content [[[
#
# Template used to provide the previous input rules file.
#
# Must be a relative path from default/ directory of this role or from your
# Ansible inventory directory.
nft_input_conf_content: 'etc/nftables.d/filter-input.nft.j2'
# ]]]
# .. envvar:: nft_output_default_rules [[[
#
# List of output rules to configure for all hosts inherited from this role.
nft_output_default_rules:
000 policy:
- type filter hook output priority 0; policy drop;
005 global:
- jump global
006 localhost: "{{ nft_templates.allow_out_localhost }}"
007 icmpv6: "{{ nft_templates.icmpv6_in_must_allow }}"
008 icmp: "{{ nft_templates.icmp_in_must_allow }}"
009 ping6: "{{ nft_templates.icmpv6_allow_ping }}"
010 ping: "{{ nft_templates.icmp_allow_ping }}"
011 dhcp4: "{{ nft_templates.allow_out_dhcp4 }}"
012 dhcp6: "{{ nft_templates.allow_out_dhcp6 }}"
013 mdns: "{{ nft_templates.allow_mdns }}"
013 upnp: "{{ nft_templates.allow_upnp }}"
200 output udp accepted:
- udp dport @out_udp_accept ct state new accept
210 output tcp accepted:
- tcp dport @out_tcp_accept ct state new accept
250 reset ssh: "{{ nft_templates.allow_rst }}"
# ]]]
# .. envvar:: nft_output_rules [[[
#
# List of output rules to configure for all hosts in the Ansible inventory.
nft_output_rules: {}
# ]]]
# .. envvar:: nft_output_group_rules [[[
#
# List of output rules to configure for hosts in specific Ansible inventory group.
nft_output_group_rules: {}
# ]]]
# .. envvar:: nft_output_host_rules [[[
#
# List of output rules to configure for specific hosts in the Ansible inventory.
nft_output_host_rules: {}
# ]]]
# .. envvar:: nft_output_conf_path [[[
#
# Path to the output rules file for the filter table to include in the main
# configuration file in order to use the previous defined lists.
#
# Should include the '{{ nft_conf_dir_path }}' var or be an absolut path.
nft_output_conf_path: '{{ nft_conf_dir_path }}/filter-output.nft'
# ]]]
# .. envvar:: nft_output_conf_content [[[
#
# Template used to provide the previous output rules file.
#
# Must be a relative path from default/ directory of this role or from your
# Ansible inventory directory.
nft_output_conf_content: 'etc/nftables.d/filter-output.nft.j2'
# ]]]
# .. envvar:: nft__forward_table_manage [[[
#
# If the forward table should be managed ? Possible options are :
#
# ``False``
# Default. The forward table is not managed and rules will not be added.
#
# ``True``
# Add the forwarding rules that follow.
nft__forward_table_manage: false
# ]]]
# .. envvar:: nft_forward_default_rules [[[
#
# List of forward rules to configure for all hosts inherited from this role.
nft_forward_default_rules:
000 policy:
- type filter hook forward priority 0; policy drop;
001 global:
- jump global
002 icmp: "{{ nft_templates.icmp_fwd_must_allow }}"
003 icmpv6: "{{ nft_templates.icmpv6_fwd_must_allow }}"
900 log:
- counter log prefix "FWD "
# ]]]
# .. envvar:: nft_forward_rules [[[
#
# List of forward rules to configure for all hosts in the Ansible inventory.
nft_forward_rules: {}
# ]]]
# .. envvar:: nft_forward_group_rules [[[
#
# List of forward rules to configure for hosts in specific Ansible inventory group.
nft_forward_group_rules: {}
# ]]]
# .. envvar:: nft_forward_host_rules [[[
#
# List of forward rules to configure for specific hosts in the Ansible inventory.
nft_forward_host_rules: {}
# ]]]
# .. envvar:: nft_forward_conf_path [[[
#
# Path to the forward rules file for the filter table to include in the main
# configuration file in order to use the previous defined lists.
#
# Should include the '{{ nft_conf_dir_path }}' var or be an absolut path.
nft_forward_conf_path: '{{ nft_conf_dir_path }}/filter-forward.nft'
# ]]]
# .. envvar:: nft_forward_conf_content [[[
#
# Template used to provide the previous forward rules file.
#
# Must be a relative path from default/ directory of this role or from your
# Ansible inventory directory.
nft_forward_conf_content: 'etc/nftables.d/filter-forward.nft.j2'
# ]]]
# ]]]
# .. envvar:: nft__mangle_table_manage [[[
#
# If the mangle table should be managed ? Possible options are :
#
# ``False``
# Default. The mangle table is not managed and rules will not be added.
#
# ``True``
# Add the mangleing rules that follow.
nft__mangle_table_manage: false
# ]]]
# .. envvar:: nft_mangle_default_rules [[[
#
# List of mangle rules to configure for all hosts inherited from this role.
nft_mangle_default_rules: {}
# ]]]
# .. envvar:: nft_mangle_rules [[[
#
# List of mangle rules to configure for all hosts in the Ansible inventory.
nft_mangle_rules: {}
# ]]]
# .. envvar:: nft_mangle_group_rules [[[
#
# List of mangle rules to configure for hosts in specific Ansible inventory group.
nft_mangle_group_rules: {}
# ]]]
# .. envvar:: nft_mangle_host_rules [[[
#
# List of mangle rules to configure for specific hosts in the Ansible inventory.
nft_mangle_host_rules: {}
# ]]]
# .. envvar:: nft_mangle_conf_path [[[
#
# Path to the mangle rules file for the filter table to include in the main
# configuration file in order to use the previous defined lists.
#
# Should include the '{{ nft_conf_dir_path }}' var or be an absolut path.
nft_mangle_conf_path: '{{ nft_conf_dir_path }}/filter-mangle.nft'
# ]]]
# .. envvar:: nft_mangle_conf_content [[[
#
# Template used to provide the previous mangle rules file.
#
# Must be a relative path from default/ directory of this role or from your
# Ansible inventory directory.
nft_mangle_conf_content: 'etc/nftables.d/filter-mangle.nft.j2'
# ]]]
# ]]]
# ip nat table rules [[[
# ---------------------------
#
# All these rules will be set up in an ip table in order to perform some
# Network Address Translation (NAT).
# .. envvar:: nft__nat_table_manage [[[
#
# If the nat table should be managed ? Possible options are :
#
# ``False``
# Default. The nat table is not managed and rules will not be added.
#
# ``True``
# Add the pre and postrouting rules that follow.
nft__nat_table_manage: False
# ]]]
# .. envvar:: nft__nat_default_prerouting_rules [[[
#
# List of prerouting rules to configure for all hosts inherited from this role.
nft__nat_default_prerouting_rules:
000 policy:
- type nat hook prerouting priority 0;
# ]]]
# .. envvar:: nft__nat_prerouting_rules [[[
#
# List of prerouting rules to configure for all hosts in the Ansible inventory.
nft__nat_prerouting_rules: {}
# ]]]
# .. envvar:: nft__nat_group_prerouting_rules [[[
#
# List of prerouting rules to configure for hosts in specific
# Ansible inventory group.
nft__nat_group_prerouting_rules: {}
# ]]]
# .. envvar:: nft__nat_host_prerouting_rules [[[
#
# List of prerouting rules to configure for specific hosts
# in the Ansible inventory.
nft__nat_host_prerouting_rules: {}
# ]]]
# .. envvar:: nft__nat_prerouting_conf_path [[[
#
# Path to the prerouting rules file for the nat table to include in the main
# configuration file in order to use the previous defined lists.
#
# Should include the '{{ nft_conf_dir_path }}' var or be an absolut path.
nft__nat_prerouting_conf_path: '{{ nft_conf_dir_path }}/nat-prerouting.nft'
# ]]]
# .. envvar:: nft__nat_prerouting_conf_content [[[
#
# Template used to provide the previous prerouting rules file.
#
# Must be a relative path from default/ directory of this role or from your
# Ansible inventory directory.
nft__nat_prerouting_conf_content: 'etc/nftables.d/nat-prerouting.nft.j2'
# ]]]
# .. envvar:: nft__nat_default_postrouting_rules [[[
#
# List of postrouting rules to configure for all hosts inherited from this role.
nft__nat_default_postrouting_rules:
000 policy:
- type nat hook postrouting priority 100;
# ]]]
# .. envvar:: nft__nat_postrouting_rules [[[
#
# List of postrouting rules to configure for all hosts in the Ansible inventory.
nft__nat_postrouting_rules: {}
# ]]]
# .. envvar:: nft__nat_group_postrouting_rules [[[
#
# List of postrouting rules to configure for hosts in specific
# Ansible inventory group.
nft__nat_group_postrouting_rules: {}
# ]]]
# .. envvar:: nft__nat_host_postrouting_rules [[[
#
# List of postrouting rules to configure for specific hosts
# in the Ansible inventory.
nft__nat_host_postrouting_rules: {}
# ]]]
# .. envvar:: nft__nat_postrouting_conf_path [[[
#
# Path to the postrouting rules file for the nat table to include in the main
# configuration file in order to use the previous defined lists.
#
# Should include the '{{ nft_conf_dir_path }}' var or be an absolut path.
nft__nat_postrouting_conf_path: '{{ nft_conf_dir_path }}/nat-postrouting.nft'
# ]]]
# .. envvar:: nft__nat_postrouting_conf_content [[[
#
# Template used to provide the previous postrouting rules file.
#
# Must be a relative path from default/ directory of this role or from your
# Ansible inventory directory.
nft__nat_postrouting_conf_content: 'etc/nftables.d/nat-postrouting.nft.j2'
# ]]]
# ]]]
# Service management [[[
# ----------------------
# .. envvar:: nft_service_manage [[[
#
# If the Nftables service should be managed ? Possible options are :
#
# ``True``
# Default. The service is started.
#
# ``False``
# The service will not be touched.
nft_service_manage: true
# ]]]
# .. envvar:: nft_service_name [[[
#
# The service name to manage.
nft_service_name: 'nftables'
# ]]]
# .. envvar:: nft_service_enabled [[[
#
# If the Nftables service should be enabled at startup ? Possible options are :
#
# ``True``
# Default. The service is enabled.
#
# ``False``
# The service is disabled from startup.
nft_service_enabled: true
# ]]]
# .. envvar:: nft_service_unit_from_role [[[
#
# Should the role supply a custom nftables.service unit file?
# Or use the distribution provided one?
#
# ``true``
# Default. Install our service unit, written to 'nft_service_unit_path'.
#
# ``false``
# No service unit will be added. Use distribution provided nftables.service.
nft_service_unit_from_role: true
# ]]]
# .. envvar:: nft_service_unit_path [[[
#
# Path to store Nftables service.
nft_service_unit_path: '/etc/systemd/system/nftables.service'
# ]]]
# .. envvar:: nft_service_unit_content [[[
#
# Template used to provide systemd unit for Nftables service.
nft_service_unit_content: 'etc/systemd/system/nftables.service.j2'
# ]]]
# .. envvar:: nft__service_override_path [[[
#
# Path to store Nftables custom conf.
nft__service_override_path: '/etc/systemd/system/nftables.service.d/override.conf'
# ]]]
# .. envvar:: nft__service_override_content [[[
#
# Template used to provide systemd custom conf for Nftables service.
nft__service_override_content: 'etc/systemd/system/nftables.service.d/override.conf.j2'
# ]]]
# .. envvar:: nft__service_protect [[[
#
# If the systemd unit should have the Protect directives ? Possible options :
#
# ``True``
# Default. Directives will be set (ProtectSystem, ProtectHome,…).
#
# ``False``
# The directives will be ignored.
nft__service_protect: true
# ]]]
# .. envvar:: nft_fail2ban_service_override [[[
#
# Should the systemd unit override file for fail2ban.service be added?
# Options:
# ``True``:
# Default. The fail2ban override file should be present, at path 'nft__fail2ban_service_unit_path'.
#
# ``False``:
# Skip the tasks that put the fail2ban override file into place.
nft_fail2ban_service_override: true
# ]]]
# .. envvar:: nft__fail2ban_service_unit_path [[[
#
# Path to store Fail2Ban custom conf.
nft__fail2ban_service_unit_path: '/etc/systemd/system/fail2ban.service.d/override.conf'
# ]]]
# .. envvar:: nft__fail2ban_service_unit_content [[[
#
# Template used to provide systemd custom conf for Fail2Ban service.
nft__fail2ban_service_unit_content: 'etc/systemd/system/fail2ban.service.d/override.conf.j2'
# ]]]
#
# .. envvar:: nft_debug [[[
#
# Toggle on/off more verbose output. Possible options are:
#
# ''Flase''
# Default. No additional output will be given.
#
# ''True''
# More verbose output.
nft_debug: False
# .. envvar:: nft_backup_conf [[[
#
# If the nftables config files should be backuped when changed ?
# Possible options are:
#
# ``True``
# Default. Backup all nftables config files inside the nftables directory.
#
# ``False``
# Configs will not be backuped.
nft_backup_conf: True
# ]]]
# ]]]
# ]]]
# OS specific variables defaults [[[
# ----------------------------------
# .. envvar:: nft__bin_location [[[
#
# Specify Nftables executable location.
#
nft__bin_location: '/usr/sbin/nft'
# ]]]
# ]]]
# .. envvar:: nft_templates: [[[
#
# Frequently used nft rule collections.
nft_templates:
drop_invalid_log_no_rst:
- ct state invalid tcp flags != rst log prefix "DROP INVALID "
- ct state invalid counter drop
allow_established:
- ct state established,related counter accept
allow_in_localhost:
- iif lo accept
allow_out_localhost:
- oif lo accept
allow_rst:
- tcp flags { rst, psh | ack } counter accept
allow_mdns:
- meta l4proto udp ip6 daddr ff02::fb udp dport mdns counter accept comment "mDNS IPv6 service discovery"
- meta l4proto udp ip daddr 224.0.0.251 udp dport mdns counter accept comment "mDNS IPv4 service discovery"
allow_in_dhcp4:
- meta l4proto udp udp sport bootps udp dport bootpc counter accept comment "DHCPv4"
allow_in_dhcp6:
- meta l4proto udp ip6 saddr fe80::/10 ip6 daddr fe80::/10 udp sport dhcpv6-server udp dport dhcpv6-client counter accept comment "DHCPv6"
allow_out_dhcp4:
- meta l4proto udp udp dport bootps udp sport bootpc counter accept comment "DHCPv4"
allow_out_dhcp6:
- meta l4proto udp ip6 saddr fe80::/10 ip6 daddr fe80::/10 udp dport dhcpv6-server udp sport dhcpv6-client counter accept comment "DHCPv6"
allow_upnp:
- meta l4proto udp ip daddr 239.255.255.250 udp dport 1900 counter accept comment "Multicast UPnP"
icmp_in_must_allow:
- meta l4proto icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } counter accept
icmp_allow_ping:
- meta l4proto icmp icmp type { echo-request, echo-reply } counter accept
icmp_fwd_must_allow:
- meta l4proto icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } counter accept
icmpv6_fwd_must_allow:
# RFC 4890, 4.3.1. Traffic That Must Not Be Dropped
- meta l4proto ipv6-icmp icmpv6 type destination-unreachable counter accept
- meta l4proto ipv6-icmp icmpv6 type packet-too-big counter accept
- meta l4proto ipv6-icmp icmpv6 type time-exceeded icmpv6 code 0 counter accept
- meta l4proto ipv6-icmp icmpv6 type parameter-problem icmpv6 code { 1, 2 } counter accept
icmpv6_in_must_allow:
# RFC 4890, 4.4.1. Traffic That Must Not Be Dropped
- meta l4proto ipv6-icmp icmpv6 type destination-unreachable counter accept
- meta l4proto ipv6-icmp icmpv6 type packet-too-big counter accept
- meta l4proto ipv6-icmp icmpv6 type time-exceeded icmpv6 code 0 counter accept
- meta l4proto ipv6-icmp icmpv6 type parameter-problem icmpv6 code { 1, 2 } counter accept
- meta l4proto ipv6-icmp icmpv6 type nd-router-solicit counter accept
- meta l4proto ipv6-icmp icmpv6 type nd-router-advert counter accept
- meta l4proto ipv6-icmp icmpv6 type nd-neighbor-solicit counter accept
- meta l4proto ipv6-icmp icmpv6 type nd-neighbor-advert counter accept
- meta l4proto ipv6-icmp icmpv6 type ind-neighbor-solicit counter accept
- meta l4proto ipv6-icmp icmpv6 type ind-neighbor-solicit counter accept
- meta l4proto ipv6-icmp ip6 saddr fe80::/10 icmpv6 type mld-listener-query counter accept
- meta l4proto ipv6-icmp ip6 saddr fe80::/10 icmpv6 type mld-listener-report counter accept
- meta l4proto ipv6-icmp ip6 saddr fe80::/10 icmpv6 type mld-listener-reduction counter accept
- meta l4proto ipv6-icmp ip6 saddr fe80::/10 icmpv6 type mld2-listener-report counter accept
- meta l4proto ipv6-icmp icmpv6 type 148 counter accept comment "Certification Path Solicitation (SEND)"
- meta l4proto ipv6-icmp icmpv6 type 149 counter accept comment "Certification Path Advertisement (SEND)"
- meta l4proto ipv6-icmp ip6 saddr fe80::/10 icmpv6 type 151 counter accept comment "Multicast Router Advertisement (MRD)"
- meta l4proto ipv6-icmp ip6 saddr fe80::/10 icmpv6 type 152 counter accept comment "Multicast Router Solicitation (MRD)"
- meta l4proto ipv6-icmp ip6 saddr fe80::/10 icmpv6 type 153 counter accept comment "Multicast Router Termination (MRD)"
icmpv6_in_should_allow:
# RFC 4890, 4.3.2. Traffic That Normally Should Not Be Dropped
- meta l4proto ipv6-icmp icmpv6 type time-exceeded icmpv6 code 1 counter accept
- meta l4proto ipv6-icmp icmpv6 type parameter-problem icmpv6 code 0 counter accept
icmpv6_in_allow_mobip:
# RFC 4890, 4.3.2. Traffic That Normally Should Not Be Dropped
- meta l4proto ipv6-icmp icmpv6 type 144 counter accept comment "Home Agent Address Discovery Request Message"
- meta l4proto ipv6-icmp icmpv6 type 145 counter accept comment "Home Agent Address Discovery Reply Message"
- meta l4proto ipv6-icmp icmpv6 type 146 counter accept comment "Mobile Prefix Solicitation"
- meta l4proto ipv6-icmp icmpv6 type 147 counter accept comment "Mobile Prefix Advertisement"
icmpv6_in_allow_dropped_anyway:
# RFC 4890, 4.4.3. Traffic That Will Be Dropped Anyway -- No Special Attention Needed
- meta l4proto ipv6-icmp icmpv6 type router-renumbering counter accept
- meta l4proto ipv6-icmp icmpv6 type 150 counter drop comment "Seamoby Experimental"
icmpv6_in_allow_redirect:
# RFC 4890, 4.4.4. Traffic for Which a Policy Should Be Defined
- meta l4proto ipv6-icmp icmpv6 type nd-redirect counter accept
icmpv6_in_drop_redirect:
# RFC 4890, 4.4.4. Traffic for Which a Policy Should Be Defined
- meta l4proto ipv6-icmp icmpv6 type nd-redirect counter drop
icmpv6_in_allow_nodeinfo:
# RFC 4890, 4.4.4. Traffic for Which a Policy Should Be Defined
- meta l4proto ipv6-icmp icmpv6 type 139 counter accept comment "Node Information Query"
- meta l4proto ipv6-icmp icmpv6 type 140 counter accept comment "Node Information Response"
icmpv6_in_drop_nodeinfo:
# RFC 4890, 4.4.4. Traffic for Which a Policy Should Be Defined
- meta l4proto ipv6-icmp icmpv6 type 139 counter drop comment "Node Information Query"
- meta l4proto ipv6-icmp icmpv6 type 140 counter drop comment "Node Information Response"
icmpv6_in_allow_unallocated:
# RFC 4890, 4.4.4. Traffic for Which a Policy Should Be Defined
- meta l4proto ipv6-icmp icmpv6 type 5-99 counter accept comment "Unallocated error ICMPv6"
- meta l4proto ipv6-icmp icmpv6 type 102-126 counter accept comment "Unallocated error ICMPv6"
icmpv6_in_drop_unallocated:
# RFC 4890, 4.4.4. Traffic for Which a Policy Should Be Defined
- meta l4proto ipv6-icmp icmpv6 type 5-99 counter drop comment "Unallocated error ICMPv6"
- meta l4proto ipv6-icmp icmpv6 type 102-126 counter drop comment "Unallocated error ICMPv6"
icmpv6_in_drop_dangerous:
# RFC 4890, 4.4.5. Traffic That Should Be Dropped Unless a Good Case Can Be Made
- meta l4proto ipv6-icmp icmpv6 type { 100, 101, 200, 201 } counter drop comment "Experimental ICMPv6 allocations"
- meta l4proto ipv6-icmp icmpv6 type { 127, 255 } counter drop comment "ICMPv6 extension numbers"
- meta l4proto ipv6-icmp icmpv6 type 154-199 counter drop comment "Unallocated informational ICMPv6"
- meta l4proto ipv6-icmp icmpv6 type 202-254 counter drop comment "Unallocated informational ICMPv6"
icmpv6_allow_ping:
- meta l4proto ipv6-icmp icmpv6 type { echo-request, echo-reply } counter accept
icmpv6_fwd_should_allow:
# RFC 4890, 4.3.2. Traffic That Normally Should Not Be Dropped
- meta l4proto ipv6-icmp icmpv6 type time-exceeded icmpv6 code 1 counter accept
- meta l4proto ipv6-icmp icmpv6 type parameter-problem icmpv6 code 0 counter accept
icmpv6_fwd_allow_mobip:
# RFC 4890, 4.3.2. Traffic That Normally Should Not Be Dropped
- meta l4proto ipv6-icmp icmpv6 type 144 counter accept comment "Home Agent Address Discovery Request Message"
- meta l4proto ipv6-icmp icmpv6 type 145 counter accept comment "Home Agent Address Discovery Reply Message"
- meta l4proto ipv6-icmp icmpv6 type 146 counter accept comment "Mobile Prefix Solicitation"
- meta l4proto ipv6-icmp icmpv6 type 147 counter accept comment "Mobile Prefix Advertisement"
icmpv6_fwd_allow_dropped_anyway:
# RFC 4890, 4.3.3. Traffic That Will Be Dropped Anyway
- meta l4proto ipv6-icmp icmpv6 type nd-router-solicit ip6 hoplimit 255 counter accept
- meta l4proto ipv6-icmp icmpv6 type nd-router-advert ip6 hoplimit 255 counter accept
- meta l4proto ipv6-icmp icmpv6 type nd-neighbor-solicit ip6 hoplimit 255 counter accept
- meta l4proto ipv6-icmp icmpv6 type nd-neighbor-advert ip6 hoplimit 255 counter accept
- meta l4proto ipv6-icmp icmpv6 type nd-redirect ip6 hoplimit 255 counter accept
- meta l4proto ipv6-icmp icmpv6 type ind-neighbor-solicit ip6 hoplimit 255 counter accept
- meta l4proto ipv6-icmp icmpv6 type ind-neighbor-solicit ip6 hoplimit 255 counter accept
- meta l4proto ipv6-icmp ip6 saddr fe80::/10 icmpv6 type mld-listener-query counter accept
- meta l4proto ipv6-icmp ip6 saddr fe80::/10 icmpv6 type mld-listener-report counter accept
- meta l4proto ipv6-icmp ip6 saddr fe80::/10 icmpv6 type mld-listener-reduction counter accept
- meta l4proto ipv6-icmp ip6 saddr fe80::/10 icmpv6 type mld2-listener-report counter accept
- meta l4proto ipv6-icmp icmpv6 type 148 ip6 hoplimit 255 counter accept comment "Certification Path Solicitation (SEND)"
- meta l4proto ipv6-icmp icmpv6 type 149 ip6 hoplimit 255 counter accept comment "Certification Path Advertisement (SEND)"
- meta l4proto ipv6-icmp ip6 saddr fe80::/10 icmpv6 type 151 ip6 hoplimit 1 counter accept comment "Multicast Router Advertisement (MRD)"
- meta l4proto ipv6-icmp ip6 saddr fe80::/10 icmpv6 type 152 ip6 hoplimit 1 counter accept comment "Multicast Router Solicitation (MRD)"
- meta l4proto ipv6-icmp ip6 saddr fe80::/10 icmpv6 type 153 ip6 hoplimit 1 counter accept comment "Multicast Router Termination (MRD)"
icmpv6_fwd_allow_experimental:
# RFC 4890, 4.3.4. Traffic for Which a Policy Should Be Defined
- meta l4proto ipv6-icmp icmpv6 type 150 counter drop comment "Seamoby Experimental"
icmpv6_fwd_drop_experimental:
# RFC 4890, 4.3.4. Traffic for Which a Policy Should Be Defined
- meta l4proto ipv6-icmp icmpv6 type 150 counter drop comment "Seamoby Experimental"
icmpv6_fwd_allow_unallocated:
# RFC 4890, 4.3.4. Traffic for Which a Policy Should Be Defined
- meta l4proto ipv6-icmp icmpv6 type 5-99 counter drop comment "Unallocated error ICMPv6"
- meta l4proto ipv6-icmp icmpv6 type 102-126 counter drop comment "Unallocated error ICMPv6"
- meta l4proto ipv6-icmp icmpv6 type 154-199 counter drop comment "Unallocated informational ICMPv6"
- meta l4proto ipv6-icmp icmpv6 type 202-254 counter drop comment "Unallocated informational ICMPv6"
icmpv6_fwd_drop_unallocated:
# RFC 4890, 4.3.4. Traffic for Which a Policy Should Be Defined
- meta l4proto ipv6-icmp icmpv6 type 5-99 counter drop comment "Unallocated error ICMPv6"
- meta l4proto ipv6-icmp icmpv6 type 102-126 counter drop comment "Unallocated error ICMPv6"
- meta l4proto ipv6-icmp icmpv6 type 154-199 counter drop comment "Unallocated informational ICMPv6"