From cfc84351a4d3387483a3c0b547a672dfe9176e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20PICOSSON?= Date: Fri, 1 Aug 2025 23:30:51 +0200 Subject: [PATCH] BLOG: article sur les VPN + tuto Wireguard --- .../Infrastructure/virtual_private_network.md | 127 ++++++++++ .../blog/posts/00_vision_and_objectives.md | 2 +- .../blog/posts/01_deploy_wireguard_vpn.md | 238 ++++++++++++++++++ 3 files changed, 366 insertions(+), 1 deletion(-) create mode 100644 MyWebSite/docs/BASE_CONNAISSANCES/CLOUD_AND_INFRASTRUCTURE/Infrastructure/virtual_private_network.md create mode 100644 MyWebSite/docs/blog/posts/01_deploy_wireguard_vpn.md diff --git a/MyWebSite/docs/BASE_CONNAISSANCES/CLOUD_AND_INFRASTRUCTURE/Infrastructure/virtual_private_network.md b/MyWebSite/docs/BASE_CONNAISSANCES/CLOUD_AND_INFRASTRUCTURE/Infrastructure/virtual_private_network.md new file mode 100644 index 0000000..41efa0f --- /dev/null +++ b/MyWebSite/docs/BASE_CONNAISSANCES/CLOUD_AND_INFRASTRUCTURE/Infrastructure/virtual_private_network.md @@ -0,0 +1,127 @@ +# 🔐 Fonctionnement d’un VPN & UtilitĂ© en Infrastructure RĂ©seau + +## 🧠 Qu’est-ce qu’un VPN (Virtual Private Network) ? + +Un VPN est une **connexion chiffrĂ©e** entre deux points (par exemple, un poste client et un rĂ©seau privĂ© d’entreprise), qui permet de **transporter des donnĂ©es en toute sĂ©curitĂ© via un rĂ©seau public comme Internet**. + +> 🎯 Objectif principal : crĂ©er un tunnel sĂ©curisĂ© entre deux entitĂ©s rĂ©seau. + +--- + +## đŸ§© Composants principaux + +- **Client VPN** : logiciel installĂ© sur un poste. +- **Serveur VPN** : Ă©quipement ou service qui reçoit et dĂ©chiffre le trafic. +- **Tunnel VPN** : canal chiffrĂ© entre le client et le serveur. +- **Protocole VPN** : OpenVPN, IPSec, WireGuard... + +--- + +## đŸ›Ąïž UtilitĂ© dans une infrastructure + +### 🏱 Pour une entreprise : +- AccĂšs sĂ©curisĂ© aux ressources internes depuis l'extĂ©rieur +- Connexion entre plusieurs sites (VPN site-Ă -site) +- SĂ©curisation des donnĂ©es en transit + +### ☁ Cloud / Hybride : +- Relier un rĂ©seau on-premise Ă  un VPC cloud +- AccĂšs sĂ©curisĂ© aux ressources cloud privĂ©es + +--- + +## 📈 Exemple 1 : VPN client → entreprise + +🔍 Flux : + +1. Le client VPN s’authentifie. +1. Un tunnel chiffrĂ© est Ă©tabli. +1. Le trafic est redirigĂ© via le tunnel. +1. L’utilisateur accĂšde au rĂ©seau interne. + +```mermaid +flowchart TD + A[Ordinateur distant] --> B[Client VPN] + B -- Tunnel chiffrĂ© --> C[Internet] + C --> D[Pare-feu / Routeur VPN] + D --> E[Serveur interne] +``` + +## 📈 Exemple 2 : VPN site-Ă -site (entre 2 sites) + +🔍 Flux : + +1. Tunnel IPSec entre les routeurs. +1. AccĂšs direct entre les rĂ©seaux internes. + +```mermaid +flowchart TD + subgraph SiteA [Site A - SiĂšge] + A1[LAN 192.168.1.0/24] + A2[Routeur VPN A] + A1 --> A2 + end + + subgraph Internet + I1 + end + + subgraph SiteB [Site B - Filiale] + B1[LAN 192.168.2.0/24] + B2[Routeur VPN B] + B1 --> B2 + end + + A2 -- Tunnel IPSec --> I1 + B2 -- Tunnel IPSec --> I1 +``` + +## 🔒 Protocoles VPN courants + +| Protocole | Type | Avantages | +|---------------|----------------|--------------------------------------| +| IPSec | Site-to-site | Standard, sĂ©curisĂ©, matĂ©riel supportĂ© | +| OpenVPN | Remote access | SĂ©curisĂ©, open-source, flexible | +| WireGuard | Remote access | LĂ©ger, rapide, moderne | +| SSL VPN | Remote access | Utilisable dans navigateur | + +--- + +## 🔧 Exemple : TĂ©lĂ©travail + +```mermaid +flowchart TD + A[Utilisateur Ă  domicile] --> B[Client OpenVPN] + B -- Tunnel SSL --> C[Internet] + C --> D[Pare-feu VPN] + D --> E[Intranet / NAS / Apps internes] +``` + +### 🔍 Fonctionnement : +- Authentification du client +- Tunnel SSL sĂ©curisĂ© +- AccĂšs aux ressources internes + +--- + +## ⚠ Points de vigilance + +- **Performance** : latence induite par le chiffrement. +- **SĂ©curitĂ©** : bien dĂ©finir les rĂšgles d’accĂšs. +- **Maintenance** : surveillance des certificats et connexions. + +--- + +## đŸ› ïž Outils VPN + +### Logiciels : +- pfSense / OPNsense +- OpenVPN Access Server +- StrongSwan (IPSec) +- WireGuard + +### Cloud : +- AWS VPN Gateway +- Azure VPN Gateway +- GCP Cloud VPN + diff --git a/MyWebSite/docs/blog/posts/00_vision_and_objectives.md b/MyWebSite/docs/blog/posts/00_vision_and_objectives.md index cd3f434..7206877 100644 --- a/MyWebSite/docs/blog/posts/00_vision_and_objectives.md +++ b/MyWebSite/docs/blog/posts/00_vision_and_objectives.md @@ -1,6 +1,6 @@ --- draft: false -date: 2024-07-11 +date: 2025-07-11 categories: - Divers comments: true diff --git a/MyWebSite/docs/blog/posts/01_deploy_wireguard_vpn.md b/MyWebSite/docs/blog/posts/01_deploy_wireguard_vpn.md new file mode 100644 index 0000000..24a5150 --- /dev/null +++ b/MyWebSite/docs/blog/posts/01_deploy_wireguard_vpn.md @@ -0,0 +1,238 @@ + +--- +draft: true +date: 2025-08-01 +categories: + - INFRASTRUCTURE + - CYBER +comments: true +--- + +# 🚀 DĂ©ploiement complet d’un VPN WireGuard (avec automatisation & Docker) + +Ce tutoriel vous guide Ă©tape par Ă©tape pour dĂ©ployer un **VPN WireGuard sĂ©curisĂ©** avec : + +- Scripts d’installation en **Bash et Python** +- GĂ©nĂ©ration automatique des clĂ©s +- Configuration serveur et client +- GĂ©nĂ©ration de QR code pour mobile +- 🚀 Bonus : dĂ©ploiement avec Docker + +--- + +## 📩 PrĂ©requis + +- Serveur Linux (Ubuntu/Debian/CentOS) +- AccĂšs root (`sudo`) +- Port UDP 51820 ouvert +- Python 3, Bash +- Docker (pour partie Docker) + +--- + +## 1. 🔧 Installation de WireGuard (Bash) + +```bash +#!/bin/bash +set -e +sudo apt update && sudo apt upgrade -y +sudo apt install -y wireguard qrencode +sudo mkdir -p /etc/wireguard +sudo chmod 700 /etc/wireguard +``` + +--- + +## 2. 🔑 GĂ©nĂ©ration des clĂ©s serveur et client + +```bash +#!/bin/bash +set -e +cd /etc/wireguard +umask 077 + +wg genkey | tee privatekey | wg pubkey > publickey +mkdir -p clients +CLIENT="client1" +wg genkey | tee clients/$CLIENT-privatekey | wg pubkey > clients/$CLIENT-publickey +``` + +--- + +## 3. ⚙ Configuration serveur `wg0.conf` + +```bash +#!/bin/bash +cd /etc/wireguard +cat < publickey +wg genkey | tee clients/$CLIENT-privatekey | wg pubkey > clients/$CLIENT-publickey + +cat < $WG_DIR/wg0.conf +[Interface] +PrivateKey = $(cat privatekey) +Address = 10.10.10.1/24 +ListenPort = 51820 +SaveConfig = true + +[Peer] +PublicKey = $(cat clients/$CLIENT-publickey) +AllowedIPs = 10.10.10.2/32 +EOF + +cat < $WG_DIR/clients/$CLIENT.conf +[Interface] +PrivateKey = $(cat clients/$CLIENT-privatekey) +Address = 10.10.10.2/24 +DNS = 1.1.1.1 + +[Peer] +PublicKey = $(cat publickey) +Endpoint = YOUR.SERVER.IP:51820 +AllowedIPs = 0.0.0.0/0 +PersistentKeepalive = 25 +EOF + +qrencode -t ansiutf8 < $WG_DIR/clients/$CLIENT.conf +systemctl enable wg-quick@wg0 +systemctl start wg-quick@wg0 +``` + +--- + +## 🐳 DĂ©ploiement avec Docker (optionnel) + +### 📁 Structure du projet + +``` +wireguard-docker/ +├── docker-compose.yml +├── config/ +│ └── wg0.conf +├── entrypoint.sh +``` + +### 📜 `docker-compose.yml` + +```yaml +version: "3.8" +services: + wireguard: + image: linuxserver/wireguard + container_name: wireguard + cap_add: + - NET_ADMIN + - SYS_MODULE + environment: + - PUID=1000 + - PGID=1000 + - SERVERURL=YOUR.SERVER.IP + - SERVERPORT=51820 + - PEERS=client1 + - PEERDNS=1.1.1.1 + - INTERNAL_SUBNET=10.10.10.0 + volumes: + - ./config:/config + - /lib/modules:/lib/modules + ports: + - 51820:51820/udp + restart: unless-stopped +``` + +### 📝 `entrypoint.sh` (optionnel si gĂ©nĂ©ration custom) + +```bash +#!/bin/bash +docker-compose up -d +``` + +--- + +## ✅ VĂ©rification + +```bash +sudo wg show +``` + +--- + +## 🎯 RĂ©sultat + +- Serveur WireGuard actif sur port UDP 51820 +- Client prĂȘt Ă  se connecter avec fichier `.conf` ou QR code +- DĂ©ploiement automatisĂ© en Bash et Python + +--- +