You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
748 B

  1. #!/bin/bash
  2. mkdir -p /etc/wireguard/keys
  3. umask 077 && wg genkey > /etc/wireguard/keys/private.key && wg pubkey < /etc/wireguard/keys/private.key > /etc/wireguard/keys/public.key && umask 0022
  4. IP4="10.17.25.$IP"
  5. IP6="fd42:42:42:25"`printf '%.2x\n' $IP`"::"
  6. echo "[Interface]
  7. Address = $IP4/32
  8. Address = $IP6/64
  9. SaveConfig = false
  10. PostUp = wg set %i private-key /etc/wireguard/keys/private.key
  11. [Peer]
  12. PublicKey = iu3I09FtiVDIOuiU83JvpfJkg4yiCxolqcFsXbz5Ixc=
  13. AllowedIPs = 10.17.24.0/22, fd42:42:42::/48
  14. Endpoint = vpn.altinea.fr:58212
  15. PersistentKeepalive = 25" > /etc/wireguard/wg0.conf
  16. systemctl enable wg-quick@wg0.service && systemctl daemon-reload && systemctl start wg-quick@wg0
  17. echo -n "Clé publique : "
  18. cat /etc/wireguard/keys/public.key