Skip to content

Commit fd9cda5

Browse files
authored
Merge pull request #1130 from JoshStark/wireguard-mullvad
2 parents 6360fcf + 3b84427 commit fd9cda5

File tree

22 files changed

+259
-103
lines changed

22 files changed

+259
-103
lines changed

.github/workflows/BuildImage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ on:
1212
env:
1313
GITHUB_REPO: "linuxserver/docker-mods" #don't modify
1414
ENDPOINT: "linuxserver/mods" #don't modify
15-
BASEIMAGE: "replace_baseimage" #replace
16-
MODNAME: "replace_modname" #replace
15+
BASEIMAGE: "wireguard" #replace
16+
MODNAME: "mullvad" #replace
1717
MOD_VERSION: ${{ inputs.mod_version }} #don't modify
18-
MULTI_ARCH: "true" #set to false if not needed
18+
MULTI_ARCH: "false" #set to false if not needed
1919

2020
jobs:
2121
set-vars:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
FROM scratch
44

5-
LABEL maintainer="username"
5+
LABEL maintainer="Stark"
66

77
# copy local files
88
COPY root/ /

Dockerfile.complex

Lines changed: 0 additions & 33 deletions
This file was deleted.

README.md

Lines changed: 97 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,105 @@
1-
# Rsync - Docker mod for openssh-server
1+
# Mullvad - Docker mod for Wireguard
22

3-
This mod adds rsync to openssh-server, to be installed/updated during container start.
3+
This mod adds a script which runs on service startup to communicate with the Mullvad APIs. This obtains the relevant config for a chosen Wireguard node which the container can tunnel through when running in CLIENT mode.
44

5-
In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync`
5+
## Parameters
66

7-
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:openssh-server-rsync|linuxserver/mods:openssh-server-mod2`
7+
### `-e MULLVAD_ACCOUNT` (required)
88

9-
# Mod creation instructions
9+
Your Mullvad account number. This is used to make an API call to obtain your tunnel IP address.
1010

11-
* Fork the repo, create a new branch based on the branch `template`.
12-
* Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done.
13-
* Inspect the `root` folder contents. Edit, add and remove as necessary.
14-
* After all init scripts and services are created, run `find ./ -path "./.git" -prune -o \( -name "run" -o -name "finish" -o -name "check" \) -not -perm -u=x,g=x,o=x -print -exec chmod +x {} +` to fix permissions.
15-
* Edit this readme with pertinent info, delete these instructions.
16-
* Finally edit the `.github/workflows/BuildImage.yml`. Customize the vars for `BASEIMAGE` and `MODNAME`. Set the versioning logic and `MULTI_ARCH` if needed.
17-
* Ask the team to create a new branch named `<baseimagename>-<modname>`. Baseimage should be the name of the image the mod will be applied to. The new branch will be based on the `template` branch.
18-
* Submit PR against the branch created by the team.
11+
### `-e MULLVAD_PRIVATE_KEY` (required)
1912

