Skip to content

Matrice de flux & Hardening

Ce document décrit les flux réseau autorisés entre les services et les règles de durcissement applicables à chaque VM.

Contexte : réseau plat 192.168.1.0/24, pas de VLANs. L'isolation est assurée par UFW sur chaque VM et par le firewall Proxmox sur les hyperviseurs.


Architecture de sécurité

┌─────────────────────────────────────────────────────┐
│                   Freebox (192.168.1.254)            │
│                    │ NAT 80/443 → .20               │
│                    │ SSH → .any:2222 (port non std)  │
└────────────────────┼────────────────────────────────┘
                     │
          ┌──────────┴──────────┐
          │   Firewall Proxmox  │ ← Protection des hyperviseurs
          │   (nftables host)   │
          └──────────┬──────────┘
                     │
          ┌──────────┴──────────┐
          │  UFW sur chaque VM  │ ← Règles par service
          │  Fail2Ban (SSH +     │ ← Anti-bruteforce
          │    services HTTP)   │
          └─────────────────────┘

En flat network, le firewall Proxmox ne peut pas intercepter le trafic entre VMs d'un même bridge — chaque VM est responsable de sa propre sécurité.


Règles UFW générales (toutes les VMs)

ufw default deny incoming
ufw default allow outgoing
ufw limit 2222/tcp comment 'SSH rate-limited port non standard'
ufw allow proto icmp comment 'ICMP'

Matrice des flux par VM

101 — traefik (192.168.1.20)

ufw allow 80/tcp    comment 'HTTP - Let\'s Encrypt HTTP-01 fallback'
ufw allow 443/tcp   comment 'HTTPS - Reverse proxy TLS'
ufw allow from 192.168.1.0/24 to any port 2222 proto tcp comment 'SSH local only'
Direction Source Destination Port Règle
Entrant Internet (Freebox) traefik 80, 443
Entrant 192.168.1.0/24 traefik 2222 ✅ SSH
Entrant Any traefik Autres 🚫
Sortant traefik Toutes VMs .21-.42 443 ✅ Reverse proxy
Sortant traefik api.ovh.com 443 ✅ Challenge DNS LE

Fail2Ban : logs d'accès Traefik — bannissement après 5 requêtes suspectes en 60s.


102 — gitlab (192.168.1.21)

ufw allow from 192.168.1.20 to any port 443 proto tcp comment 'Traefik reverse proxy'
ufw allow from 192.168.1.0/24 to any port 2222 proto tcp comment 'SSH local'
Direction Source Destination Port Règle
Entrant traefik gitlab 443 ✅ Web UI / API
Entrant 192.168.1.0/24 gitlab 2222 ✅ SSH
Entrant Any gitlab Autres 🚫
Sortant gitlab vault 8200 ✅ Secrets pipelines
Sortant gitlab harbor 443 ✅ Push images
Sortant gitlab k3s-master 6443 ✅ API k3s
Sortant gitlab monitoring 9090 ✅ Métriques
Sortant gitlab deb.debian.org 443 ✅ APT

Fail2Ban : logs GitLab (SSH Git + HTTP auth).


103 — vault (192.168.1.22)

ufw allow from 192.168.1.20 to any port 443 proto tcp comment 'Traefik reverse proxy'
ufw allow from 192.168.1.21 to any port 8200 proto tcp comment 'GitLab API'
ufw allow from 192.168.1.30 to any port 8200 proto tcp comment 'Harbor API'
ufw allow from 192.168.1.32 to any port 8200 proto tcp comment 'Keycloak API'
ufw allow from 192.168.1.40 to any port 8200 proto tcp comment 'k3s API'
ufw allow from 192.168.1.0/24 to any port 2222 proto tcp comment 'SSH local'
Direction Source Destination Port Règle
Entrant traefik vault 443 ✅ Web UI
Entrant gitlab / harbor / keycloak / k3s vault 8200 ✅ API interne
Entrant 192.168.1.0/24 vault 2222 ✅ SSH
Entrant Any vault Autres 🚫

201 — harbor (192.168.1.30)

ufw allow from 192.168.1.20 to any port 443 proto tcp comment 'Traefik reverse proxy'
ufw allow from 192.168.1.21 to any port 443 proto tcp comment 'GitLab push/pull'
ufw allow from 192.168.1.0/24 to any port 2222 proto tcp comment 'SSH local'
Direction Source Destination Port Règle
Entrant traefik harbor 443 ✅ Web UI
Entrant gitlab harbor 443 ✅ Push/pull images
Entrant 192.168.1.0/24 harbor 2222 ✅ SSH
Entrant Any harbor Autres 🚫
Sortant harbor vault 8200 ✅ Secrets

202 — monitoring — prometheus/grafana/loki (192.168.1.31)

ufw allow from 192.168.1.20 to any port 443 proto tcp comment 'Traefik - Grafana UI'
ufw allow from 192.168.1.21 to any port 9090 proto tcp comment 'GitLab - métriques'
ufw allow from 192.168.1.0/24 to any port 2222 proto tcp comment 'SSH local'
Direction Source Destination Port Règle
Entrant traefik monitoring 443 ✅ Grafana UI
Entrant gitlab monitoring 9090 ✅ Métriques pipelines
Entrant 192.168.1.0/24 monitoring 2222 ✅ SSH
Entrant Any monitoring Autres 🚫
Sortant monitoring Toutes VMs 9100 ✅ Scrape node_exporter
Sortant monitoring k3s-master/workers 10250 ✅ Scrape kubelet
Sortant monitoring traefik 80/443 ✅ Blackbox exporter

