Wireguard » Historique » Version 39
xavier, 10/12/2019 00:07
structure
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 | 38 | xavier | Le 8 décembre 2019, Wireguard [a enfin fait son entrée dans la branche 'net-next' du noyau Linux](https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=e7096c131e5161fa3b8e52a650d7719d2857adfd) et pourrait donc faire partie intégrante de la version 5.6 prévue début 2020. |
12 | |||
13 | D'ici là le site officiel de Wireguard est clair -- c'est pas sec, même si ça marche bien : |
||
14 | 27 | xavier | |
15 | > 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. |
||
16 | |||
17 | 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. |
||
18 | |||
19 | 36 | xavier | {{include(infrastructure:Wireguard-Stretch-Bogue-934763)}} |
20 | |||
21 | 29 | xavier | ## Chez Aquilenet |
22 | |||
23 | 33 | xavier | Nous avons configuré chaque pair « en dur » dans les fichiers de configuration des tunnels, avec des adresses IP publiques. Cet adressage est déjà à revoir : au delà du pair que nous utilisons actuellement comme nœud de mise en relation ([[infrastructure:hypnos]]), les autres n'ont pas vocation à être joignables publiquement (hors des tunnels, ils ne sont joignables que sur des IP hors de notre contrôle). |
24 | 27 | xavier | |
25 | 1 | sacha | ## Installation |
26 | |||
27 | https://www.wireguard.com/install/ |
||
28 | 23 | xavier | |
29 | 37 | xavier | Pour l'instant (2019-08-15), via DKMS dans le noyau Linux et en userspace écrit en GO (en cours de migration en Rust) sur les autres plateformes (*BSD, OpenWRT, Android, Windows). |
30 | 35 | xavier | |
31 | 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. |
||
32 | 24 | xavier | |
33 | 1 | sacha | ## Configuration |
34 | |||
35 | 34 | xavier | **FIXME : tout ce qui suit est à vérifier/réviser/modifier ou déplacer vers les pages de [[infrastructure:hypnos]], [[infrastructure:thanatos]], [[infrastructure:meca]] ou [[infrastructure:pom]].** |
36 | |||
37 | 1 | sacha | ### Serveur |
38 | |||
39 | ~~~ |
||
40 | umask 077 |
||
41 | wg genkey > /etc/wireguard/private |
||
42 | wg genkey | tee /etc/wireguard/private | wg pubkey > /etc/wireguard/publickey |
||
43 | wg set wg0 private-key /etc/wireguard/private |
||
44 | ip link set wg0 up |
||
45 | |||
46 | cat << EOF > /etc/wireguard/wireguard.conf |
||
47 | [Interface] |
||
48 | ListenPort = 50000 |
||
49 | PrivateKey = `cat /etc/wireguard/private` |
||
50 | |||
51 | [Peer] |
||
52 | PublicKey = Va0X1zOpRc9471Aa3DEUUy7UkAv5aq5SojtIPqOSqwg= |
||
53 | AllowedIPs = 10.33.33.0/24 |
||
54 | Endpoint = 185.233.100.19:50000 |
||
55 | EOF |
||
56 | |||
57 | ~~~ |
||
58 | |||
59 | ### Client |
||
60 | |||
61 | ~~~ |
||
62 | umask 077 |
||
63 | wg genkey | tee /etc/wireguard/private | wg pubkey > /etc/wireguard/publickey |
||
64 | wg set wg0 private-key /etc/wireguard/private |
||
65 | 17 | stephanie.vieville | ip link add dev wg0 type wireguard |
66 | 1 | sacha | ip link set wg0 up |
67 | 17 | stephanie.vieville | |
68 | 1 | sacha | ~~~ |
69 | 2 | sacha | |
70 | 12 | louis.leveque | ### Config serveur (Hypnos) |
71 | |||
72 | ~~~ |
||
73 | #!/bin/bash |
||
74 | |||
75 | set -x -e |
||
76 | |||
77 | # Creating the wireguard interface |
||
78 | ip link add dev wg0 type wireguard |
||
79 | |||
80 | # Setting the IP on the wireguard interface |
||
81 | ip address add dev wg0 185.233.101.127/24 |
||
82 | |||
83 | # Configuring the wireguard server |
||
84 | wg set wg0 listen-port 50000 private-key /etc/wireguard/private |
||
85 | |||
86 | # Starting up the wireguard interface |
||
87 | ip link set up dev wg0 |
||
88 | |||
89 | # Add Client |
||
90 | wg set wg0 peer W/iRbRNZhftkcmkfS/pUNcyDJ1YHB0cBEDigzed6+B0= allowed-ips 185.233.101.126/32 |
||
91 | |||
92 | # Create the static route for the client |
||
93 | ip route add 185.233.101.126/32 dev wg0 proto static |
||
94 | ~~~ |
||
95 | |||
96 | ### Config client |
||
97 | |||
98 | ~~~ |
||
99 | #!/bin/bash |
||
100 | |||
101 | set -e -x |
||
102 | |||
103 | # Creating the wireguard interface |
||
104 | ip link add dev wg0 type wireguard |
||
105 | |||
106 | # Setting the IP on the wireguard interface |
||
107 | ip address add dev wg0 185.233.101.126/24 |
||
108 | |||
109 | # Configuring wireguard |
||
110 | wg set wg0 private-key ./private |
||
111 | |||
112 | # Starting up the wireguard interface |
||
113 | ip link set up dev wg0 |
||
114 | |||
115 | # Connect to the server |
||
116 | wg set wg0 peer 'XRhI4WqBipwY21pxPZ9Q7EWkypnQCKKtJjqu2tUUTVo=' allowed-ips 0.0.0.0/0 endpoint 185.233.100.9:50000 |
||
117 | ~~~ |
||
118 | |||
119 | 4 | sacha | ### 1er test: @Sacha's Home (Fibre Bouygues) --> @Hypnos (VM Aquilenet) |
120 | 3 | sacha | |
121 | 2 | sacha | ~~~ |
122 | |||
123 | root@hypnos:/etc/wireguard# iperf3 -s |
||
124 | ----------------------------------------------------------- |
||
125 | Server listening on 5201 |
||
126 | ----------------------------------------------------------- |
||
127 | Accepted connection from 10.33.33.2, port 60038 |
||
128 | [ 5] local 10.33.33.1 port 5201 connected to 10.33.33.2 port 60040 |
||
129 | [ ID] Interval Transfer Bandwidth |
||
130 | [ 5] 0.00-1.00 sec 15.1 MBytes 127 Mbits/sec |
||
131 | [ 5] 1.00-2.00 sec 19.9 MBytes 167 Mbits/sec |
||
132 | [ 5] 2.00-3.00 sec 20.1 MBytes 169 Mbits/sec |
||
133 | [ 5] 3.00-4.00 sec 20.1 MBytes 169 Mbits/sec |
||
134 | [ 5] 4.00-5.00 sec 19.7 MBytes 166 Mbits/sec |
||
135 | [ 5] 5.00-6.00 sec 20.0 MBytes 168 Mbits/sec |
||
136 | [ 5] 6.00-7.00 sec 20.2 MBytes 169 Mbits/sec |
||
137 | [ 5] 7.00-8.00 sec 20.2 MBytes 170 Mbits/sec |
||
138 | [ 5] 8.00-9.00 sec 20.1 MBytes 169 Mbits/sec |
||
139 | [ 5] 9.00-10.00 sec 20.2 MBytes 169 Mbits/sec |
||
140 | [ 5] 10.00-10.03 sec 566 KBytes 165 Mbits/sec |
||
141 | - - - - - - - - - - - - - - - - - - - - - - - - - |
||
142 | [ ID] Interval Transfer Bandwidth |
||
143 | [ 5] 0.00-10.03 sec 0.00 Bytes 0.00 bits/sec sender |
||
144 | [ 5] 0.00-10.03 sec 196 MBytes 164 Mbits/sec receiver |
||
145 | ----------------------------------------------------------- |
||
146 | Server listening on 5201 |
||
147 | ----------------------------------------------------------- |
||
148 | ~~~ |
||
149 | |||
150 | |||
151 | ~~~ |
||
152 | root@hypnos:/etc/wireguard# wg |
||
153 | interface: wg0 |
||
154 | public key: Va0X1zOpRc9471Aa3DEUUy7UkAv5aq5SojtIPqOSqwg= |
||
155 | private key: (hidden) |
||
156 | listening port: 50000 |
||
157 | |||
158 | peer: VEfmgnq/aXPX3qBB7Q2fgxAawQdfUYZDRKEQSPC8tnA= |
||
159 | endpoint: 5.51.0.155:3418 |
||
160 | allowed ips: 10.33.33.0/24 |
||
161 | latest handshake: 4 minutes, 30 seconds ago |
||
162 | transfer: 208.75 MiB received, 6.68 MiB sent |
||
163 | ~~~ |
||
164 | 5 | sacha | |
165 | ## InstallDebian sur Apu2 |
||
166 | |||
167 | https://blog.pgeiser.com/posts/2017/04/installing-debian-stretch-on-a-machine-without-a-graphic-card/ |
||
168 | 6 | sacha | |
169 | 18 | xavier | ~~~ |
170 | 22 | sacha | apt-get install aptitude \ |
171 | 18 | xavier | dhcpd resolvconf \ |
172 | curl dnsutils htop iperf3 tcpdump tmux whois \ |
||
173 | 1 | sacha | debian-security-support debsums needrestart |
174 | 18 | xavier | ~~~ |
175 | 8 | sacha | |
176 | ~~~ |
||
177 | #!/bin/bash |
||
178 | gw=`ip route | awk '/default/ { print $3 }'` |
||
179 | 9 | sacha | sysctl -w net.ipv4.ip_forward=1 |
180 | 8 | sacha | ip link add dev wg0 type wireguard |
181 | ip address add dev wg0 10.33.33.2/24 |
||
182 | ip link set up dev wg0 |
||
183 | ip route add 185.233.100.19/32 via $gw dev enp1s0 |
||
184 | ip route del default |
||
185 | ip route add default dev wg0 |
||
186 | wg setconf wg0 /etc/wireguard/wg0.conf |
||
187 | ~~~ |
||
188 | 10 | sacha | |
189 | https://git.zx2c4.com/WireGuard/about/src/tools/man/wg-quick.8 |
||
190 | https://git.zx2c4.com/WireGuard/about/src/tools/wg.8 |
||
191 | 16 | sacha | |
192 | https://vincent.bernat.ch/fr/blog/2018-vpn-wireguard-route |