blob: db1278c7302ec909d6c7d1870cb408a303d22573 (
plain) (
blame)
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
|
---
- name: Wireguard config
hosts: tamriel
remote_user: ansible_worker
become: yes
vars_files:
- secrets.yml
tasks:
- name: install wireguard
apt:
name: wireguard
- name: IPv4 forwarding
sysctl:
name: net.ipv4.ip_forward
value: "1"
state: present
- name: ARP proxy
sysctl:
name: net.ipv4.conf.all.proxy_arp
value: "1"
state: present
- name: Generate wireguard config
template:
src: templates/wg.conf.j2
dest: /etc/wireguard/wg0.conf
- lineinfile:
dest: /etc/network/interfaces
state: present
insertafter: "^source /etc/network/interfaces.d/*"
line: auto wg0
- lineinfile:
dest: /etc/network/interfaces
state: present
insertafter: "^auto wg0"
line: iface wg0 inet static
- interfaces_file:
iface: wg0
option: address
value: 10.0.27.1
- interfaces_file:
iface: wg0
option: netmask
value: 255.255.255.0
- interfaces_file:
iface: wg0
option: pre-up
value: ip link add $IFACE type wireguard
- interfaces_file:
iface: wg0
option: pre-up
value: wg setconf $IFACE /etc/wireguard/$IFACE.conf
- interfaces_file:
iface: wg0
option: post-down
value: ip link del $IFACE
- iptables:
chain: INPUT
match: conntrack
ctstate: ["RELATED","ESTABLISHED"]
jump: ACCEPT
- iptables:
chain: FORWARD
match: conntrack
ctstate: ["RELATED","ESTABLISHED"]
jump: ACCEPT
- iptables:
chain: FORWARD
in_interface: wg0
out_interface: wg0
match: conntrack
ctstate: ["NEW"]
jump: ACCEPT
- iptables:
chain: FORWARD
in_interface: wg0
jump: ACCEPT
- iptables:
table: nat
chain: POSTROUTING
out_interface: ens2
jump: MASQUERADE
|