Skip to content

Instantly share code, notes, and snippets.

@Dreyer
Last active February 3, 2024 21:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Dreyer/161b920f0d8300ed3bc750ae2f80c339 to your computer and use it in GitHub Desktop.
Save Dreyer/161b920f0d8300ed3bc750ae2f80c339 to your computer and use it in GitHub Desktop.
Check the status of a NordVPN connection from your shell.
#!/bin/bash
URL='https://nordvpn.com/wp-admin/admin-ajax.php?action=get_user_info_data'
JSON=$(curl -s $URL)
printf "\n"
#echo $JSON | python -m json.tool
echo $JSON | python -c 'import sys, json; data = json.load(sys.stdin); print "IP: %s (%s)\nStatus: %s" % (data["ip"], data["isp"], "\033[32mProtected" if data["status"] is True else "\033[31mUnprotected");'
printf "\n"
@mannyrye
Copy link

mannyrye commented Nov 3, 2017

They changed their code. The address you used does not always work. This fixes it

#!/bin/bash

URL='https://api.nordvpn.com/vpn/check/full'
JSON=$(curl -s $URL)

printf "\n"
#echo $JSON | python -m json.tool
echo $JSON | python -c 'import sys, json; data = json.load(sys.stdin); print "IP: %s (%s)\nStatus: %s" % (data["ip"], data["isp"], "\033[32mProtected" if data["status"] == "Protected" else "\033[31mUnprotected");'
printf "\n"

@ClouDevops101
Copy link

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