Projet

Général

Profil

Wireguard » Historique » Version 18

Matthieu Herrb, 21/05/2019 11:31
deplace contenu pour adhérent·e·s

1 10 Matthieu Herrb
{{>toc}}
2 10 Matthieu Herrb
3 1 Matthieu Herrb
h1. Wireguard
4 1 Matthieu Herrb
5 13 Matthieu Herrb
6 13 Matthieu Herrb
h2. Configuration serveur sur h10
7 13 Matthieu Herrb
8 13 Matthieu Herrb
Cette section ne concerne que les bénévoles qui veulent aider, ou les curieu·ses·x qui veulent voir comment c'est fait de l'autre coté.
9 13 Matthieu Herrb
10 13 Matthieu Herrb
h3. Routage
11 13 Matthieu Herrb
12 13 Matthieu Herrb
Sur h7: router les IP via h10:
13 13 Matthieu Herrb
14 13 Matthieu Herrb
Exemple:
15 13 Matthieu Herrb
<pre>
16 13 Matthieu Herrb
ip r add 185.119.170.3/32 via 91.224.148.143 dev eth3.3131
17 13 Matthieu Herrb
ip -6 r add 2a03:7220:8087:300::/56 via fe80::80:8f dev eth3.3131
18 13 Matthieu Herrb
</pre>
19 13 Matthieu Herrb
20 13 Matthieu Herrb
C'est fait automatiquement en indiquant @wireguard@ dans @ip_ttnn.txt@ comme route pour une IPv4
21 13 Matthieu Herrb
22 13 Matthieu Herrb
h3.Config globale sur h10
23 13 Matthieu Herrb
24 13 Matthieu Herrb
<pre>
25 13 Matthieu Herrb
# modprobe wireguard
26 13 Matthieu Herrb
# umask 077
27 13 Matthieu Herrb
# wg genkey > /etc/wireguard/private
28 13 Matthieu Herrb
# wg pubkey < /etc/wireguard/private > /etc/wireguard/public
29 13 Matthieu Herrb
# ip link add dev wg0 type wireguard
30 13 Matthieu Herrb
# ip a add dev wg0 10.99.0.1/32
31 13 Matthieu Herrb
# ip -6 a add dev wg0 fe80::31/128
32 13 Matthieu Herrb
# wg set wg0 private-key ./private listen-port 51820
33 13 Matthieu Herrb
# ip link set wg0 up
34 13 Matthieu Herrb
</pre>
35 13 Matthieu Herrb
36 13 Matthieu Herrb
37 13 Matthieu Herrb
h3. Pour chaque client, sur h10:
38 13 Matthieu Herrb
39 13 Matthieu Herrb
Exemple:
40 13 Matthieu Herrb
<pre>
41 13 Matthieu Herrb
# wg set wg0 peer <clé publique du client> allowed-ips 185.119.170.3/32,2a03:7220:8087:300::/56
42 13 Matthieu Herrb
# ip r add 185.119.170.3/32 dev wg0
43 13 Matthieu Herrb
# ip -6 r add 2a03:7220:8087:300::/56 dev wg0
44 13 Matthieu Herrb
</pre>
45 13 Matthieu Herrb
46 13 Matthieu Herrb
47 13 Matthieu Herrb
48 13 Matthieu Herrb
h2. Old tests VPN tetaneutral sur h9
49 1 Matthieu Herrb
50 9 Matthieu Herrb
h3. Configuration
51 10 Matthieu Herrb
52 11 Matthieu Herrb
Sur h7: router les IP via h9:
53 1 Matthieu Herrb
<pre>
54 11 Matthieu Herrb
ip r add 185.119.170.3/32 via 91.224.148.143 dev eth3.3131
55 11 Matthieu Herrb
ip -6 r add 2a03:7220:8087:300::/56 via fe80::80:8f dev eth3.3131
56 11 Matthieu Herrb
</pre>
57 11 Matthieu Herrb
58 11 Matthieu Herrb
Sur h9 config globale:
59 11 Matthieu Herrb
60 11 Matthieu Herrb
<pre>
61 1 Matthieu Herrb
# modprobe wireguard
62 1 Matthieu Herrb
# umask 077
63 1 Matthieu Herrb
# wg genkey > /etc/wireguard/private
64 1 Matthieu Herrb
# wg pubkey < /etc/wireguard/private > /etc/wireguard/public
65 1 Matthieu Herrb
# ip link add dev wg0 type wireguard
66 1 Matthieu Herrb
# ip a add dev wg0 10.99.0.1/32
67 1 Matthieu Herrb
# ip -6 a add dev wg0 fe80::31/128
68 6 Matthieu Herrb
# wg set wg0 private-key ./private listen-port 55769
69 1 Matthieu Herrb
# ip link set wg0 up
70 1 Matthieu Herrb
</pre>
71 1 Matthieu Herrb
72 11 Matthieu Herrb
73 1 Matthieu Herrb
Pour chaque client, sur h9:
74 1 Matthieu Herrb
75 1 Matthieu Herrb
<pre>
76 1 Matthieu Herrb
# wg set wg0 peer <clé publique du client> allowed-ips 185.119.170.3/32,2a03:7220:8087:300::/56
77 1 Matthieu Herrb
# ip r add 185.119.170.3/32 dev wg0
78 2 Matthieu Herrb
# ip -6 r add 2a03:7220:8087:300::/56 dev wg0
79 1 Matthieu Herrb
</pre>
80 1 Matthieu Herrb
81 11 Matthieu Herrb
h4. Config client openwrt
82 11 Matthieu Herrb
83 11 Matthieu Herrb
Dans @/etc/config/network@
84 11 Matthieu Herrb
85 1 Matthieu Herrb
<pre>
86 1 Matthieu Herrb
config interface 'vpn0'
87 1 Matthieu Herrb
        option proto 'wireguard'
