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: README.md
+5-13Lines changed: 5 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,15 +70,10 @@ This image provides various versions that are available via tags. Please read th
70
70
71
71
During container start, it will first check if the wireguard module is already installed and loaded. Kernels newer than 5.6 generally have the wireguard module built-in (along with some older custom kernels). However, the module may not be enabled. Make sure it is enabled prior to starting the container.
72
72
73
-
If the kernel is not built-in, or installed on host, the container will check if the kernel headers are present (in `/usr/src`) and if not, it will attempt to download the necessary kernel headers from the `ubuntu xenial/bionic`, `debian/raspbian buster` repos; then will attempt to compile and install the kernel module. If the kernel headers are not found in either `usr/src` or in the repos mentioned, container will sleep indefinitely as wireguard cannot be installed.
74
-
75
-
If you're on a debian/ubuntu based host with a custom or downstream distro provided kernel (ie. Pop!_OS), the container won't be able to install the kernel headers from the regular ubuntu and debian repos. In those cases, you can try installing the headers on the host via `sudo apt install linux-headers-$(uname -r)` (if distro version) and then add a volume mapping for `/usr/src:/usr/src`, or if custom built, map the location of the existing headers to allow the container to use host installed headers to build the kernel module (tested successful on Pop!_OS, ymmv).
76
-
77
-
With regards to arm32/64 devices, Raspberry Pi 2-4 running the [official ubuntu images](https://ubuntu.com/download/raspberry-pi) or Raspbian Buster are supported out of the box. For all other devices and OSes, you can try installing the kernel headers on the host, and mapping `/usr/src:/usr/src` and it may just work (no guarantees).
78
-
79
-
This can be run as a server or a client, based on the parameters used.
73
+
This can be run as a server or a client, based on the parameters used.
80
74
81
75
## Server Mode
76
+
82
77
If the environment variable `PEERS` is set to a number or a list of strings separated by comma, the container will run in server mode and the necessary server and peer/client confs will be generated. The peer/client config qr codes will be output in the docker log. They will also be saved in text and png format under `/config/peerX` in case `PEERS` is a variable and an integer or `/config/peer_X` in case a list of names was provided instead of an integer.
83
78
84
79
Variables `SERVERURL`, `SERVERPORT`, `INTERNAL_SUBNET` and `PEERDNS` are optional variables used for server mode. Any changes to these environment variables will trigger regeneration of server and peer confs. Peer/client confs will be recreated with existing private/public keys. Delete the peer folders for the keys to be recreated along with the confs.
@@ -90,11 +85,13 @@ To display the QR codes of active peers again, you can use the following command
90
85
The templates used for server and peer confs are saved under `/config/templates`. Advanced users can modify these templates and force conf generation by deleting `/config/wg0.conf` and restarting the container.
91
86
92
87
## Client Mode
88
+
93
89
Do not set the `PEERS` environment variable. Drop your client conf into the config folder as `/config/wg0.conf` and start the container.
94
90
95
91
If you get IPv6 related errors in the log and connection cannot be established, edit the `AllowedIPs` line in your peer/client wg0.conf to include only `0.0.0.0/0` and not `::/0`; and restart the container.
96
92
97
93
## Road warriors, roaming and returning home
94
+
98
95
If you plan to use Wireguard both remotely and locally, say on your mobile phone, you will need to consider routing. Most firewalls will not route ports forwarded on your WAN interface correctly to the LAN out of the box. This means that when you return home, even though you can see the Wireguard server, the return packets will probably get lost.
99
96
100
97
This is not a Wireguard specific issue and the two generally accepted solutions are NAT reflection (setting your edge router/firewall up in such a way as it translates internal packets correctly) or split horizon DNS (setting your internal DNS to return the private rather than public IP when connecting locally).
@@ -107,7 +104,7 @@ Both of these approaches have positives and negatives however their setup is out
107
104
108
105
When routing via Wireguard from another container using the `service` option in docker, you might lose access to the containers webUI locally. To avoid this, exclude the docker subnet from being routed via Wireguard by modifying your `wg0.conf` like so (modifying the subnets as you require):
109
106
110
-
```
107
+
```ini
111
108
[Interface]
112
109
PrivateKey = <private key>
113
110
Address = 9.8.7.6/32
@@ -145,7 +142,6 @@ services:
145
142
container_name: wireguard
146
143
cap_add:
147
144
- NET_ADMIN
148
-
- SYS_MODULE
149
145
environment:
150
146
- PUID=1000
151
147
- PGID=1000
@@ -159,7 +155,6 @@ services:
159
155
- LOG_CONFS=true #optional
160
156
volumes:
161
157
- /path/to/appdata/config:/config
162
-
- /lib/modules:/lib/modules
163
158
ports:
164
159
- 51820:51820/udp
165
160
sysctls:
@@ -173,7 +168,6 @@ services:
173
168
docker run -d \
174
169
--name=wireguard \
175
170
--cap-add=NET_ADMIN \
176
-
--cap-add=SYS_MODULE \
177
171
-e PUID=1000 \
178
172
-e PGID=1000 \
179
173
-e TZ=Europe/London \
@@ -186,7 +180,6 @@ docker run -d \
186
180
-e LOG_CONFS=true `#optional` \
187
181
-p 51820:51820/udp \
188
182
-v /path/to/appdata/config:/config \
189
-
-v /lib/modules:/lib/modules \
190
183
--sysctl="net.ipv4.conf.all.src_valid_mark=1" \
191
184
--restart unless-stopped \
192
185
lscr.io/linuxserver/wireguard:alpine
@@ -210,7 +203,6 @@ Container images are configured using parameters passed at runtime (such as thos
210
203
|`-e ALLOWEDIPS=0.0.0.0/0`| The IPs/Ranges that the peers will be able to reach using the VPN connection. If not specified the default value is: '0.0.0.0/0, ::0/0' This will cause ALL traffic to route through the VPN, if you want split tunneling, set this to only the IPs you would like to use the tunnel AND the ip of the server's WG ip, such as 10.13.13.1. |
211
204
|`-e LOG_CONFS=true`| Generated QR codes will be displayed in the docker log. Set to `false` to skip log output. |
212
205
|`-v /config`| Contains all relevant configuration files. |
During container start, it will first check if the wireguard module is already installed and loaded. Kernels newer than 5.6 generally have the wireguard module built-in (along with some older custom kernels). However, the module may not be enabled. Make sure it is enabled prior to starting the container.
60
-
61
-
If the kernel is not built-in, or installed on host, the container will check if the kernel headers are present (in `/usr/src`) and if not, it will attempt to download the necessary kernel headers from the `ubuntu xenial/bionic`, `debian/raspbian buster` repos; then will attempt to compile and install the kernel module. If the kernel headers are not found in either `usr/src` or in the repos mentioned, container will sleep indefinitely as wireguard cannot be installed.
62
-
63
-
If you're on a debian/ubuntu based host with a custom or downstream distro provided kernel (ie. Pop!_OS), the container won't be able to install the kernel headers from the regular ubuntu and debian repos. In those cases, you can try installing the headers on the host via `sudo apt install linux-headers-$(uname -r)` (if distro version) and then add a volume mapping for `/usr/src:/usr/src`, or if custom built, map the location of the existing headers to allow the container to use host installed headers to build the kernel module (tested successful on Pop!_OS, ymmv).
64
-
65
-
With regards to arm32/64 devices, Raspberry Pi 2-4 running the [official ubuntu images](https://ubuntu.com/download/raspberry-pi) or Raspbian Buster are supported out of the box. For all other devices and OSes, you can try installing the kernel headers on the host, and mapping `/usr/src:/usr/src` and it may just work (no guarantees).
66
58
67
-
This can be run as a server or a client, based on the parameters used.
59
+
This can be run as a server or a client, based on the parameters used.
68
60
69
61
## Server Mode
62
+
70
63
If the environment variable `PEERS` is set to a number or a list of strings separated by comma, the container will run in server mode and the necessary server and peer/client confs will be generated. The peer/client config qr codes will be output in the docker log. They will also be saved in text and png format under `/config/peerX` in case `PEERS` is a variable and an integer or `/config/peer_X` in case a list of names was provided instead of an integer.
71
-
64
+
72
65
Variables `SERVERURL`, `SERVERPORT`, `INTERNAL_SUBNET` and `PEERDNS` are optional variables used for server mode. Any changes to these environment variables will trigger regeneration of server and peer confs. Peer/client confs will be recreated with existing private/public keys. Delete the peer folders for the keys to be recreated along with the confs.
73
-
66
+
74
67
To add more peers/clients later on, you increment the `PEERS` environment variable or add more elements to the list and recreate the container.
75
-
68
+
76
69
To display the QR codes of active peers again, you can use the following command and list the peer numbers as arguments: `docker exec -it wireguard /app/show-peer 1 4 5` or `docker exec -it wireguard /app/show-peer myPC myPhone myTablet` (Keep in mind that the QR codes are also stored as PNGs in the config folder).
77
70
78
71
The templates used for server and peer confs are saved under `/config/templates`. Advanced users can modify these templates and force conf generation by deleting `/config/wg0.conf` and restarting the container.
79
72
80
73
## Client Mode
81
-
Do not set the `PEERS` environment variable. Drop your client conf into the config folder as `/config/wg0.conf` and start the container.
74
+
75
+
Do not set the `PEERS` environment variable. Drop your client conf into the config folder as `/config/wg0.conf` and start the container.
82
76
83
77
If you get IPv6 related errors in the log and connection cannot be established, edit the `AllowedIPs` line in your peer/client wg0.conf to include only `0.0.0.0/0` and not `::/0`; and restart the container.
84
78
85
79
## Road warriors, roaming and returning home
80
+
86
81
If you plan to use Wireguard both remotely and locally, say on your mobile phone, you will need to consider routing. Most firewalls will not route ports forwarded on your WAN interface correctly to the LAN out of the box. This means that when you return home, even though you can see the Wireguard server, the return packets will probably get lost.
87
-
82
+
88
83
This is not a Wireguard specific issue and the two generally accepted solutions are NAT reflection (setting your edge router/firewall up in such a way as it translates internal packets correctly) or split horizon DNS (setting your internal DNS to return the private rather than public IP when connecting locally).
89
-
84
+
90
85
Both of these approaches have positives and negatives however their setup is out of scope for this document as everyone's network layout and equipment will be different.
91
86
92
87
## Maintaining local access to attached services
@@ -95,7 +90,7 @@ app_setup_block: |
95
90
96
91
When routing via Wireguard from another container using the `service` option in docker, you might lose access to the containers webUI locally. To avoid this, exclude the docker subnet from being routed via Wireguard by modifying your `wg0.conf` like so (modifying the subnets as you require):
Copy file name to clipboardExpand all lines: root/etc/s6-overlay/s6-rc.d/init-wireguard-module/run
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,9 @@ ip link del dev test 2>/dev/null
8
8
if ip link add dev test type wireguard; then
9
9
echo "**** It seems the wireguard module is already active. Skipping kernel header install and module compilation. ****"
10
10
ip link del dev test
11
+
if capsh --print | grep -qv '\!cap_sys_module'; then
12
+
echo "**** As the wireguard module is already active you can remove the SYS_MODULE capability from your container run/compose. ****"
13
+
fi
11
14
else
12
15
echo "**** The wireguard module is not active. If you believe that your kernel should have wireguard support already, make sure that it is activated via modprobe! ****"
0 commit comments