mirror cantonese + two more articles
[robinkrens.nl] / docs / wireguard.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title></title>
6 <meta name="generator" content="HTML::TextToHTML v2.51"/>
7 <link rel="stylesheet" type="text/css" href="../files/style.css"/>
8 </head>
9 <body>
10 <h1><a name="section_1">Wireguard gateway setup</a></h1>
11
12 <p>WireGuard securely encapsulates IP packets over UDP. You add a WireGuard interface, configure it with your private key and your peers' public keys, and then you send packets across it. It's that easy. Compared to OpenVPN, Ipsec, or even tinc, this is by far the easiest to configure.
13 </p>
14 <hr/>
15
16 <p><em>Adapted from a mail conversation</em><br/>
17 So in this particular setup we have a listening server and a client. 
18 The client tunnels all IP requests (wildcard 0.0.0.0/0) through the wireguard interface.
19 The server only allows accept connections from one IP (and furthermore checks if the key is OK).
20 </p>
21 <h2><a name="section_1_1">Generate public and private keys for client and server</a></h2>
22
23 <p>The following cmd will create a private key with a corresponding public key.
24 Create these for both the server and your client.
25 </p>
26 <pre>
27         umask 077
28         wg genkey | tee private.key | wg pubkey &gt; public.key
29 </pre>
30 <h2><a name="section_1_2">My configuration files are as follows:</a></h2>
31
32 <p>A server with a virtual IP 172.16.16.1 (you can use any local LAN IP) is listening on port 51820.
33 Right now, it only accepts connection from one peer (172.16.16.2). Traffics from other peers or with invalid keys are dropped.
34 The server config is as follows
35 </p>
36 <pre>
37         [Interface]
38         Address = 172.16.16.1/24
39         ListenPort = 51820
40         PrivateKey = xxxxxxxx
41
42         [Peer]
43         PublicKey = xxxxxxxxxxxxxx
44         AllowedIPs = 172.16.16.2/32
45 </pre>
46 <p>On the client side, we have a client with virtual IP 172.16.16.2. As for the peer, we have set a wildcard with 0.0.0.0/0. The endpoint
47 is our server. All traffic is sent through this tunnel (except for maybe LAN traffic). 
48 </p>
49 <pre>
50         [Interface]
51         Address = 172.16.16.2/32
52         PrivateKey = xxxxxxxxx
53         DNS = 8.8.8.8
54
55         [Peer]
56         PublicKey = xxxxxxxxxxxxxx
57         Endpoint = 1.2.3.4:51820
58         AllowedIPs = 0.0.0.0/0
59         PersistentKeepalive = 21
60 </pre>
61 <h2><a name="section_1_3">Running</a></h2>
62 <p>You can start and stop your client/server with the wg-quick tool (if you compile by yourself, remember to build this tool as well)
63         
64 </p><pre>
65         wg-quick up wg0.conf
66         wg-quick down wg0.conf
67 </pre>
68 </body>
69 </html>