Automatically create Wireguard exit nodes in your Headscale tailnet
- Headscale running on PR #2892
- Mullvad account
This small Python script automatically creates Mullvad Wireguard-only nodes in your Headscale tailnet & connects your devices with them.
First, you'll have to configure the required environment variables in .env.example and move the file to .env.
$ nix shell .$ pip install -r requirements.txt
$ python3 -m src.headscale_mullvad.main [COMMAND]This registers Mullvad relays as nodes in Headscale.
$ headscale-mullvad relay add --id $USER_ID
Registering 500 relays ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00You can also use --name to specify a user by name.
$ headscale-mullvad relay add --id $USER_ID --countries de,es
[00:00:00] INFO Fetching Mullvad relays
Registering 10 relays ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00Once relays are added, you can grant specific nodes access to them and set up authentication with Mullvad automatically.
$ headscale-mullvad node add --id $NODE_ID
[00:00:00] INFO Adding node abc to Mullvad
[00:00:00] INFO Creating relay connections
Creating 10 connections ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00You can also use --name to specify a node by name.
View all registered Mullvad relays.
$ headscale-mullvad relay list
Mullvad relays
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┓
┃ ID ┃ Name ┃ Country ┃ City ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━┩
│ 100000001 │ mv-cy-nic-wg-001 │ Cyprus │ Nicosia │
│ 100000002 │ mv-cy-nic-wg-002 │ Cyprus │ Nicosia │
└───────────┴──────────────────┴─────────┴─────────┘Check which nodes have access to the relays.
$ headscale-mullvad node list
Nodes
┏━━━━┳━━━━━━┳━━━━━━┳━━━━━━━━┓
┃ ID ┃ Name ┃ User ┃ Access ┃
┡━━━━╇━━━━━━╇━━━━━━╇━━━━━━━━┩
│ 1 │ abc │ foo │ Yes │
│ 2 │ xyz │ bar │ No │
└────┴──────┴──────┴────────┘This will revoke access to all relays for a specific node.
$ headscale-mullvad node delete --id $NODE_ID
[00:00:00] INFO Deleting connections for node abc
Deleting 10 connections ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00This will delete relays and any connections to them.
$ headscale-mullvad relay delete --countries de,es
Deleting 10 connections ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Deleting 10 relays ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00Omit --countries to delete all relays.