Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save stevecrozz/fd91035fb3133c385dab8825ec219baa to your computer and use it in GitHub Desktop.

Select an option

Save stevecrozz/fd91035fb3133c385dab8825ec219baa to your computer and use it in GitHub Desktop.
Process mullvad ini config into some edgerouter config
#! /bin/bash
private_key=$(grep PrivateKey "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}')
public_key=$(grep PublicKey "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}')
allowed_ips=$(grep AllowedIPs "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}')
address=$(grep Address "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}')
endpoint=$(grep Endpoint "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}')
echo $private_key
echo $public_key
echo $allowed_ips | cut -d ',' -f 1
echo $allowed_ips | cut -d ',' -f 2
ipv4address=$(echo $address | cut -d ',' -f 1)
ipv6address=$(echo $address | cut -d ',' -f 2)
echo $endpoint
cat << EOF
delete interfaces wireguard wg1 address
delete interfaces wireguard wg1 peer
set interfaces wireguard wg1 address $ipv4address
set interfaces wireguard wg1 address $ipv6address
set interfaces wireguard wg1 peer $public_key
set interfaces wireguard wg1 peer $public_key allowed-ips 0.0.0.0/0
set interfaces wireguard wg1 peer $public_key allowed-ips ::0/0
set interfaces wireguard wg1 peer $public_key endpoint $endpoint
set interfaces wireguard wg1 private-key $private_key
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment