mirror of
https://github.com/khuedoan/homelab.git
synced 2025-01-07 05:51:17 +07:00
Generate Wireguard keys
This commit is contained in:
parent
0fc931e62e
commit
75a3e2cddf
@ -7,5 +7,8 @@
|
||||
|
||||
- hosts: all
|
||||
become: yes
|
||||
tasks:
|
||||
- apt:
|
||||
update_cache: yes
|
||||
roles:
|
||||
- name: wireguard
|
||||
|
@ -1,4 +1,18 @@
|
||||
- name: Install Wireguard
|
||||
apt:
|
||||
name: wireguard
|
||||
update_cache: yes
|
||||
|
||||
- name: Generate Wireguard keypair
|
||||
shell: wg genkey | tee /etc/wireguard/privatekey | wg pubkey | tee /etc/wireguard/publickey
|
||||
args:
|
||||
creates: /etc/wireguard/privatekey
|
||||
|
||||
- name: Register private key
|
||||
shell: cat /etc/wireguard/privatekey
|
||||
register: wireguard_private_key
|
||||
changed_when: false
|
||||
|
||||
- name: Register public key
|
||||
shell: cat /etc/wireguard/publickey
|
||||
register: wireguard_public_key
|
||||
changed_when: false
|
||||
|
@ -0,0 +1,6 @@
|
||||
[Interface]
|
||||
Address = {{ interface }}.1
|
||||
ListenPort = 51820
|
||||
PrivateKey = {{ wireguard_private_key }}
|
||||
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
||||
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
|
Loading…
Reference in New Issue
Block a user