Skip to content

Commit e59aaed

Browse files
authored
Merge pull request Place1#104 from DasSkelett/fix/docker-modules
Add CAP_SYS_MODULE to Docker commands and docker-compose.yml
2 parents 349f5fa + 3b78d17 commit e59aaed

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ docker run \
5151
-it \
5252
--rm \
5353
--cap-add NET_ADMIN \
54+
--cap-add SYS_MODULE \
5455
--device /dev/net/tun:/dev/net/tun \
5556
--sysctl net.ipv6.conf.all.disable_ipv6=0 \
5657
--sysctl net.ipv6.conf.all.forwarding=1 \
5758
-v wg-access-server-data:/data \
58-
-v /lib/modules:/lib/modules \
59+
-v /lib/modules:/lib/modules:ro \
5960
-e "WG_ADMIN_PASSWORD=$WG_ADMIN_PASSWORD" \
6061
-e "WG_WIREGUARD_PRIVATE_KEY=$WG_WIREGUARD_PRIVATE_KEY" \
6162
-p 8000:8000/tcp \
@@ -87,8 +88,9 @@ helm delete my-release
8788
Download the the docker-compose.yml file from the repo and run the following command.
8889

8990
```bash
90-
export WG_ADMIN_PASSWORD="example"
91+
export WG_ADMIN_PASSWORD=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1)
9192
export WG_WIREGUARD_PRIVATE_KEY="$(wg genkey)"
93+
echo "Your automatically generated admin password for the wg-access-server's web interface: $WG_ADMIN_PASSWORD"
9294

9395
docker-compose up
9496
```

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ services:
99
container_name: wg-access-server
1010
cap_add:
1111
- NET_ADMIN
12+
- SYS_MODULE
1213
sysctls:
1314
net.ipv6.conf.all.disable_ipv6: 0
1415
net.ipv6.conf.all.forwarding: 1
1516
volumes:
17+
- "/lib/modules:/lib/modules:ro"
1618
- "wg-access-server-data:/data"
1719
# - "./config.yaml:/config.yaml" # if you have a custom config file
1820
environment:

docs/deployment/1-docker.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,33 @@ docker run \
99
-it \
1010
--rm \
1111
--cap-add NET_ADMIN \
12+
--cap-add SYS_MODULE \
1213
--device /dev/net/tun:/dev/net/tun \
1314
--sysctl net.ipv6.conf.all.disable_ipv6=0 \
1415
--sysctl net.ipv6.conf.all.forwarding=1 \
1516
-v wg-access-server-data:/data \
16-
-v /lib/modules:/lib/modules \
17+
-v /lib/modules:/lib/modules:ro \
1718
-e "WG_ADMIN_PASSWORD=$WG_ADMIN_PASSWORD" \
1819
-e "WG_WIREGUARD_PRIVATE_KEY=$WG_WIREGUARD_PRIVATE_KEY" \
1920
-p 8000:8000/tcp \
2021
-p 51820:51820/udp \
2122
ghcr.io/freifunkmuc/wg-access-server:latest
2223
```
2324

24-
Make sure you have the `ip_tables` and `ip6_tables` kernel modules loaded on the host:
25+
## Modules
26+
27+
If you load the kernel modules `ip_tables` and `ip6_tables` on the host,
28+
you can drop the `SYS_MODULE` capability and remove the `/lib/modules` mount:
2529
```bash
2630
modprobe ip_tables && modprobe ip6_tables
31+
# Load modules on boot
32+
echo ip_tables >> /etc/modules
33+
echo ip6_tables >> /etc/modules
2734
```
35+
This is highly recommended, as a container with CAP_SYS_MODULE essentially has root privileges
36+
over the host system and attacker could easily break out of the container.
37+
38+
## IPv4-only (without IPv6)
2839

2940
If you don't want IPv6 inside the VPN network, set `WG_VPN_CIDRV6=0`.
3041
In this case you can also get rid of the sysctls:

docs/deployment/2-docker-compose.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Docker Compose
22

3-
You can run wg-access-server using the following example
4-
Docker Compose file.
3+
You can run wg-access-server using the following example Docker Compose file.
54

6-
Checkout the [configuration docs](../2-configuration.md) to learn how wg-access-server
7-
can be configured.
5+
Checkout the [configuration docs](../2-configuration.md) to learn how wg-access-server can be configured.
6+
7+
Please also read the [Docker instructions](../1-docker.md) for general information regarding Docker deployments.
88

99
```yaml
1010
{!../docker-compose.yml!}

0 commit comments

Comments
 (0)