#!/bin/bash set -u set -e AddressAwg=10.0.0.1/24 # Adresse VPN Wireguard extremite A EndpointA=172.16.0.122 # Adresse extremite A PortA=51820 # Port ecoute extremite A AddressBwg=10.0.0.2/24 # Adresse VPN Wireguard extremite B <<<<<<< HEAD:ansible/wireguard/mkwgconf.sh EndpointB=172.16.0.120 # Adresse extremite B ======= EndpointB=172.16.0.121 # Adresse extremite B >>>>>>> d29ce732af0fce68c555df54563113473c3a0c5b:ansible/mkwgconf.sh PortB=51820 # Port ecoute extremite B AddressCwg=10.0.0.3/24 # Adresse VPN Wireguard extremite C EndpointC=172.16.0.121 # Adresse extremite C PortC=51820 # Port ecoute extremite C 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 wg genkey > endpoint-c.key wg pubkey < endpoint-c.key > endpoint-c.pub PKA=$(cat endpoint-a.key) pKA=$(cat endpoint-a.pub) PKB=$(cat endpoint-b.key) pKB=$(cat endpoint-b.pub) PKC=$(cat endpoint-c.key) pKC=$(cat endpoint-c.pub) cat < wg0-1.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 # remote settings for Endpoint C [Peer] PublicKey = $pKC Endpoint = ${EndpointC}:$PortC AllowedIPs = $AddressCwg FINI cat < wg0-2.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 cat < wg0-3.conf #local settings for Endpoint C [Interface] PrivateKey = $PKC Address = $AddressCwg ListenPort = $PortC # remote settings for Endpoint A [Peer] PublicKey = $pKA Endpoint = ${EndpointA}:$PortA AllowedIPs = $AddressAwg FINI