Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save sandeepkv93/84870b21b582866505898cb292ce19ce to your computer and use it in GitHub Desktop.

Select an option

Save sandeepkv93/84870b21b582866505898cb292ce19ce to your computer and use it in GitHub Desktop.
NordVPN Command Line (CLI) – Complete Reference Guide

NordVPN Command Line (CLI) – Complete Reference Guide

Table of Contents

  1. Overview
  2. Installation
  3. Login & Account Management
  4. Basic Connection Commands
  5. Countries, Cities & Groups (Server Discovery)
  6. Server Groups (P2P, Double VPN, etc.)
  7. Status & Diagnostics
  8. Settings & Configuration
  9. Protocols & Technology (NordLynx / OpenVPN)
  10. Kill Switch, Firewall & LAN Access
  11. Whitelisting (Split Tunneling via CLI)
  12. Automation & Scripting
  13. systemd / Service Management
  14. Troubleshooting & Recovery
  15. Power‑User Tips

1. Overview

NordVPN provides a first‑class CLI that allows:

  • Fast connections without GUI overhead
  • Scriptable VPN workflows
  • Server selection via constraints, not raw server lists

⚠️ Important design note: The CLI does not expose individual server lists (hostnames, IPs, load %). You choose filters (country, city, group), and NordVPN selects the optimal server.


2. Installation

Linux (Ubuntu / Debian / Fedora / Arch)

sh <(curl -sSf https://downloads.nordcdn.com/apps/linux/install.sh)

Verify installation:

nordvpn --version

Supported on most modern Linux distributions.


macOS (Homebrew)

brew install nordvpn

Start NordVPN service:

brew services start nordvpn

Verify:

nordvpn --version

3. Login & Account Management

Login (one‑time)

nordvpn login
  • Opens browser for authentication
  • Returns control to terminal after success

Check account

nordvpn account

Logout

nordvpn logout

4. Basic Connection Commands

Connect to fastest available server

nordvpn connect

Connect to a country

nordvpn connect us
nordvpn connect india
nordvpn connect germany

Connect to a specific city

nordvpn connect united_states new_york

City names use underscores, not spaces.

Disconnect

nordvpn disconnect

5. Countries, Cities & Groups (Server Discovery)

List available countries

nordvpn countries

List cities in a country

nordvpn cities united_states

List server groups

nordvpn groups

Example output:

Standard VPN servers
P2P
Double VPN
Onion Over VPN
Dedicated IP

❌ There is no command like nordvpn servers.


6. Server Groups (Specialized Routing)

P2P servers

nordvpn connect p2p

Double VPN

nordvpn connect double_vpn

Onion over VPN

nordvpn connect onion_over_vpn

Dedicated IP

nordvpn connect dedicated_ip

Combine country + group

nordvpn connect us --group p2p

7. Status & Diagnostics

Show current VPN status

nordvpn status

Displays:

  • Connection state
  • Server hostname
  • Country / city
  • VPN IP address
  • Protocol
  • Transfer statistics

8. Settings & Configuration

Show all settings

nordvpn settings

Enable auto‑connect

nordvpn set autoconnect on

Auto‑connect to a country

nordvpn set autoconnect on us

Disable auto‑connect

nordvpn set autoconnect off

9. Protocols & Technology

Set NordLynx (WireGuard – fastest)

nordvpn set technology nordlynx

Use OpenVPN

nordvpn set technology openvpn

Recommendation: NordLynx for performance unless blocked by network policy.


10. Kill Switch, Firewall & LAN Access

Enable Kill Switch

nordvpn set killswitch on

Disable Kill Switch

nordvpn set killswitch off

Enable LAN discovery (SSH, NAS, Kubernetes, etc.)

nordvpn set lan-discovery on

Disable NordVPN firewall

nordvpn set firewall off

11. Whitelisting (Split Tunneling via CLI)

Allow specific ports (bypass VPN)

nordvpn whitelist add port 22
nordvpn whitelist add port 8080

Allow local subnet

nordvpn whitelist add subnet 192.168.1.0/24

Remove all whitelist rules

nordvpn whitelist remove all

Useful for home servers, SSH access, databases, or internal services.


12. Automation & Scripting

Simple Bash script

#!/bin/bash
nordvpn connect us
sleep 10
curl ifconfig.me

Rotate regions example

COUNTRIES=(us uk germany japan)
for c in "${COUNTRIES[@]}"; do
  nordvpn connect "$c"
  sleep 30
done

13. systemd / Service Management (Linux)

Enable NordVPN daemon at boot

sudo systemctl enable nordvpnd

Start daemon

sudo systemctl start nordvpnd

Restart daemon

sudo systemctl restart nordvpnd

14. Troubleshooting & Recovery

Restart service

sudo systemctl restart nordvpnd   # Linux
brew services restart nordvpn     # macOS

Check running processes

ps aux | grep nordvpn

Reset configuration

nordvpn logout
nordvpn login

Check connectivity

curl ifconfig.me

15. Power‑User Tips

  • Prefer NordLynx for best latency and throughput
  • Use city + group filters instead of chasing server names
  • Enable LAN discovery for local development clusters
  • Whitelist SSH and service ports for uninterrupted access
  • Combine with tmux for fast region switching

Summary

NordVPN CLI is constraint‑based, not server‑list‑based.

You choose what you want (country, city, purpose). NordVPN chooses how it’s delivered (server, IP, routing).

This model scales better, performs better, and is ideal for automation.


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