Wireguard » Historique » Version 25
xavier, 15/08/2019 18:48
intro
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 | 1 | sacha | ## Installation |
10 | |||
11 | https://www.wireguard.com/install/ |
||
12 | 23 | xavier | |
13 | 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). |
||
14 | |||
15 | 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. |
||
16 | 1 | sacha | |
17 | 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. |
18 | |||
19 | 1 | sacha | ## Configuration |
20 | |||
21 | ### Serveur |
||
22 | |||
23 | ~~~ |
||
24 | umask 077 |
||
25 | wg genkey > /etc/wireguard/private |
||
26 | wg genkey | tee /etc/wireguard/private | wg pubkey > /etc/wireguard/publickey |
||
27 | wg set wg0 private-key /etc/wireguard/private |
||
28 | ip link set wg0 up |
||
29 | |||
30 | cat << EOF > /etc/wireguard/wireguard.conf |
||
31 | [Interface] |
||
32 | ListenPort = 50000 |
||
33 | PrivateKey = `cat /etc/wireguard/private` |
||
34 | |||
35 | [Peer] |
||
36 | PublicKey = Va0X1zOpRc9471Aa3DEUUy7UkAv5aq5SojtIPqOSqwg= |
||
37 | AllowedIPs = 10.33.33.0/24 |
||
38 | Endpoint = 185.233.100.19:50000 |
||
39 | EOF |
||
40 | |||
41 | ~~~ |
||
42 | |||
43 | ### Client |
||
44 | |||
45 | ~~~ |
||
46 | umask 077 |
||
47 | wg genkey | tee /etc/wireguard/private | wg pubkey > /etc/wireguard/publickey |
||
48 | wg set wg0 private-key /etc/wireguard/private |
||
49 | 17 | stephanie.vieville | ip link add dev wg0 type wireguard |
50 | 1 | sacha | ip link set wg0 up |
51 | 17 | stephanie.vieville | |
52 | 1 | sacha | ~~~ |
53 | 2 | sacha | |
54 | 12 | louis.leveque | ### Config serveur (Hypnos) |
55 | |||
56 | ~~~ |
||
57 | #!/bin/bash |
||
58 | |||
59 | set -x -e |
||
60 | |||
61 | # Creating the wireguard interface |
||
62 | ip link add dev wg0 type wireguard |
||
63 | |||
64 | # Setting the IP on the wireguard interface |
||
65 | ip address add dev wg0 185.233.101.127/24 |
||
66 | |||
67 | # Configuring the wireguard server |
||
68 | wg set wg0 listen-port 50000 private-key /etc/wireguard/private |
||
69 | |||
70 | # Starting up the wireguard interface |
||
71 | ip link set up dev wg0 |
||
72 | |||
73 | # Add Client |
||
74 | wg set wg0 peer W/iRbRNZhftkcmkfS/pUNcyDJ1YHB0cBEDigzed6+B0= allowed-ips 185.233.101.126/32 |
||
75 | |||
76 | # Create the static route for the client |
||
77 | ip route add 185.233.101.126/32 dev wg0 proto static |
||
78 | ~~~ |
||
79 | |||
80 | ### Config client |
||
81 | |||
82 | ~~~ |
||
83 | #!/bin/bash |
||
84 | |||
85 | set -e -x |
||
86 | |||
87 | # Creating the wireguard interface |
||
88 | ip link add dev wg0 type wireguard |
||
89 | |||
90 | # Setting the IP on the wireguard interface |
||
91 | ip address add dev wg0 185.233.101.126/24 |
||
92 | |||
93 | # Configuring wireguard |
||
94 | wg set wg0 private-key ./private |
||
95 | |||
96 | # Starting up the wireguard interface |
||
97 | ip link set up dev wg0 |
||
98 | |||
99 | # Connect to the server |
||
100 | wg set wg0 peer 'XRhI4WqBipwY21pxPZ9Q7EWkypnQCKKtJjqu2tUUTVo=' allowed-ips 0.0.0.0/0 endpoint 185.233.100.9:50000 |
||
101 | ~~~ |
||
102 | |||
103 | 4 | sacha | ### 1er test: @Sacha's Home (Fibre Bouygues) --> @Hypnos (VM Aquilenet) |
104 | 3 | sacha | |
105 | 2 | sacha | ~~~ |
106 | |||
107 | root@hypnos:/etc/wireguard# iperf3 -s |
||
108 | ----------------------------------------------------------- |
||
109 | Server listening on 5201 |
||
110 | ----------------------------------------------------------- |
||
111 | Accepted connection from 10.33.33.2, port 60038 |
||
112 | [ 5] local 10.33.33.1 port 5201 connected to 10.33.33.2 port 60040 |
||
113 | [ ID] Interval Transfer Bandwidth |
||
114 | [ 5] 0.00-1.00 sec 15.1 MBytes 127 Mbits/sec |
||
115 | [ 5] 1.00-2.00 sec 19.9 MBytes 167 Mbits/sec |
||
116 | [ 5] 2.00-3.00 sec 20.1 MBytes 169 Mbits/sec |
||
117 | [ 5] 3.00-4.00 sec 20.1 MBytes 169 Mbits/sec |
||
118 | [ 5] 4.00-5.00 sec 19.7 MBytes 166 Mbits/sec |
||
119 | [ 5] 5.00-6.00 sec 20.0 MBytes 168 Mbits/sec |
||
120 | [ 5] 6.00-7.00 sec 20.2 MBytes 169 Mbits/sec |
||
121 | [ 5] 7.00-8.00 sec 20.2 MBytes 170 Mbits/sec |
||
122 | [ 5] 8.00-9.00 sec 20.1 MBytes 169 Mbits/sec |
||
123 | [ 5] 9.00-10.00 sec 20.2 MBytes 169 Mbits/sec |
||
124 | [ 5] 10.00-10.03 sec 566 KBytes 165 Mbits/sec |
||
125 | - - - - - - - - - - - - - - - - - - - - - - - - - |
||
126 | [ ID] Interval Transfer Bandwidth |
||
127 | [ 5] 0.00-10.03 sec 0.00 Bytes 0.00 bits/sec sender |
||
128 | [ 5] 0.00-10.03 sec 196 MBytes 164 Mbits/sec receiver |
||
129 | ----------------------------------------------------------- |
||
130 | Server listening on 5201 |
||
131 | ----------------------------------------------------------- |
||
132 | ~~~ |
||
133 | |||
134 | |||
135 | ~~~ |
||
136 | root@hypnos:/etc/wireguard# wg |
||
137 | interface: wg0 |
||
138 | public key: Va0X1zOpRc9471Aa3DEUUy7UkAv5aq5SojtIPqOSqwg= |
||
139 | private key: (hidden) |
||
140 | listening port: 50000 |
||
141 | |||
142 | peer: VEfmgnq/aXPX3qBB7Q2fgxAawQdfUYZDRKEQSPC8tnA= |
||
143 | endpoint: 5.51.0.155:3418 |
||
144 | allowed ips: 10.33.33.0/24 |
||
145 | latest handshake: 4 minutes, 30 seconds ago |
||
146 | transfer: 208.75 MiB received, 6.68 MiB sent |
||
147 | ~~~ |
||
148 | 5 | sacha | |
149 | ## InstallDebian sur Apu2 |
||
150 | |||
151 | https://blog.pgeiser.com/posts/2017/04/installing-debian-stretch-on-a-machine-without-a-graphic-card/ |
||
152 | 6 | sacha | |
153 | 18 | xavier | ~~~ |
154 | 22 | sacha | apt-get install aptitude \ |
155 | 18 | xavier | dhcpd resolvconf \ |
156 | curl dnsutils htop iperf3 tcpdump tmux whois \ |
||
157 | 1 | sacha | debian-security-support debsums needrestart |
158 | 18 | xavier | ~~~ |
159 | 8 | sacha | |
160 | ~~~ |
||
161 | #!/bin/bash |
||
162 | gw=`ip route | awk '/default/ { print $3 }'` |
||
163 | 9 | sacha | sysctl -w net.ipv4.ip_forward=1 |
164 | 8 | sacha | ip link add dev wg0 type wireguard |
165 | ip address add dev wg0 10.33.33.2/24 |
||
166 | ip link set up dev wg0 |
||
167 | ip route add 185.233.100.19/32 via $gw dev enp1s0 |
||
168 | ip route del default |
||
169 | ip route add default dev wg0 |
||
170 | wg setconf wg0 /etc/wireguard/wg0.conf |
||
171 | ~~~ |
||
172 | 10 | sacha | |
173 | https://git.zx2c4.com/WireGuard/about/src/tools/man/wg-quick.8 |
||
174 | https://git.zx2c4.com/WireGuard/about/src/tools/wg.8 |
||
175 | 16 | sacha | |
176 | https://vincent.bernat.ch/fr/blog/2018-vpn-wireguard-route |