Projet

Général

Profil

Wireguard » Historique » Version 24

xavier, 15/08/2019 18:42
bogue linux-headers / wireguard-dkms sous Debian Stretch

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