88 5 Matthieu Herrb
        option private_key '<clé privée>'
89 1 Matthieu Herrb
        list addresses '185.119.170.3/32'
90 5 Matthieu Herrb
        list addresses '2a03:7220:8087:300::1/56'
91 1 Matthieu Herrb
92 1 Matthieu Herrb
config wireguard_vpn0
93 1 Matthieu Herrb
        option public_key 'DsIeOCRs/5uYdi8rLiBzRNmN4zUzKCQRqY3Sbl8NS0A=' # La clé publique de h9
94 1 Matthieu Herrb
        option route_allowed_ips '1'
95 1 Matthieu Herrb
        option endpoint_host '91.224.148.143'
96 1 Matthieu Herrb
        option endpoint_port '55769'
97 4 Matthieu Herrb
        option persistent_keepalive '25'
98 2 Matthieu Herrb
        list allowed_ips '0.0.0.0/0'
99 3 Matthieu Herrb
        list allowed_ips '::/0'
100 1 Matthieu Herrb
</pre>
101 1 Matthieu Herrb
102 12 Matthieu Herrb
h4. Config client debian 
103 11 Matthieu Herrb
104 11 Matthieu Herrb
Dans @/etc/rc.local@ pas de route par défaut configurée
105 11 Matthieu Herrb
106 1 Matthieu Herrb
<pre>
107 11 Matthieu Herrb
# wireguard
108 11 Matthieu Herrb
# route vers h9 
109 11 Matthieu Herrb
/bin/ip route add 91.224.148.143/32 via 192.168.31.200 dev eth0
110 11 Matthieu Herrb
111 11 Matthieu Herrb
/sbin/modprobe wireguard
112 11 Matthieu Herrb
/bin/ip link add dev wg0 type wireguard
113 11 Matthieu Herrb
/bin/ip a add dev wg0 185.119.170.2
114 11 Matthieu Herrb
/bin/ip -6 a add dev wg0 2a03:7220:8087:200::1/56
115 11 Matthieu Herrb
/usr/bin/wg set wg0 private-key /etc/wireguard/private 
116 11 Matthieu Herrb
/usr/bin/wg set wg0 peer DsIeOCRs/5uYdi8rLiBzRNmN4zUzKCQRqY3Sbl8NS0A= \
117 11 Matthieu Herrb
        endpoint  91.224.148.143:55769 \
118 11 Matthieu Herrb
        allowed-ips 0.0.0.0/0,::/0 \