203 — keycloak (192.168.1.32)

ufw allow from 192.168.1.20 to any port 443 proto tcp comment 'Traefik reverse proxy'
ufw allow from 192.168.1.21 to any port 443 proto tcp comment 'GitLab OIDC callback'
ufw allow from 192.168.1.30 to any port 443 proto tcp comment 'Harbor OIDC callback'
ufw allow from 192.168.1.40 to any port 443 proto tcp comment 'ArgoCD OIDC callback'
ufw allow from 192.168.1.41 to any port 443 proto tcp comment 'k3s apps OIDC callback'
ufw allow from 192.168.1.42 to any port 443 proto tcp comment 'k3s apps OIDC callback'
ufw allow from 192.168.1.0/24 to any port 2222 proto tcp comment 'SSH local'
Direction Source Destination Port Règle
Entrant traefik keycloak 443 ✅ Web UI
Entrant gitlab / harbor / k3s keycloak 443 ✅ OIDC callbacks
Entrant 192.168.1.0/24 keycloak 2222 ✅ SSH
Entrant Any keycloak Autres 🚫
Sortant keycloak vault 8200 ✅ Secrets OIDC

204 — defectdojo (192.168.1.33)

ufw allow from 192.168.1.20 to any port 443 proto tcp comment 'Traefik reverse proxy'
ufw allow from 192.168.1.0/24 to any port 2222 proto tcp comment 'SSH local'
Direction Source Destination Port Règle
Entrant traefik defectdojo 443 ✅ Web UI
Entrant 192.168.1.0/24 defectdojo 2222 ✅ SSH
Entrant Any defectdojo Autres 🚫

301 — k3s-master (192.168.1.40)

ufw allow from 192.168.1.21 to any port 6443 proto tcp comment 'GitLab - kubectl'
ufw allow from 192.168.1.41 to any port 6443 proto tcp comment 'k3s worker01'
ufw allow from 192.168.1.42 to any port 6443 proto tcp comment 'k3s worker02'
ufw allow from 192.168.1.31 to any port 10250 proto tcp comment 'Prometheus kubelet'
ufw allow from 192.168.1.20 to any port 443 proto tcp comment 'Traefik Ingress'
ufw allow from 192.168.1.41 to any port 8472 proto udp comment 'Flannel VXLAN worker01'
ufw allow from 192.168.1.42 to any port 8472 proto udp comment 'Flannel VXLAN worker02'
ufw allow from 192.168.1.0/24 to any port 2222 proto tcp comment 'SSH local'
Direction Source Destination Port Règle
Entrant gitlab k3s-master 6443 ✅ API Kubernetes
Entrant k3s-worker* k3s-master 6443 ✅ API
Entrant monitoring k3s-master 10250 ✅ Scrape kubelet
Entrant k3s-worker* k3s-master 8472 UDP ✅ Flannel
Entrant traefik k3s-master 443 ✅ Ingress
Entrant 192.168.1.0/24 k3s-master 2222 ✅ SSH
Entrant Any k3s-master Autres 🚫

302 — k3s-worker01 (192.168.1.41) et 303 — k3s-worker02 (192.168.1.42)

ufw allow out to 192.168.1.40 port 6443 proto tcp comment 'k3s API'
ufw allow from 192.168.1.31 to any port 10250 proto tcp comment 'Prometheus kubelet'
ufw allow from 192.168.1.40 to any port 8472 proto udp comment 'Flannel VXLAN master'
ufw allow from 192.168.1.20 to any port 443 proto tcp comment 'Traefik Ingress'
ufw allow from 192.168.1.0/24 to any port 2222 proto tcp comment 'SSH local'

Hardening SSH (toutes les VMs)

Fichier /etc/ssh/sshd_config.d/hardening.conf :

Port 2222
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
MaxAuthTries 3
MaxSessions 2
ClientAliveInterval 300
ClientAliveCountMax 0
AllowUsers mounik

Déployé par Ansible sur toutes les VMs.


Firewall Proxmox

En complément du UFW de chaque VM, activer le firewall Proxmox :

# Activer au niveau datacenter
pvesh set /cluster/firewall/options --enable 1

# Règles au niveau du nœud (protection hyperviseur)
# /etc/pve/nodes/pve01/host.fw
[INCOMING]
ACCEPT -source 192.168.1.0/24 -p tcp -dport 22
ACCEPT -source 192.168.1.0/24 -p tcp -dport 8006
ACCEPT -source 192.168.1.0/24 -p tcp -dport 3128
DROP -log nolog

Ordre de déploiement des règles

  1. Proxmox : activer firewall hyperviseur
  2. OpenTofu : création des VMs avec cloud-init (clé SSH + UFW basique)
  3. Ansible — hardening de base : SSH (port 2222, clé uniquement), UFW (default deny), Fail2Ban (jail SSH)
  4. Ansible — services : installation et configuration de chaque service
  5. Ansible — affinage UFW : mise à jour des règles par service (ports applicatifs, sources autorisées)