debian@ap-33ans
This commit is contained in:
0
vpn/endpoint-a.key
Normal file
0
vpn/endpoint-a.key
Normal file
52
vpn/mkwgconf.sh
Normal file
52
vpn/mkwgconf.sh
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
set -e
|
||||
|
||||
AddressAwg=10.0.0.1/32 # Adresse VPN Wireguard extremite A
|
||||
EndpointA=172.16.0.121 # Adresse extremite A
|
||||
PortA=51820 # Port ecoute extremite A
|
||||
AddressBwg=10.0.0.2/32 # Adresse VPN Wireguard extremite B
|
||||
EndpointB=172.16.0.120 # Adresse extremite B
|
||||
PortB=51820 # Port ecoute extremite B
|
||||
|
||||
umask 077 ;
|
||||
wg genkey > endpoint-a.key
|
||||
wg pubkey < endpoint-a.key > endpoint-a.pub
|
||||
|
||||
wg genkey > endpoint-b.key
|
||||
wg pubkey < endpoint-b.key > endpoint-b.pub
|
||||
|
||||
PKA=$(cat endpoint-a.key)
|
||||
pKA=$(cat endpoint-a.pub)
|
||||
PKB=$(cat endpoint-b.key)
|
||||
pKB=$(cat endpoint-b.pub)
|
||||
|
||||
cat <<FINI > wg0-a.conf
|
||||
# local settings for Endpoint A
|
||||
[Interface]
|
||||
PrivateKey = $PKA
|
||||
Address = $AddressAwg
|
||||
ListenPort = $PortA
|
||||
|
||||
# remote settings for Endpoint B
|
||||
[Peer]
|
||||
PublicKey = $pKB
|
||||
Endpoint = ${EndpointB}:$PortB
|
||||
AllowedIPs = $AddressBwg
|
||||
FINI
|
||||
|
||||
|
||||
cat <<FINI > wg0-b.conf
|
||||
# local settings for Endpoint B
|
||||
[Interface]
|
||||
PrivateKey = $PKB
|
||||
Address = $AddressBwg
|
||||
ListenPort = $PortB
|
||||
|
||||
# remote settings for Endpoint A
|
||||
[Peer]
|
||||
PublicKey = $pKA
|
||||
Endpoint = ${EndpointA}:$PortA
|
||||
AllowedIPs = $AddressAwg
|
||||
FINI
|
||||
|
||||
22
vpn/wp.yml
Normal file
22
vpn/wp.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
- name:
|
||||
hosts: ap33-test
|
||||
become: yes
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Installer Wireguard et Wireguardtools
|
||||
apt:
|
||||
- wireguard
|
||||
- wireguard-tools
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
||||
- name: Copie fichier mkwgconfsh
|
||||
ansible.builtin.copy:
|
||||
src: mkwgconf.sh
|
||||
dest: /tmp/
|
||||
|
||||
- name: Lancement du script
|
||||
ansible.builtin.shell:
|
||||
cmd: bash /tmp/mkwgconf.sh
|
||||
Reference in New Issue
Block a user