You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Containers/WireGuard.md
+22-23Lines changed: 22 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ To be able to run WireGuard successfully, your Raspberry Pi needs to be **fully*
24
24
$ sudo apt update
25
25
$ sudo apt upgrade -y
26
26
```
27
-
27
+
28
28
### <aname="obtainDDNS"> Step 2: Set up a Dynamic DNS name </a>
29
29
30
30
Before you can use WireGuard (or any VPN solution), you need a mechanism for your remote clients to reach your home router. You have two choices:
@@ -80,9 +80,9 @@ With most containers, you can continue to tweak environment variables and settin
80
80
```yml
81
81
- TZ=Australia/Sydney
82
82
```
83
-
83
+
84
84
Note:
85
-
85
+
86
86
- Never use quote marks around the right hand side of a time-zone definition.
87
87
88
88
* `SERVERURL=` should be set to the domain name you have registered with a Dynamic DNS service provider. Example:
@@ -98,7 +98,7 @@ With most containers, you can continue to tweak environment variables and settin
98
98
```
99
99
100
100
Note:
101
-
101
+
102
102
- Many examples on the web use "PEERS=n" where "n" is a number. In practice, that approach seems to be a little fragile and is not recommended for IOTstack.
103
103
104
104
#### <a name="configurePeerDNS"> Optional configuration - DNS resolution for peers </a>
@@ -110,7 +110,7 @@ With most containers, you can continue to tweak environment variables and settin
The WireGuard service definition template follows the convention of using UDP port "51820" in three places. You can leave it like that and it will just work. There is no reason to change the defaults unless you want to.
@@ -163,7 +163,7 @@ Of the two, the first is generally the simpler and means you don't have to re-ru
163
163
$ cd ~/IOTstack
164
164
$ ./menu.sh
165
165
```
166
-
166
+
167
167
2. Choose the "Build Stack" option.
168
168
3. If WireGuard is not already selected, select it.
169
169
4. Press <kbd>enter</kbd> to begin the build.
@@ -200,9 +200,9 @@ You will need to create the `compose-override.yml` **before** running the menu t
200
200
- PEERDNS=auto
201
201
- ALLOWEDIPS=0.0.0.0/0
202
202
```
203
-
203
+
204
204
Key points:
205
-
205
+
206
206
* The override file works at the **section** level. Therefore, you have to include *all* of the environment variables from the template, not just the ones you want to alter.
207
207
* If your override file contains configurations for other containers, make sure the file only has a single `services:` directive at the start.
208
208
@@ -213,7 +213,7 @@ You will need to create the `compose-override.yml` **before** running the menu t
213
213
$ cd ~/IOTstack
214
214
$ ./menu.sh
215
215
```
216
-
216
+
217
217
5. Choose the "Build Stack" option.
218
218
6. If WireGuard is not already selected, select it.
219
219
7. Press <kbd>enter</kbd> to begin the build.
@@ -223,7 +223,7 @@ You will need to create the `compose-override.yml` **before** running the menu t
223
223
```bash
224
224
$ cat docker-compose.yml
225
225
```
226
-
226
+
227
227
and verify that the `wireguard` service definition is as you expect.
Repeat the command a few times with a short delay in between. You are looking for signs that the WireGuard container is restarting. If the container seems to be restarting then this command is your friend:
245
-
245
+
246
246
```bash
247
247
$ docker logs wireguard
248
248
```
249
-
249
+
250
250
See also discussion of [the read-only flag](#readOnlyFlag).
251
251
252
252
3. Confirm that WireGuard has generated the expected configurations. For example, given the following setting in `docker-compose.yml`:
@@ -287,7 +287,7 @@ You will need to create the `compose-override.yml` **before** running the menu t
287
287
│ └── server.conf
288
288
└── wg0.conf
289
289
```
290
-
290
+
291
291
Notice how each element in the `PEERS=` list is represented by a sub-directory prefixed with `peer_`. You should expect the same pattern for your peers.
292
292
293
293
### <a name="clientQRcodes"> Step 7: Save your WireGuard client configuration files (QR codes) </a>
@@ -365,7 +365,7 @@ A typical configuration process goes something like this:
365
365
Service Name | WireGuard
366
366
367
367
The fields in the above list are in alphabetical order. They will almost certainly be in a different order in your router and may also have different names:
368
-
368
+
369
369
* *Interface* is typically a popup menu. Generally it will either default to the name of the physical port on your router that connects to the outside world, or be some other sensible default like "All".
370
370
* *Private IP* (or *Internal IP*) is the IP address of the Raspberry Pi running WireGuard. Note that this pretty much forces you to give your Raspberry Pi a statically-configured IP address (either a static binding in your DHCP server or a hard-coded address in the Raspberry Pi itself).
371
371
* *Private Port* (or *Internal Port*) needs to be the value you chose for «external» in the WireGuard service definition (51820 if you didn't change it).
@@ -415,7 +415,7 @@ You also need to make a few assumptions:
415
415
1. The host running the remote WireGuard client (eg a mobile phone with the WireGuard app installed) has been allocated the IP address 55.66.77.88 when it connected to the Internet over 3G/4G/5G.
416
416
2. When the remote WireGuard client initiated the session, it chose UDP port 44524 as its source port. The actual number chosen is (essentially) random and only significant to the client.
417
417
3. Your Internet Service Provider allocated the IP address 12.13.14.15 to the WAN side of your router.
418
-
4. You have done all the steps in [Set up a Dynamic DNS name] and your WAN IP address (12.13.14.15) is being propagated to your Dynamic DNS service provider.
418
+
4. You have done all the steps in [Set up a Dynamic DNS name](#obtainDDNS) and your WAN IP address (12.13.14.15) is being propagated to your Dynamic DNS service provider.
419
419
420
420
Here's a reference model to help explain what occurs:
There will be a short delay. The expected answer is either:
500
500
501
-
* `«public»/udp open|filtered unknown` = Docker is listening
502
-
* `«public»/udp closed unknown` = Docker is not listening
501
+
* `«public»/udp open|filtered unknown` = router is listening
502
+
* `«public»/udp closed unknown` = router is not listening
503
503
504
504
## <a name="readOnlyFlag"> The read-only flag </a>
505
505
@@ -508,7 +508,7 @@ The `:ro` at the end of the following line in WireGuard's service definition mea
508
508
```yml
509
509
- /lib/modules:/lib/modules:ro
510
510
```
511
-
511
+
512
512
If that flag is omitted then WireGuard **may** try to update the `/lib/modules` path in your operating system. To be clear, `/lib/modules` is both **outside** the WireGuard container and **outside** the normal persistent storage area in the `./volumes` directory.
513
513
514
514
The basic idea of containers is that processes are *contained*, include all their own dependencies, can be added and removed cleanly, and don't change the underlying operating system.
@@ -550,18 +550,17 @@ The procedure is:
550
550
551
551
```bash
552
552
$ cd ~/IOTstack
553
-
$ docker-compose stop wireguard
554
-
$ docker-compose rm -f wireguard
553
+
$ docker-compose rm --force --stop -v wireguard
555
554
```
556
555
557
556
2. Erase the persistent storage area (essential):
558
557
559
558
```bash
560
559
$ sudo rm -rf ./volumes/wireguard
561
560
```
562
-
561
+
563
562
> Be very careful with that command and double-check your work **before** you hit <kbd>return</kbd>.
564
-
563
+
565
564
Erasing the persistent storage area destroys the old client configurations and invalidates any copies of QR codes. Existing clients will stop working until presented with a new QR code.
0 commit comments