Wireguard » Historique » Version 46
sacha, 23/09/2024 01:26
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 | 46 | sacha | Attention cependant Wireguard est un VPN de niveau 3 ! (on ne peux pas par exemple avoir du broadcast pour DHCP ou des VIP Keepalived) |
7 | 20 | xavier | |
8 | 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]]. |
9 | 26 | xavier | |
10 | 1 | sacha | 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. |
11 | 38 | xavier | |
12 | 46 | sacha | Aujourd'hui Wireguard est intégré dans les noyaux des principaux systèmes: Linux/*BSD/Windows/Mac |
13 | 40 | xavier | |
14 | ## Chez Aquilenet |
||
15 | 29 | xavier | |
16 | 46 | sacha | Deux serveurs pour du failover Hypnos et Thanos Avec du BGP pour gérer le failover. |
17 | 37 | xavier | |
18 | 35 | xavier | ## Installation |
19 | |||
20 | 24 | xavier | |
21 | 1 | sacha | ## Configuration |
22 | |||
23 | 43 | sacha | ### Config serveur (Hypnos) |
24 | |||
25 | * Ajouter à la mano |
||
26 | |||
27 | 1 | sacha | ~~~ |
28 | umask 077 |
||
29 | wg genkey > /etc/wireguard/private |
||
30 | wg genkey | tee /etc/wireguard/private | wg pubkey > /etc/wireguard/publickey |
||
31 | wg set wg0 private-key /etc/wireguard/private |
||
32 | ip link set wg0 up |
||
33 | 43 | sacha | ~~~ |
34 | 1 | sacha | |
35 | 43 | sacha | * /etc/wireguard/wg0.conf |
36 | |||
37 | ~~~ |
||
38 | 1 | sacha | [Interface] |
39 | ListenPort = 50000 |
||
40 | PrivateKey = `cat /etc/wireguard/private` |
||
41 | |||
42 | [Peer] |
||
43 | 45 | sacha | PublicKey = XRhI4WqBipwY21pxPZ9Q7EWkypnQCKKtJjqu2tUUTVo= |
44 | 1 | sacha | AllowedIPs = 10.33.33.0/24 |
45 | Endpoint = 185.233.100.19:50000 |
||
46 | 43 | sacha | ~~~ |
47 | 1 | sacha | |
48 | 43 | sacha | * /etc/network/interfaces |
49 | |||
50 | On ajoute les informations suivantes pour Wireguard (on n'utilise pas wg-quick) |
||
51 | Chaque IP cliente est ajoutée dans la table de routage. |
||
52 | |||
53 | 1 | sacha | ~~~ |
54 | 43 | sacha | auto wg0 |
55 | iface wg0 inet static |
||
56 | address 185.233.101.127 |
||
57 | netmask 255.255.255.255 |
||
58 | pre-up /sbin/ip link add dev $IFACE type wireguard || true |
||
59 | pre-up wg setconf $IFACE /etc/wireguard/$IFACE.conf || true |
||
60 | up /sbin/ip link set $IFACE up || true |
||
61 | up /sbin/ip route add default dev $IFACE || true |
||
62 | down /sbin/ip link del dev $IFACE || true |
||
63 | up /sbin/ip route add 185.233.101.120/32 dev $IFACE proto static || true |
||
64 | down /sbin/ip route del 185.233.101.120/32 dev $IFACE proto static || true |
||
65 | up /sbin/ip route add 185.233.101.125/32 dev $IFACE proto static || true |
||
66 | down /sbin/ip route del 185.233.101.125/32 dev $IFACE proto static || true |
||
67 | up /sbin/ip route add 185.233.101.126/32 dev $IFACE proto static || true |
||
68 | down /sbin/ip route del 185.233.101.126/32 dev $IFACE proto static || true |
||
69 | ~~~ |
||
70 | 12 | louis.leveque | |
71 | ### Client |
||
72 | 43 | sacha | **Voir plutôt [[infrastructure:Pom_buster_install_2019-07]] pour une configuration détaillée.** |
73 | 12 | louis.leveque | ~~~ |
74 | umask 077 |
||
75 | wg genkey | tee /etc/wireguard/private | wg pubkey > /etc/wireguard/publickey |
||
76 | wg set wg0 private-key /etc/wireguard/private |
||
77 | ip link add dev wg0 type wireguard |
||
78 | ip link set wg0 up |
||
79 | |||
80 | ~~~ |
||
81 | |||
82 | |||
83 | 43 | sacha | ### Archives |
84 | 44 | sacha | |
85 | 12 | louis.leveque | |
86 | 4 | sacha | ### 1er test: @Sacha's Home (Fibre Bouygues) --> @Hypnos (VM Aquilenet) |
87 | 3 | sacha | |
88 | 2 | sacha | ~~~ |
89 | |||
90 | root@hypnos:/etc/wireguard# iperf3 -s |
||
91 | ----------------------------------------------------------- |
||
92 | Server listening on 5201 |
||
93 | ----------------------------------------------------------- |
||
94 | Accepted connection from 10.33.33.2, port 60038 |
||
95 | [ 5] local 10.33.33.1 port 5201 connected to 10.33.33.2 port 60040 |
||
96 | [ ID] Interval Transfer Bandwidth |
||
97 | [ 5] 0.00-1.00 sec 15.1 MBytes 127 Mbits/sec |
||
98 | [ 5] 1.00-2.00 sec 19.9 MBytes 167 Mbits/sec |
||
99 | [ 5] 2.00-3.00 sec 20.1 MBytes 169 Mbits/sec |
||
100 | [ 5] 3.00-4.00 sec 20.1 MBytes 169 Mbits/sec |
||
101 | [ 5] 4.00-5.00 sec 19.7 MBytes 166 Mbits/sec |
||
102 | [ 5] 5.00-6.00 sec 20.0 MBytes 168 Mbits/sec |
||
103 | [ 5] 6.00-7.00 sec 20.2 MBytes 169 Mbits/sec |
||
104 | [ 5] 7.00-8.00 sec 20.2 MBytes 170 Mbits/sec |
||
105 | [ 5] 8.00-9.00 sec 20.1 MBytes 169 Mbits/sec |
||
106 | [ 5] 9.00-10.00 sec 20.2 MBytes 169 Mbits/sec |
||
107 | [ 5] 10.00-10.03 sec 566 KBytes 165 Mbits/sec |
||
108 | - - - - - - - - - - - - - - - - - - - - - - - - - |
||
109 | [ ID] Interval Transfer Bandwidth |
||
110 | [ 5] 0.00-10.03 sec 0.00 Bytes 0.00 bits/sec sender |
||
111 | [ 5] 0.00-10.03 sec 196 MBytes 164 Mbits/sec receiver |
||
112 | ----------------------------------------------------------- |
||
113 | Server listening on 5201 |
||
114 | ----------------------------------------------------------- |
||
115 | ~~~ |
||
116 | |||
117 | |||
118 | ~~~ |
||
119 | root@hypnos:/etc/wireguard# wg |
||
120 | interface: wg0 |
||
121 | public key: Va0X1zOpRc9471Aa3DEUUy7UkAv5aq5SojtIPqOSqwg= |
||
122 | private key: (hidden) |
||
123 | listening port: 50000 |
||
124 | |||
125 | peer: VEfmgnq/aXPX3qBB7Q2fgxAawQdfUYZDRKEQSPC8tnA= |
||
126 | endpoint: 5.51.0.155:3418 |
||
127 | allowed ips: 10.33.33.0/24 |
||
128 | latest handshake: 4 minutes, 30 seconds ago |
||
129 | transfer: 208.75 MiB received, 6.68 MiB sent |
||
130 | ~~~ |
||
131 | 5 | sacha | |
132 | ## InstallDebian sur Apu2 |
||
133 | |||
134 | https://blog.pgeiser.com/posts/2017/04/installing-debian-stretch-on-a-machine-without-a-graphic-card/ |
||
135 | 6 | sacha | |
136 | 18 | xavier | ~~~ |
137 | 22 | sacha | apt-get install aptitude \ |
138 | 18 | xavier | dhcpd resolvconf \ |
139 | curl dnsutils htop iperf3 tcpdump tmux whois \ |
||
140 | 1 | sacha | debian-security-support debsums needrestart |
141 | 18 | xavier | ~~~ |
142 | 8 | sacha | |
143 | ~~~ |
||
144 | #!/bin/bash |
||
145 | gw=`ip route | awk '/default/ { print $3 }'` |
||
146 | 9 | sacha | sysctl -w net.ipv4.ip_forward=1 |
147 | 8 | sacha | ip link add dev wg0 type wireguard |
148 | ip address add dev wg0 10.33.33.2/24 |
||
149 | ip link set up dev wg0 |
||
150 | ip route add 185.233.100.19/32 via $gw dev enp1s0 |
||
151 | ip route del default |
||
152 | ip route add default dev wg0 |
||
153 | wg setconf wg0 /etc/wireguard/wg0.conf |
||
154 | ~~~ |
||
155 | 10 | sacha | |
156 | https://git.zx2c4.com/WireGuard/about/src/tools/man/wg-quick.8 |
||
157 | https://git.zx2c4.com/WireGuard/about/src/tools/wg.8 |
||
158 | 16 | sacha | |
159 | https://vincent.bernat.ch/fr/blog/2018-vpn-wireguard-route |