119 11 Matthieu Herrb
        persistent-keepalive 25
120 11 Matthieu Herrb
/bin/ip link set wg0 up
121 11 Matthieu Herrb
122 11 Matthieu Herrb
/bin/ip route add 10.99.0.1 dev wg0
123 11 Matthieu Herrb
/bin/ip route add default via 10.99.0.1 dev wg0
124 11 Matthieu Herrb
/bin/ip -6 route add default via fe80::31 dev wg0
125 9 Matthieu Herrb
</pre>
126 9 Matthieu Herrb
127 9 Matthieu Herrb
h3. Status
128 9 Matthieu Herrb
129 9 Matthieu Herrb
<pre>
130 9 Matthieu Herrb
root@h9:~# wg show
131 9 Matthieu Herrb
interface: wg0
132 9 Matthieu Herrb
  public key: DsIeOCRs/5uYdi8rLiBzRNmN4zUzKCQRqY3Sbl8NS0A=
133 9 Matthieu Herrb
  private key: (hidden)
134 9 Matthieu Herrb
  listening port: 55769
135 9 Matthieu Herrb
136 9 Matthieu Herrb
peer: y4ydCem0bUQpryyiTxS2eMPtoHLD5iOGqth1f9xkfww=
137 9 Matthieu Herrb
  endpoint: 176.158.4.203:57103
138 9 Matthieu Herrb
  allowed ips: 185.119.170.3/32, 2a03:7220:8087:300::/56
139 9 Matthieu Herrb
  latest handshake: 1 minute, 27 seconds ago
140 9 Matthieu Herrb
  transfer: 1.08 MiB received, 1.92 MiB sent
141 9 Matthieu Herrb
142 9 Matthieu Herrb
peer: hUT6WhmUw6yRpwLX3R9Rh/8x1lZDk9JeX56We7zVvWc=
143 9 Matthieu Herrb
  endpoint: 176.158.4.203:57658
144 9 Matthieu Herrb
  allowed ips: 185.119.170.2/32, 2a03:7220:8087:200::/56
145 3 Matthieu Herrb
  latest handshake: 1 minute, 38 seconds ago
146 7 Matthieu Herrb
  transfer: 107.09 KiB received, 208.19 KiB sent
147 7 Matthieu Herrb
</pre>
148 7 Matthieu Herrb
149 8 Matthieu Herrb
h3. Déploiement
150 8 Matthieu Herrb
151 8 Matthieu Herrb
Remarque: clé privée des clients à garder privée...
152 8 Matthieu Herrb
153 8 Matthieu Herrb
Deux modes possibles :
154 8 Matthieu Herrb
155 8 Matthieu Herrb
# sur un PC de l'adhérent·e
156 8 Matthieu Herrb
157 8 Matthieu Herrb
 * iel installe wireguard
158 8 Matthieu Herrb
 * iel génère la clé privé et envoie à ttnn la clé publique
159 8 Matthieu Herrb
 * ttnn envoie la config à l'adhérent·e
160 8 Matthieu Herrb
 * Avantages :
161 8 Matthieu Herrb
162 8 Matthieu Herrb
  * performance
163 8 Matthieu Herrb
  * utilisable en mobilité
164 8 Matthieu Herrb
 * Inconvénients :
165 8 Matthieu Herrb
166 8 Matthieu Herrb
  * difficulté assistance installation initiale / dépannage
167 8 Matthieu Herrb
# Sur un routeur fourni par l'association
168 8 Matthieu Herrb
169 8 Matthieu Herrb
 * routeur un peu costaud (ZBT ou Archer C7)
170 8 Matthieu Herrb
 * on génère un firmware avec la config en dur
171 8 Matthieu Herrb
 * on fournit le routeur à l'adhérent·e (comme pour un accès radio)
172 8 Matthieu Herrb
 * Avantages :
173 8 Matthieu Herrb
174 8 Matthieu Herrb
  * simplicité pour l'adhérent·e
175 8 Matthieu Herrb
  * assistance
176 8 Matthieu Herrb
 * Inconvénients :
177 8 Matthieu Herrb
178 8 Matthieu Herrb
  * performances (à confirmer)
179 1 Matthieu Herrb
  * moins mobile