13+
The private key of a device on your Mullvad account. You will need to [create a device](https://mullvad.net/en/account/devices) under your account, then use the generated private key for this variable's value. If you have an existing device, you will need to get the private key out of a previously generated config file.
2014

21-
## Tips and tricks
15+
### `-e MULLVAD_LOCATION` (required)
2216

23-
* Some images have helpers built in, these images are currently:
24-
* [Openvscode-server](https://github.com/linuxserver/docker-openvscode-server/pull/10/files)
25-
* [Code-server](https://github.com/linuxserver/docker-code-server/pull/95)
17+
Your spefied location you wish to tunnel through. This variable supports three different formats which effect which node you tunnel through:
18+
19+
| Type | Example | Result |
20+
| :-- | :-- | :-- |
21+
| Region | gb | A node will be randomly picked from all locations within Great Britain |
22+
| City | gb-lon | A node will be randomly picked from one of the locations in London |
23+
| Node(s) | gb-lon-wg-001,gb-lon-wg-002 | Allows for a specific node to be selected, or from a pool of hand-picked nodes. This option is not region or city locked, so you may pick nodes from any global location |
24+
25+
**Note**: The API this script uses does not distinguish between owned or rented nodes. If that is something you care about, you may need to look at the [Mullvad server list](https://mullvad.net/en/servers) and pick some nodes you wish to tunnel through.
26+
27+
### `-e MULLVAD_DNS` (default: 10.64.0.1)
28+
29+
An optional variable which lets you override the default DNS used for tunnelled connections. If not set, this default's to Mullvad's DNS.
30+
31+
### `-e LAN_NETWORKS`
32+
33+
If you run web services through a Wireguard container (via `network_mode: service`) you will likely lose access to their web UIs due to the container's default routing rules. Use this variable to inform the container to apply a rule which allows inbound traffic from one or more LAN networks.
34+
35+
E.g. `-e LAN_NETWORKS=192.168.0.0/24,10.20.0.0/16`.
36+
37+
Only use this if you require access to a service's web UI.
38+
39+
### `-e ALLOW_ATTACHED_NETWORKS` (default: false)
40+
41+
If you have a service running within the same stack as Wireguard but not routed through it, you can't be default contact another service routed through the Wireguard container. When this parameter is set to `true`, the script will apply a rule which allows inbound traffic from services on any networks which have been attached to the Wireguard container.
42+
43+
### Example `compose.yml`
44+
45+
A basic example showing a wireguard container in client mode using this mod, with Sonarr routed through it and Seerr which is on the same shared stack network but not routed through wireguard. The outcome of this is that Sonarr will have its WAN requests routed through Wireguard, but Seerr will not. Seerr is able to communicate with Sonarr via `http://wireguard_client:8989` because it is on the same default stack network and `ALLOW_ATTACHED_NETWORKS=true`. Users on the LAN network `192.168.0.0/24` may also access Sonarr's web UI via the docker host's IP.
46+
47+
```yaml
48+
services:
49+
50+
wireguard_client:
51+
image: lscr.io/linuxserver/wireguard
52+
cap_add:
53+
- NET_ADMIN
54+
environment:
55+
- PUID=1000
56+
- PGID=1000
57+
- TZ=Europe/London
58+
- DOCKER_MODS=linuxserver/mods:wireguard-mullvad
59+
- MULLVAD_PRIVATE_KEY=$MULLVAD_PRIVATE_KEY
60+
- MULLVAD_ACCOUNT=$MULLVAD_ACCOUNT
61+
- MULLVAD_LOCATION=gb-lon
62+
- LAN_NETWORKS=192.168.0.0/24
63+
- ALLOW_ATTACHED_NETWORKS=true
64+
volumes:
65+
- /opt/appdata/wireguard/config:/config
66+
- /lib/modules:/lib/modules
67+
ports:
68+
- "8989:8989"
69+
healthcheck:
70+
test: |
71+
bash -c 'curl -fs https://am.i.mullvad.net/connected | grep -q "You are connected to Mullvad" || exit 1'
72+
interval: 1m
73+
timeout: 10s
74+
retries: 3
75+
start_period: 10s
76+
sysctls:
77+
- net.ipv4.conf.all.src_valid_mark=1
78+
- net.ipv6.conf.all.disable_ipv6=1
79+
- net.ipv6.conf.default.disable_ipv6=1
80+
restart: unless-stopped
81+
82+
sonarr:
83+
image: lscr.io/linuxserver/sonarr:latest
84+
network_mode: service:wireguard_client
85+
depends_on:
86+
- wireguard_client
87+
restart: unless-stopped
88+
environment:
89+
PUID: '1000'
90+
PGID: '1004'
91+
TZ: Europe/London
92+
volumes:
93+
- /opt/appdata/sonarr:/config
94+
95+
seerr:
96+
image: ghcr.io/seerr-team/seerr:latest
97+
restart: unless-stopped
98+
user: "1000"
99+
depends_on:
100+
- wireguard_client
101+
environment:
102+
- TZ=Europe/London
103+
volumes:
104+
- /opt/appdata/seerr:/app/config
105+
```

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-add-package/run

Lines changed: 0 additions & 30 deletions
This file was deleted.

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-add-package/up

Lines changed: 0 additions & 1 deletion
This file was deleted.

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-install/run

Lines changed: 0 additions & 8 deletions
This file was deleted.

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-install/type

Lines changed: 0 additions & 1 deletion
This file was deleted.

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-install/up

Lines changed: 0 additions & 1 deletion
This file was deleted.

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-add-package/dependencies.d/init-mods renamed to root/etc/s6-overlay/s6-rc.d/init-mod-wireguard-mullvad-install/dependencies.d/init-mods

File renamed without changes.

0 commit comments

Comments
 (0)