Skip to content

Instantly share code, notes, and snippets.

@GTRekter
Created May 20, 2023 10:59
Show Gist options
  • Save GTRekter/5857aded1c4f7f5b0114600ff8b1867a to your computer and use it in GitHub Desktop.
Save GTRekter/5857aded1c4f7f5b0114600ff8b1867a to your computer and use it in GitHub Desktop.
This script automates NordVPN connection to different countries and performs nslookup for a specified endpoint. It checks if NordVPN is installed and logged in, prompts for installation if needed, and asks for the endpoint for nslookup.
#!/bin/bash
# Check if NordVPN is installed
if ! command -v nordvpn &> /dev/null; then
echo "NordVPN is not installed. Installing..."
# Determine the installation command based on the system
if command -v apt-get &> /dev/null; then
sudo apt-get install nordvpn
elif command -v yum &> /dev/null; then
sudo yum install nordvpn
else
echo "Unsupported package manager. Please install NordVPN manually."
exit 1
fi
fi
if ! nordvpn account &> /dev/null; then
echo "NordVPN is not logged in. Logging in..."
read -p "Enter your NordVPN username: " username
read -sp "Enter your NordVPN password: " password
nordvpn login --username "$username" --password "$password"
fi
# Prompt for the endpoint for nslookup
read -p "Enter the endpoint for nslookup: " endpoint
countries=$(nordvpn countries)
read -ra countryArray <<< "$countries"
for country in "${countryArray[@]}"; do
echo "$country"
nordvpn connect "$country"
nslookup "$endpoint"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment