Skip to content

Commit cb43fbc

Browse files
authored
Merge pull request #414 from Paraphraser/20210924-WireGuard-master
WireGuard documentation corrections
2 parents fcd13b3 + 389d26c commit cb43fbc

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

docs/Containers/WireGuard.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To be able to run WireGuard successfully, your Raspberry Pi needs to be **fully*
2424
$ sudo apt update
2525
$ sudo apt upgrade -y
2626
```
27-
27+
2828
### <a name="obtainDDNS"> Step 2: Set up a Dynamic DNS name </a>
2929

3030
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
8080
```yml
8181
- TZ=Australia/Sydney
8282
```
83-
83+
8484
Note:
85-
85+
8686
- Never use quote marks around the right hand side of a time-zone definition.
8787

8888
* `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
9898
```
9999

100100
Note:
101-
101+
102102
- 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.
103103

104104
#### <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
110110
```yml
111111
- PEERDNS=192.168.203.65
112112
```
113-
113+
114114
#### <a name="configurePorts"> Optional configuration - WireGuard ports </a>
115115

116116
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
163163
$ cd ~/IOTstack
164164
$ ./menu.sh
165165
```
166-
166+
167167
2. Choose the "Build Stack" option.
168168
3. If WireGuard is not already selected, select it.
169169
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
200200
- PEERDNS=auto
201201
- ALLOWEDIPS=0.0.0.0/0
202202
```
203-
203+
204204
Key points:
205-
205+
206206
* 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.
207207
* If your override file contains configurations for other containers, make sure the file only has a single `services:` directive at the start.
208208

@@ -213,7 +213,7 @@ You will need to create the `compose-override.yml` **before** running the menu t
213213
$ cd ~/IOTstack
214214
$ ./menu.sh
215215
```
216-
216+
217217
5. Choose the "Build Stack" option.
218218
6. If WireGuard is not already selected, select it.
219219
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
223223
```bash
224224
$ cat docker-compose.yml
225225
```
226-
226+
227227
and verify that the `wireguard` service definition is as you expect.
228228

229229
### <a name="startWireGuard"> Step 6: Start WireGuard </a>
@@ -240,13 +240,13 @@ You will need to create the `compose-override.yml` **before** running the menu t
240240
```bash
241241
$ docker ps --format "table {{.Names}}\t{{.RunningFor}}\t{{.Status}}" --filter name=wireguard
242242
```
243-
243+
244244
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+
246246
```bash
247247
$ docker logs wireguard
248248
```
249-
249+
250250
See also discussion of [the read-only flag](#readOnlyFlag).
251251

252252
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
287287
│   └── server.conf
288288
└── wg0.conf
289289
```
290-
290+
291291
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.
292292

293293
### <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:
365365
Service Name | WireGuard
366366

367367
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+
369369
* *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".
370370
* *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).
371371
* *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:
415415
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.
416416
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.
417417
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.
419419

420420
Here's a reference model to help explain what occurs:
421421

@@ -498,8 +498,8 @@ $ PORT=«public»; sudo nmap -sU -p $PORT downunda.duckdns.org | grep "$PORT/udp
498498

499499
There will be a short delay. The expected answer is either:
500500

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
503503

504504
## <a name="readOnlyFlag"> The read-only flag </a>
505505

@@ -508,7 +508,7 @@ The `:ro` at the end of the following line in WireGuard's service definition mea
508508
```yml
509509
- /lib/modules:/lib/modules:ro
510510
```
511-
511+
512512
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.
513513

514514
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:
550550

551551
```bash
552552
$ cd ~/IOTstack
553-
$ docker-compose stop wireguard
554-
$ docker-compose rm -f wireguard
553+
$ docker-compose rm --force --stop -v wireguard
555554
```
556555

557556
2. Erase the persistent storage area (essential):
558557

559558
```bash
560559
$ sudo rm -rf ./volumes/wireguard
561560
```
562-
561+
563562
> Be very careful with that command and double-check your work **before** you hit <kbd>return</kbd>.
564-
563+
565564
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.
566565

567566
3. Start WireGuard:

0 commit comments

Comments
 (0)