Skip to content

Instantly share code, notes, and snippets.

@schrobby
Created June 21, 2014 16:07
Show Gist options
  • Save schrobby/1c6df5a7ce4b3ff386df to your computer and use it in GitHub Desktop.
Save schrobby/1c6df5a7ce4b3ff386df to your computer and use it in GitHub Desktop.
Uses PIA's rudimentary API to forward a port and return it
#!/bin/bash
USER=`head -n 1 userdata.file`
PASS=`tail -n 1 userdata.file`
DEVICE=`/sbin/ifconfig | grep -o "tun[0-9]"`
LOCAL_IP=`/sbin/ifconfig $DEVICE | grep -Po "(?<=addr.)[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"`
curl -s -d "user=$USER&pass=$PASS&client_id=$(cat pia_client_id)&local_ip=$LOCAL_IP" https://www.privateinternetaccess.com/vpninfo/port_forward_assignment | grep -Po "[0-9]*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment