Skip to content

Instantly share code, notes, and snippets.

@catchsudheera
Created December 29, 2022 21:52
Show Gist options
  • Save catchsudheera/9ca9cc0b34646046f1d5eac5858a5d0c to your computer and use it in GitHub Desktop.
Save catchsudheera/9ca9cc0b34646046f1d5eac5858a5d0c to your computer and use it in GitHub Desktop.
This bash script can be used to generate the wireguard config from nordvpn nordlynx connection on a linux machine. I used this script to generate wg config for my Gl.iNet router vpn client
#!/bin/bash
CONFIG_FILE_NAME='nordlynx_wg.conf'
nordvpn disconnect
sleep 2
nordvpn set technology nordlynx
nordvpn connect Netherlands
nordvpn status
WG_CONF=$(sudo wg showconf nordlynx)
LOCAL_ADDRESS=$(/sbin/ifconfig nordlynx | grep 'inet ' | tr -s ' ' | cut -d" " -f3)
PRIVATE_KEY=$(echo "$WG_CONF" | grep 'PrivateKey = .*')
HOSTNAME=$(nordvpn status | grep 'Hostname'| cut -d" " -f2)
PORT=$(echo "$WG_CONF" | grep 'Endpoint = .*' | cut -d":" -f2)
PUBLIC_KEY=$(echo "$WG_CONF" | grep 'PublicKey = .*')
nordvpn disconnect
sh -c "cat > $CONFIG_FILE_NAME << 'EOL'
[Interface]
Address = ${LOCAL_ADDRESS}
${PRIVATE_KEY}
DNS = 103.86.96.100
[Peer]
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = $HOSTNAME:$PORT
${PUBLIC_KEY}
EOL"
echo " ---------------------------------------- "
cat $CONFIG_FILE_NAME
echo " ---------------------------------------- "
@catchsudheera
Copy link
Author

catchsudheera commented Dec 29, 2022

Steps

  1. Install nordvpn linux client. https://support.nordvpn.com/Connectivity/Linux/1182453582/Installing-and-using-NordVPN-on-Linux.htm
  2. Log in to the client by running nordvpn login
  3. Run above script
  4. Add the generated nordlynx_wg.conf config file to the router following the steps here : https://docs.gl-inet.com/en/4/tutorials/wireguard_client/?fbclid=IwAR2SHMfcwwfoYRWa8xW1HfXEz0ZVlg0zMXAss4BKPlIXpcY3tH9pb32rXd4#set-up-wireguard-client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment