Wireguard » Historique » Version 27
xavier, 15/08/2019 19:05
WIP
1 | 21 | xavier | {{>toc}} |
---|---|---|---|
2 | |||
3 | 1 | sacha | # Wireguard |
4 | |||
5 | 14 | sacha | Le VPN Kiss, utilisant les dernières règles de l'art, construit pour être audité & performant ! au revoir IPSec & OpenVPN ! |
6 | 20 | xavier | |
7 | 25 | xavier | Aquilenet utilise Wireguard avec succès depuis mi-2019, pour interconnecter une partie de ses [[îlots]] à son [[infrastructure:|cœur de réseau]]. |
8 | |||
9 | 26 | xavier | ## *Work In Progress* |
10 | |||
11 | 27 | xavier | Le site officiel de Wireguard est clair, c'est pas sec, même si ça marche bien : |
12 | |||
13 | > WireGuard is not yet complete. You should not rely on this code. It has not undergone proper degrees of security auditing and the protocol is still subject to change. We're working toward a stable 1.0 release, but that time has not yet come. There are experimental snapshots tagged with "0.0.YYYYMMDD", but these should not be considered real releases and they may contain security vulnerabilities (which would not be eligible for CVEs, since this is pre-release snapshot software). If you are packaging WireGuard, you must keep up to date with the snapshots. |
||
14 | |||
15 | Le principal auteur de Wireguard recommande aux utilisateurs de ne **pas** employer le client [TunSafe](http://tunsafe.com/), dont le [code source](https://github.com/TunSafe/TunSafe) est à cette date (août 2019) à l'arrêt depuis au moins 7 mois. |
||
16 | |||
17 | Wireguard n'est pas un remplacement complet d'une solution comme OpenVPN. Notamment, c'est une solution « niveau 3 » donc pas de DHCP possible, le protocole n'offre pas (encore ?) d'alternative pour l'adressage des hôtes : nous pré-adressons actuellement chaque pair « en dur » dans les fichiers de confoguration des tunnels. |
||
18 | |||
19 | 1 | sacha | ## Installation |
20 | |||
21 | https://www.wireguard.com/install/ |
||
22 | 23 | xavier | |
23 | Dans le Kernel Linux : via DKMS pour l'instant (2019-08-15) et en userspace écrit en GO (en cours de migration en Rust) sur les autres plateformes (*BSD, OpenWRT, Android, Windows). |
||
24 | |||
25 | Pour Debian stable, au départ « Stretch » 9.8 et dorénavant « Buster » 10.0, des paquets `wireguard{,-dkms,-modules}` sont installables depuis le dépôt `unstable` (uniquement). Les mises à jour y sont fréquentes, par exemple les versions disponibles au 2019-03-07 étaient les 0.0.20190227-1, celles disponibles au 2019-07-19 étaient les 0.0.20190702-1. |
||
26 | 1 | sacha | |
27 | 24 | xavier | ATTENTION : sous Debian Stretch, [une bogue](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=934763) introduite dans la dernière mise à jour du paquet des entêtes du noyau (2019-09-14), casse la compilation du module Wireguard. Il reste possible de compiler le module avec la version précédente, puis de l'utiliser avec la dernière version du noyau. |
28 | |||
29 | 1 | sacha | ## Configuration |
30 | |||
31 | ### Serveur |
||
32 | |||
33 | ~~~ |
||
34 | umask 077 |
||
35 | wg genkey > /etc/wireguard/private |
||
36 | wg genkey | tee /etc/wireguard/private | wg pubkey > /etc/wireguard/publickey |
||
37 | wg set wg0 private-key /etc/wireguard/private |
||
38 | ip link set wg0 up |
||
39 | |||
40 | cat << EOF > /etc/wireguard/wireguard.conf |
||
41 | [Interface] |
||
42 | ListenPort = 50000 |
||
43 | PrivateKey = `cat /etc/wireguard/private` |
||
44 | |||
45 | [Peer] |
||
46 | PublicKey = Va0X1zOpRc9471Aa3DEUUy7UkAv5aq5SojtIPqOSqwg= |
||
47 | AllowedIPs = 10.33.33.0/24 |
||
48 | Endpoint = 185.233.100.19:50000 |
||
49 | EOF |
||
50 | |||
51 | ~~~ |
||
52 | |||
53 | ### Client |
||
54 | |||
55 | ~~~ |
||
56 | umask 077 |
||
57 | wg genkey | tee /etc/wireguard/private | wg pubkey > /etc/wireguard/publickey |
||
58 | wg set wg0 private-key /etc/wireguard/private |
||
59 | 17 | stephanie.vieville | ip link add dev wg0 type wireguard |
60 | 1 | sacha | ip link set wg0 up |
61 | 17 | stephanie.vieville | |
62 | 1 | sacha | ~~~ |
63 | 2 | sacha | |
64 | 12 | louis.leveque | ### Config serveur (Hypnos) |
65 | |||
66 | ~~~ |
||
67 | #!/bin/bash |
||
68 | |||
69 | set -x -e |
||
70 | |||
71 | # Creating the wireguard interface |
||
72 | ip link add dev wg0 type wireguard |
||
73 | |||
74 | # Setting the IP on the wireguard interface |
||
75 | ip address add dev wg0 185.233.101.127/24 |
||
76 | |||
77 | # Configuring the wireguard server |
||
78 | wg set wg0 listen-port 50000 private-key /etc/wireguard/private |
||
79 | |||
80 | # Starting up the wireguard interface |
||
81 | ip link set up dev wg0 |
||
82 | |||
83 | # Add Client |
||
84 | wg set wg0 peer W/iRbRNZhftkcmkfS/pUNcyDJ1YHB0cBEDigzed6+B0= allowed-ips 185.233.101.126/32 |
||
85 | |||
86 | # Create the static route for the client |
||
87 | ip route add 185.233.101.126/32 dev wg0 proto static |
||
88 | ~~~ |
||
89 | |||
90 | ### Config client |
||
91 | |||
92 | ~~~ |
||
93 | #!/bin/bash |
||
94 | |||
95 | set -e -x |
||
96 | |||
97 | # Creating the wireguard interface |
||
98 | ip link add dev wg0 type wireguard |
||
99 | |||
100 | # Setting the IP on the wireguard interface |
||
101 | ip address add dev wg0 185.233.101.126/24 |
||
102 | |||
103 | # Configuring wireguard |
||
104 | wg set wg0 private-key ./private |
||
105 | |||
106 | # Starting up the wireguard interface |
||
107 | ip link set up dev wg0 |
||
108 | |||
109 | # Connect to the server |
||
110 | wg set wg0 peer 'XRhI4WqBipwY21pxPZ9Q7EWkypnQCKKtJjqu2tUUTVo=' allowed-ips 0.0.0.0/0 endpoint 185.233.100.9:50000 |
||
111 | ~~~ |
||
112 | |||
113 | 4 | sacha | ### 1er test: @Sacha's Home (Fibre Bouygues) --> @Hypnos (VM Aquilenet) |
114 | 3 | sacha | |
115 | 2 | sacha | ~~~ |
116 | |||
117 | root@hypnos:/etc/wireguard# iperf3 -s |
||
118 | ----------------------------------------------------------- |
||
119 | Server listening on 5201 |
||
120 | ----------------------------------------------------------- |
||
121 | Accepted connection from 10.33.33.2, port 60038 |
||
122 | [ 5] local 10.33.33.1 port 5201 connected to 10.33.33.2 port 60040 |
||
123 | [ ID] Interval Transfer Bandwidth |
||
124 | [ 5] 0.00-1.00 sec 15.1 MBytes 127 Mbits/sec |
||
125 | [ 5] 1.00-2.00 sec 19.9 MBytes 167 Mbits/sec |
||
126 | [ 5] 2.00-3.00 sec 20.1 MBytes 169 Mbits/sec |
||
127 | [ 5] 3.00-4.00 sec 20.1 MBytes 169 Mbits/sec |
||
128 | [ 5] 4.00-5.00 sec 19.7 MBytes 166 Mbits/sec |
||
129 | [ 5] 5.00-6.00 sec 20.0 MBytes 168 Mbits/sec |
||
130 | [ 5] 6.00-7.00 sec 20.2 MBytes 169 Mbits/sec |
||
131 | [ 5] 7.00-8.00 sec 20.2 MBytes 170 Mbits/sec |
||
132 | [ 5] 8.00-9.00 sec 20.1 MBytes 169 Mbits/sec |
||
133 | [ 5] 9.00-10.00 sec 20.2 MBytes 169 Mbits/sec |
||
134 | [ 5] 10.00-10.03 sec 566 KBytes 165 Mbits/sec |
||
135 | - - - - - - - - - - - - - - - - - - - - - - - - - |
||
136 | [ ID] Interval Transfer Bandwidth |
||
137 | [ 5] 0.00-10.03 sec 0.00 Bytes 0.00 bits/sec sender |
||
138 | [ 5] 0.00-10.03 sec 196 MBytes 164 Mbits/sec receiver |
||
139 | ----------------------------------------------------------- |
||
140 | Server listening on 5201 |
||
141 | ----------------------------------------------------------- |
||
142 | ~~~ |
||
143 | |||
144 | |||
145 | ~~~ |
||
146 | root@hypnos:/etc/wireguard# wg |
||
147 | interface: wg0 |
||
148 | public key: Va0X1zOpRc9471Aa3DEUUy7UkAv5aq5SojtIPqOSqwg= |
||
149 | private key: (hidden) |
||
150 | listening port: 50000 |
||
151 | |||
152 | peer: VEfmgnq/aXPX3qBB7Q2fgxAawQdfUYZDRKEQSPC8tnA= |
||
153 | endpoint: 5.51.0.155:3418 |
||
154 | allowed ips: 10.33.33.0/24 |
||
155 | latest handshake: 4 minutes, 30 seconds ago |
||
156 | transfer: 208.75 MiB received, 6.68 MiB sent |
||
157 | ~~~ |
||
158 | 5 | sacha | |
159 | ## InstallDebian sur Apu2 |
||
160 | |||
161 | https://blog.pgeiser.com/posts/2017/04/installing-debian-stretch-on-a-machine-without-a-graphic-card/ |
||
162 | 6 | sacha | |
163 | 18 | xavier | ~~~ |
164 | 22 | sacha | apt-get install aptitude \ |
165 | 18 | xavier | dhcpd resolvconf \ |
166 | curl dnsutils htop iperf3 tcpdump tmux whois \ |
||
167 | 1 | sacha | debian-security-support debsums needrestart |
168 | 18 | xavier | ~~~ |
169 | 8 | sacha | |
170 | ~~~ |
||
171 | #!/bin/bash |
||
172 | gw=`ip route | awk '/default/ { print $3 }'` |
||
173 | 9 | sacha | sysctl -w net.ipv4.ip_forward=1 |
174 | 8 | sacha | ip link add dev wg0 type wireguard |
175 | ip address add dev wg0 10.33.33.2/24 |
||
176 | ip link set up dev wg0 |
||
177 | ip route add 185.233.100.19/32 via $gw dev enp1s0 |
||
178 | ip route del default |
||
179 | ip route add default dev wg0 |
||
180 | wg setconf wg0 /etc/wireguard/wg0.conf |
||
181 | ~~~ |
||
182 | 10 | sacha | |
183 | https://git.zx2c4.com/WireGuard/about/src/tools/man/wg-quick.8 |
||
184 | https://git.zx2c4.com/WireGuard/about/src/tools/wg.8 |
||
185 | 16 | sacha | |
186 | https://vincent.bernat.ch/fr/blog/2018-vpn-wireguard-route |