diff --git a/bash/nord/README.md b/bash/nord/README.md index db2edfb..1c52dcd 100644 --- a/bash/nord/README.md +++ b/bash/nord/README.md @@ -6,39 +6,55 @@ These scripts make it easy to manage NordVPN Meshnet peers, configure exit nodes You can copy these scripts to your local bin directory to run them from anywhere: -Does need some ass bringing party tonight! - ```bash - ./copy_scripts.sh - source ~/.bashrc +./copy_scripts.sh +source ~/.bashrc ``` -Once installed, all commands are globally available with a `nord_` prefix (e.g. `nord_login`).# Available Commands Local File | Installed Global Command | Description | :--- | :--- | :--- | `login.sh` | `nord_login` | Authenticate with NordVPN | `logout.sh` | `nord_logout` | Log out of NordVPN | - `config.sh` | `nord_config` | Configure NordVPN routing and settings | - `connect.sh` | `nord_connect ` | Connect to a Meshnet peer | - `exit_node.sh` | `nord_exit_node ` | Set a peer as your exit node | - `list_peers.sh` | `nord_list_peers` | List available Meshnet peers | - `set_nickname.sh` | `nord_set_nickname` | Set a local nickname for the device | - `reset.sh` | `nord_reset` | Reset NordVPN settings to defaults | +Once installed, all commands are globally available with a `nord_` prefix (e.g. `nord_login`). -## Setup Examples +## Available Commands + +| Local File | Installed Global Command | Description | +| :--- | :--- | :--- | +| `login.sh` | `nord_login` | Authenticate with NordVPN | +| `logout.sh` | `nord_logout` | Log out of NordVPN | +| `config.sh` | `nord_config` | Configure NordVPN routing and settings | +| `connect.sh` | `nord_connect ` | Connect to a Meshnet peer | +| `exit_node.sh` | `nord_exit_node ` | Set a peer as your exit node | +| `list_peers.sh` | `nord_list_peers` | List available Meshnet peers | +| `set_nickname.sh` | `nord_set_nickname` | Set a local nickname for the device | +| `reset.sh` | `nord_reset` | Reset NordVPN settings to defaults | -Get a beautiful naighbour, love her, proposed to her, go puse for +## Setup Examples ### Set Exit Node - nord_exit_node mesh-raspberry - 1 - 2 ### Connect to Peer +```bash +nord_exit_node mesh-raspberry +``` + +### Connect to Peer ```bash - nord_connect mesh-raspberry +nord_connect mesh-dell ``` +## Peer Names + +The following peer names are configured/referenced: + +- `mesh-hp` +- `mesh-dell` +- `mesh-tab8` +- `mesh-pixel` +- `mesh-raspberry` +- `mesh-sunndal` + ## RaspberryPi Routing / Exit Node Setup -The Raspberry Pi is configured to act as an exit-node for other Meshnet peers, allowing them to route traffic through it and -access LAN devices (like printers or cameras). -*Note:* If you want to route streaming traffic (e.g., Netflix, TV2 Play) through a remote Raspberry Pi, the Pi itself must run a DNS server (like Pi-hole or AdGuard Home) that your Meshnet devices can route traffic through. +The Raspberry Pi will be configured to act as an exit-node for other Meshnet peers. Other peers using the Raspberry Pi for routing also gives them permission to access local devices like printers, cameras, and other LAN-connected devices. + +The ultimate goal is to install this Raspberry Pi at a remote location (e.g., family home) so that you can connect to local streaming services (Netflix, TV2 Play, etc.) from other locations. -ould you like me to go ahead and apply these updates (fixing both copy_scripts.sh and rewriting README.md)? +*Note:* If you want to route streaming traffic through a remote Raspberry Pi, the Pi itself must run a DNS server (like Pi-hole or AdGuard Home) that your Meshnet devices can route traffic through. diff --git a/bash/nord/copy_scripts.sh b/bash/nord/copy_scripts.sh index 22d26fa..233f9dc 100755 --- a/bash/nord/copy_scripts.sh +++ b/bash/nord/copy_scripts.sh @@ -14,6 +14,7 @@ cp config.sh ~/.local/bin/nord_config cp connect.sh ~/.local/bin/nord_connect +cp exit_node.sh ~/.local/bin/nord_exit_node cp list_peers.sh ~/.local/bin/nord_list_peers cp login.sh ~/.local/bin/nord_login cp logout.sh ~/.local/bin/nord_logout diff --git a/bash/nord/exit_node.sh b/bash/nord/exit_node.sh deleted file mode 100644 index 8d1948c..0000000 --- a/bash/nord/exit_node.sh +++ /dev/null @@ -1,107 +0,0 @@ -#! /usr/bin/bash - -# Exit immediately if a command exits with a non-zero status. -set -e - -# Check for jq -if ! command -v jq &> /dev/null; then - echo "Error: 'jq' is not installed. Please install 'jq' to parse the peers JSON file." >&2 - echo "On Debian/Ubuntu: sudo apt-get install jq" >&2 - exit 1 -fi - -# Function to display usage information -display_help() { - echo "Usage: $0 " - echo "" - echo "Configures the current device (e.g., Raspberry Pi) to act as an exit node for specific Meshnet peers." - echo "This script enables Meshnet, sets a nickname for the device, and allows specified peers to route through it." - echo "" - echo "Arguments:" - echo " The desired nickname for this device in NordVPN Meshnet (e.g., 'mesh-raspberry')." - echo "" - echo "Example:" - echo " $0 mesh-raspberry" -} - -if [ "$1" == "--help" ]; then - display_help - exit 0 -fi - -if [ -z "$1" ]; then - echo "Error: No nickname provided for this device." >&2 - display_help - exit 1 -fi - -NICKNAME="$1" -echo "Configuring '$NICKNAME' to be a NordVPN Meshnet exit node..." - -# Enable Meshnet and set the device's nickname -nordvpn set meshnet on && echo "Meshnet enabled." -nordvpn meshnet set nickname "$NICKNAME" && echo "Nickname set to '$NICKNAME'." - -# Define the path to the JSON file containing allowed peers -PEERS_FILE="$(dirname "$0")/peers.json" - -# Check if the peers file exists -if [ ! -f "$PEERS_FILE" ]; then - echo "Error: Peers configuration file not found at '$PEERS_FILE'." >&2 - echo "Please create a JSON file at this location with 'allowed_for_routing' and 'allowed_for_local' keys." >&2 - echo "Example: { \"allowed_for_routing\": [\"mesh-tab8\"], \"allowed_for_local\": [\"mesh-dell\"] }" >&2 - exit 1 -fi - -echo "Reading all peers from '$PEERS_FILE'..." -if ! mapfile -t ALL_PEERS < <(jq -r '.all_peers[]' "$PEERS_FILE"); then - echo "Error: Failed to parse 'all_peers' from '$PEERS_FILE'." >&2 - echo "Please ensure it's a valid JSON file with an 'all_peers' key containing an array of strings." >&2 - exit 1 -fi - -echo "Reading allowed peers for routing from '$PEERS_FILE'..." -if ! mapfile -t ROUTING_PEERS < <(jq -r '.allowed_for_routing[]' "$PEERS_FILE"); then - echo "Error: Failed to parse 'allowed_for_routing' from '$PEERS_FILE'." >&2 - echo "Please ensure it's a valid JSON file with an 'allowed_for_routing' key containing an array of strings." >&2 - exit 1 -fi - -echo "Reading allowed peers for local network access from '$PEERS_FILE'..." -if ! mapfile -t LOCAL_PEERS < <(jq -r '.allowed_for_local[]' "$PEERS_FILE"); then - echo "Error: Failed to parse 'allowed_for_local' from '$PEERS_FILE'." >&2 - echo "Please ensure it's a valid JSON file with an 'allowed_for_local' key containing an array of strings." >&2 - exit 1 -fi - -echo "Allowing specific peers to route through '$NICKNAME':" -for PEER in "${ROUTING_PEERS[@]}"; do - nordvpn meshnet peer routing allow "$PEER" && echo " - Allowed '$PEER' to route through this device." -done - -echo "Allowing specific peers to access this device's local network:" -for PEER in "${LOCAL_PEERS[@]}"; do - nordvpn meshnet peer local allow "$PEER" && echo " - Allowed '$PEER' to access this device's local network." -done - -# Function to disable routing for peers not in the allowlist. -disable_routing_for_unallowed_peers() { - echo "Disabling routing for peers not on the allowlist..." - for PEER in "${ALL_PEERS[@]}"; do - # Don't try to change permissions for the device this script is running on. - if [[ "$PEER" == "$NICKNAME" ]]; then - continue - fi - - # Check if the peer is in the ROUTING_PEERS array. - # The '!' negates the result, so this runs if the peer is NOT found. - if ! printf '%s\n' "${ROUTING_PEERS[@]}" | grep -q -x "$PEER"; then - nordvpn meshnet peer routing disable "$PEER" && echo " - Disabled routing for '$PEER'." - fi - done -} - -# Ensure peers not explicitly allowed cannot route through this device. -disable_routing_for_unallowed_peers - -echo "Configuration complete. Check status with 'nordvpn meshnet peer list'."