-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
93 lines (87 loc) · 2.06 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
- name: Ensure iptables is installed # well aware nftables is a thing
become: yes
ansible.builtin.apt:
name: "{{ item.package }}"
state: present
update_cache: yes
when:
- tor_exit_enabled | bool
loop:
- package: iptables-persistent
- package: iptables
- name: Drop outbound tcp ports - ipv4
ansible.builtin.iptables:
chain: OUTPUT
jump: DROP
protocol: tcp
destination_port: "{{ item.port }}"
loop:
- port: 2525
- port: 587
- port: 465
- port: 25
- port: 22
when:
- (tor_exit_enabled | bool) and (not ipv6_enabled | bool)
become: yes
- name: Drop outbound udp ports - ipv4
ansible.builtin.iptables:
chain: OUTPUT
jump: DROP
protocol: udp
destination_port: "{{ item.port }}"
loop:
- port: 2525
- port: 587
- port: 465
- port: 25
- port: 22
become: yes
when:
- (tor_exit_enabled | bool) and (not ipv6_enabled | bool)
- name: Drop outbound tcp ports - ipv6
ansible.builtin.iptables:
ip_version: ipv6
chain: OUTPUT
jump: DROP
protocol: tcp
destination_port: "{{ item.port }}"
loop:
- port: 2525
- port: 587
- port: 465
- port: 25
- port: 22
when:
- (tor_exit_enabled | bool) and (ipv6_enabled | bool)
become: yes
- name: Drop outbound udp ports - ipv6
ansible.builtin.iptables:
ip_version: ipv6
chain: OUTPUT
jump: DROP
protocol: udp
destination_port: "{{ item.port }}"
loop:
- port: 2525
- port: 587
- port: 465
- port: 25
- port: 22
become: yes
when:
- (tor_exit_enabled | bool) and (ipv6_enabled | bool)
- name: Save current state of the firewall in system file - ipv4
community.general.iptables_state:
state: saved
path: /etc/iptables/rules.v4
become: yes
when:
- (tor_exit_enabled | bool) and (not ipv6_enabled | bool)
- name: Save current state of the firewall in system file - ipv6
community.general.iptables_state:
state: saved
path: /etc/iptables/rules.v6
become: yes
when:
- (tor_exit_enabled | bool) and (ipv6_enabled | bool)