« Unix::wireguard » : différence entre les versions

De wiki_pcwiki2
Aller à la navigationAller à la recherche
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 30 : Ligne 30 :
  [[Configuration serveur wireguard OVH1]]
  [[Configuration serveur wireguard OVH1]]
  [[Configuration serveur wireguard OVH2]]
  [[Configuration serveur wireguard OVH2]]
'''Configuration du serveur OVH1:'''
# OVH1::/etc/wireguard/wg1.conf
# Le 27/06/2024:
[Interface]
Address = 10.0.1.1/32
ListenPort = 51821
# Private Key du serveur OVH1:
PrivateKey = aGMBMMT0HlH3Q/FOJ6yDh6OHu/75wjg2cTEUq2/MWnc=
PostUp  = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eno1 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eno1 -j MASQUERADE
[Peer]
# Clé du client SRV05  (192.168.1.5)
Publickey = DUnIaFntjOqb3EH9zVq0LFBRccoH/txJ08W3rv8B73M=
PersistentKeepalive = 20
AllowedIPs = 10.0.1.5/32
[Peer]
# Clé du client SRV06  (192.168.1.6)
Publickey = 8j0LhP+YWqlyH9Yj30lIakibvlEeIPRfsCzWmKJhfBQ=
PersistentKeepalive = 20
AllowedIPs = 10.0.1.6/32
[Peer]
# Clé du client XPS13  (192.168.1.13)
Publickey = IxCXwhfZ5Lf0yYUSZR5g+5aeRkFAmNIKLtHVd9MX0Cc=
PersistentKeepalive = 20
AllowedIPs = 10.0.1.13/32
[Peer]
# Clé du client SRV17  (192.168.1.17)
Publickey = 7wBupLOQktTuwVecurg9+ZgcgwqIzHbRAfgZVnDMfws=
PersistentKeepalive = 20
AllowedIPs = 10.0.1.17/32
[Peer]
# Clé du client SRV18  (192.168.1.18)
Publickey = BPBurdxfynCJtK6yh4fVlD6zF+rH03ZE7QQuqulQlSs=
PersistentKeepalive = 20
AllowedIPs = 10.0.1.18/32
[Peer]
# Clé du client SRV09  (192.168.1.25)
Publickey = acVxZhdBXe87kPX4ARmhrKZ4RcZlZFgUcZZo2iEgei8=
PersistentKeepalive = 20
AllowedIPs = 10.0.1.25/32
# OVH2::/etc/wireguard/wg0.conf
[Interface]
# Le 25/06/2024:
Address = 10.11.12.2/32
ListenPort = 51820
   
   
  # Private Key du serveur OVH2:
  [[Configuration d'un client wireguard OVH1]]
PrivateKey = gBHG/+MoOtoQoMiAtx0IjegwOejtHO4ccIgM3ljweUc=
  [[Configuration d'un client wireguard OVH2]]
 
PostUp  = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eno3 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eno3 -j MASQUERADE
[Peer]
        # Clé du client SRV17
        Publickey = 7wBupLOQktTuwVecurg9+ZgcgwqIzHbRAfgZVnDMfws=
        PersistentKeepalive = 20
        Endpoint = 51.68.207.177:51820
        AllowedIPs = 10.11.12.3/32
[Peer]
        # Clé du client SRV09
        Publickey = acVxZhdBXe87kPX4ARmhrKZ4RcZlZFgUcZZo2iEgei8=
        PersistentKeepalive = 20
        Endpoint = 51.68.207.177:51820
        AllowedIPs = 10.11.12.1/32
  [Peer]
        # Clé du client SRV18
        Publickey = BPBurdxfynCJtK6yh4fVlD6zF+rH03ZE7QQuqulQlSs=
        PersistentKeepalive = 20
        Endpoint = 51.68.207.177:51820
        AllowedIPs = 10.11.12.18/32
[Peer]
        # Clé du client XPS13
        Publickey = IxCXwhfZ5Lf0yYUSZR5g+5aeRkFAmNIKLtHVd9MX0Cc=
        PersistentKeepalive = 20
        Endpoint = 51.68.207.177:51820
        AllowedIPs = 10.11.12.13/32
 
'''Configuration d'un client:'''
# SRV09::/etc/wireguard/wg0.conf
[Interface]
Address = 10.11.12.1/32
ListenPort = 51820
DNS=8.8.8.8
 
# Private Key du client SRV09:
  PrivateKey = WFqHoWYxwQ4rxha4dAXLhJF4Oxq5J3PlVjrqmdvpm3s=
[Peer]
        # Clé du serveur (OVH2)
        Publickey = cfylLxAtWKBu+5HEoGd3qYjhzCRyAxvkZEt3BIkd+2E=
        PersistentKeepalive = 20
        Endpoint = 51.68.207.177:51820
        AllowedIPs = 10.11.12.0/24
 
'''''NB: Ne pas oublier le mur de feu (10.0.0.0/16 dans /etc/iptables/lst/whi*int*'''''

Version du 27 juin 2024 à 15:04

KEYWORDS: WIREGUARD, VPN

Le 25/06/2024:
Bouygues a l'air de merdouiller sur les ports forwarding (exemple: 1113 & 1114 ok, ssh pas ok !)
J'ai donc prévu de mettre un VPN entre OVH[1,2] et Bois Dery et j'ai choisi wireguard.
apt install -y wireguard
Préliminaires:
Il y a deux cas de figure: avec ou sans mur de feu sur le client
- Sans mur de feu: ok
- Avec mur de feu (cg srv09 ou srv06): il faut modifier:
  lst/whitelist.int.lst: ajouter 10.0.0.0/0
  lst/whitelist.ext.lst: vérifier que l'IP externe du serveur wireguard est bien dedans
  iptables.conf: ajputer strIfaceWg1 et/ou strIfaceWg2
  rules/whitelist: ajouter	$strIptablesPath -A INPUT -i $strIfaceWg1 -p all -s $ip -j ACCEPT

$strIptablesPath -A OUTPUT -o $strIfaceWg1 -p all -d $ip -j ACCEPT

$strIptablesPath -A INPUT -i $strIfaceWg2 -p all -s $ip -j ACCEPT $strIptablesPath -A OUTPUT -o $strIfaceWg2 -p all -d $ip -j ACCEPT

Avant tout, il faut modifier /etc/sysctl.conf:
# Pour Wireguard (25/06/2024):
net.ipv4.ip_forward=1
net.ipv4.conf.all.proxy_arp=1
Puis, sysctl -p pour rendre ces ordres pérennes.

Puis installer le paquet resolvonf
 
Ensuite, attention, les fichiers de conf sont très sensibles aux /32, /24 ... :
Configuration serveur wireguard OVH1
Configuration serveur wireguard OVH2

Configuration d'un client wireguard OVH1
Configuration d'un client wireguard OVH2