Skip to content

Commit cdb5192

Browse files
authored
Merge pull request #10 from edgar-vincent/improve-syntax-and-wording
Big refactor
2 parents 1bfae2c + b1ee77e commit cdb5192

File tree

3 files changed

+426
-300
lines changed

3 files changed

+426
-300
lines changed

README.md

Lines changed: 50 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,97 @@
1-
# mullvad tailscale / zerotier
2-
<p align="center"><b>Mullvad NF Tables Script</b></p>
1+
# Mullvad with Tailscale / Zerotier
2+
<p align="center"><b>Mullvad Nftables script</b></p>
33

44
> Note: The script was formerly called `mtc`. It is now `mnf` and has been improved.
55
6-
This is a simple bash script that will allow you to run MullvadVPN along with Tailscale or Zerotier in a Linux system.
6+
This is a simple bash script that will allow you to run Mullvad VPN along with Tailscale or Zerotier on Linux.
77

8-
The script is named `mnf` as per `Mullvad NF Tables`. The script was inspired by [this gist](https://gist.github.com/1player/e9cadfef833d5eb5a23c30223f560147), although it now has been completely rewritten and improved.
8+
`mnf` (for `Mullvad nftables`) was inspired by [this gist](https://gist.github.com/1player/e9cadfef833d5eb5a23c30223f560147), although it has been completely rewritten and improved.
99

10-
The script can work with Zerotier and Tailscale. It would most probably also work with any other VPN like NetMaker or Wireguard, but I have not tested it.
10+
This script works with Zerotier and Tailscale.
1111

1212
## Features
13-
14-
- [x] Complete usage guide (and help)
15-
- [x] Bring up Tailscale/Zerotier + Mullvad with a random server
16-
- [x] Connect to a specific country via country code.
17-
- [x] Select a specific rules file
18-
- [x] Select a specific nf table
13+
- [x] Bring up Tailscale/Zerotier and Mullvad with a random server
14+
- [x] Connect to a specific country
1915
- [x] Blacklist countries to avoid connecting to them
20-
- [x] Use only [RAM-only (no disk) servers](https://mullvad.net/en/blog/2022/8/1/expanding-diskless-infrastructure-to-more-locations-system-transparency-stboot/)
21-
- [x] Set custom DNS server for Mullvad
22-
- [x] Bring down Mullvad VPN and remove nftables entries.
23-
- [x] Bring down all (tailscale/zerotier+mullvad+nftables)
24-
- [x] Automatically update the relay list at stratup
25-
- [x] Only apply nftables configuration and do nothing more
26-
- [x] Only remove nftables configuration and do nothing more
16+
- [x] Use only [RAM-only (diskless) servers](https://mullvad.net/en/blog/2022/8/1/expanding-diskless-infrastructure-to-more-locations-system-transparency-stboot/)
17+
- [x] Set custom DNS server(s) for Mullvad
18+
- [x] Bring down all (tailscale/zerotier+mullvad+nftables) or each one selectively
19+
- [x] Automatically update the Mullvad relay list at startup
20+
- [x] and more.
2721

2822
## Requirements
2923

30-
- [Mullvad](https://mullvad.net/download/) must be installed in your system so you have the [mullvad cli](https://mullvad.net/en/help/how-use-mullvad-cli/) command available.
31-
24+
- [Mullvad](https://mullvad.net/download/) must be installed on your system, so that the [mullvad cli](https://mullvad.net/en/help/how-use-mullvad-cli/) command is available.
3225
- Install the `nftables` package.
33-
34-
- `tailscale` or `zerotier-one` must be installed and configured with its proper setup.
26+
- `tailscale` or `zerotier-one` must be installed and configured properly.
3527

3628
## Setup
37-
3829
1. Clone this repo:
39-
4030
```bash
4131
git clone https://github.com/r3nor/mullvad-tailscale
4232
```
43-
4433
> Or download and extract the latest release source from [releases page](https://github.com/r3nor/mullvad-tailscale/releases).
4534
46-
2. Go to cloned dir: `cd mullvad-tailscale`
47-
48-
3. Set execution permissions on script:
49-
35+
2. Go to the cloned dir: `cd mullvad-tailscale`
36+
3. Make the script executable:
5037
```bash
51-
chmod 700 mnf
38+
chmod +x mnf
5239
```
53-
5440
4. Inspect and **edit** the script file (`mnf`):
55-
56-
- Change the `RULES_DIR` variable to point to the folder where the `mullvad.rules` file from this repository is located. If you cloned the repo, it should be inside the `mullvad-tailscale` folder. Please, make sure you add the trailing slash (slash at the end).
57-
58-
- Modify the `EXCLUDED_COUNTRY_CODES` if you want to exclude any countries from the VPN connection (don't connect to these countries). If you do not want to exclude any CC set this variable to `'(none)'`. If you want to add more, just follow the pattern.
59-
41+
- Change the `RULES_DIR` variable to point to the directory in which the `mullvad.rules` file from this repository is located. If you cloned the repo, it should be inside the `mullvad-tailscale` folder.
42+
- Modify the `EXCLUDE_COUNTRY_CODES` variable if you want to exclude any countries from the VPN connection (don't connect to these countries). If you do not want to exclude any country, set this variable to `''`. If you want to add more, just add most two-letter country codes, separated by spaces.
43+
- Uncomment the `INCLUDE_COUNTRY_CODES` variable if you want to force the connection to specific countries (only connect to these countries). This will override `EXCLUDE_COUNTRY_CODES`. If you want to add more, just add most two-letter country codes, separated by spaces.
6044
5. Edit the `mullvad.rules` file:
61-
6245
- Set your Tailscale/Zerotier network IPs in the `EXCLUDED_IPS` variable (you can use CDIR notation).
63-
- Set your Tailscale/Zerotier network IPv6 IPs in the `EXCLUDED_IPV6` variable (you can use CDIR notation), leave it blank (`= ""`) if there are no IPv6s.
46+
- Set your Tailscale/Zerotier network IPv6 IPs in the `EXCLUDED_IPV6` variable (you can use CDIR notation). If you do not want IPv6 support, comment this line as well as the one starting with `ip6 daddr $EXCLUDED_IPV6` .
6447
- Set your Tailscale/Zerotier DNS resolver in `RESOLVER_ADDRS`.
65-
- Should be `100.100.100.100` for Tailscale.
66-
- If you are using Zerotier, the DNS resolver can be found in the `/etc/resolv.conf` file after running `zerotier-one` service. You will find it in a new line, it should look something like `10.X.X.X`.
67-
68-
> You can find the Tailscale/Zerotier IPs in your dashboard. Just copy and paste for each of your devices.
69-
70-
48+
- It should be `100.100.100.100` for Tailscale.
49+
- If you are using Zerotier, the DNS resolver IP can be found in the `/etc/resolv.conf` file after running `zerotier-one` service. You will find it in a new line. It should look like `10.X.X.X`.
50+
> You can find the Tailscale/Zerotier IPs in your dashboard. Just use copy and paste for each of your devices.
7151
6. Setup your Mullvad account if you haven't done it yet:
72-
7352
```bash
7453
mullvad account login 1234123412341234
7554
```
7655

7756
## Usage
78-
79-
For Zerotier users, you should apply `-z` flag on all `up/down` actions.
80-
81-
> You must be inside the directory where the script is located, or use it with the absolute path to it. If you want to run the command without specifying the folder where it is located, add the script directory to your PATH variable.
82-
57+
> You might want to add `mnf` to your PATH.
8358
[Jump to an example usage](#example)
8459

8560
### up
8661
Apply nftables configuration and connect to Mullvad and Tailscale/Zerotier.
87-
88-
- mnf up [-OPTIONS]:
89-
- -h, --help: Show this help message.
90-
- -r, --ram: No-disk/RAM only Mullvad relays (default: all servers)
91-
- -z, --zerotier: Use Zerotier instead of Tailscale
92-
- -d, --dns: Set custom Mullvad DNS Server (i.e. -d 1.1.1.1)
93-
- -c, --country: Specify a country code to connect to (i.e. -c gb)
94-
- -f, --file: Specify a particular NFT rules file (default: mullvad.rules)
62+
``` bash
63+
mnf up [-OPTIONS]:
64+
-h | --help Show this help message
65+
-r | --ram No-disk/RAM only Mullvad relays (default: all servers)
66+
-z | --zerotier Use Zerotier instead of Tailscale
67+
-d | --dns Set custom Mullvad DNS server (i.e. -d 1.1.1.1 or -d 8.8.8.8,1.1.1.1)
68+
-c | --country Specify country code(s) to connect to (i.e. -c gb or -c fr,pt,es)
69+
-f | --file Specify a particular NFT rules file (default: mullvad.rules)
70+
```
9571

9672
### down
9773
Bring down Mullvad and remove nftables configuration.
98-
99-
- mnf down [-OPTIONS]:
100-
- -h, --help: Show this help message.
101-
- -a, --all: Stop Mullvad and Tailscale/Zerotier (default: only stop Mullvad)
102-
- -z, --zerotier: Use Zerotier instead of Tailscale
103-
- -t, --table: Indicate the nft tablename to bring down (default: mullvad-ts)
74+
``` bash
75+
mnf down [-OPTIONS]:
76+
-h | --help Show this help message
77+
-a | --all Stop Mullvad and Tailscale/Zerotier (default: only stop Mullvad)
78+
-z | --zerotier Use Zerotier instead of Tailscale
79+
-t | --table Indicate the nft tablename to bring down (default: mullvad-ts)
80+
```
10481

10582
### conf
10683
Apply nftables configuration so Mullvad and Tailscale/Zerotier can work together and do nothing more.
84+
``` bash
85+
mnf conf [-OPTIONS]:
86+
-u Remove the nftables configuration
87+
-h Show this help message
88+
```
10789

108-
- mnf conf [-OPTIONS]:
109-
- -u: Remove the nftables configuration.
110-
- -h: Show this help message.
111-
11290
### Example
91+
`mnf up -rz -d 1.1.1.1 -c ee`
11392

114-
`bash ~/LINUX/VPN/mnf.sh up -rz -d 1.1.1.1 -c ee`
115-
116-
or, the same with long flag names:
93+
or the same command with long flag names:
11794

118-
`bash ~/LINUX/VPN/mnf.sh up --ram --zerotier --dns 1.1.1.1 --country ee`
95+
`mnf up --ram --zerotier --dns 1.1.1.1 --country ee`
11996

120-
The command above would set the connection to Mullvad's RAM-only servers (`-r`) and use Zerotier (`-z`). It would also configure the MullvadVPN DNS to `1.1.1.1` as indicated with the `-d` flag. Finally, the selected country would be Estonia as per the Country Code indicated after the `-c` flag.
97+
This connects to Mullvad's RAM-only servers (`-r`) in Estonia (`-c ee`) and uses Zerotier (`-z`). It also sets the MullvadVPN DNS to `1.1.1.1` .

0 commit comments

Comments
 (0)