NordVPN
NordVPN 是一家个人虚拟专用网络服务提供商。NordVPN 总部位于巴拿马。该国没有强制性数据保留法,也不参与 Five Eyes 或 Fourteen Eyes 联盟。在 Linux 上,NordVPN 通过命令行工具运行。
创建账户
要使用 NordVPN,您必须在 NordVPN 官方网站上创建自己的帐户。 https://nordvpn.com
有不同的付款选项可供选择。
安装
NordVPN 服务和 CLI 可以从源文件使用软件包 nordvpnAUR 安装。如果需要 GUI,可以选择安装 nordvpn-guiAUR。
您的用户需要属于 nordvpn 用户组,正如 .install 文件所提醒您的那样。
systemd 服务
要使用 NordVPN,您必须 启动 nordvpnd.service 系统单元。您也可以 启用 它,使其在启动时可用。
配置
以下是一些使用 NordVPN 的常用命令
登录/注销
$ nordvpn login
登录到您的 NordVPN 帐户。
$ nordvpn login --callback "nordvpnlink"
有关注释,请参阅 nordvpn-bin AUR
或者,通过从您的帐户仪表板生成的访问令牌登录,如下所示: NordVPN 仪表板
$ nordvpn login --token "tokencode"
$ nordvpn logout
从您的 NordVPN 帐户中注销。
启用 NordLynx (WireGuard)
NordVPN 已经 引入 了 NordLynx 技术,该技术基于 WireGuard 协议。与默认的 OpenVPN 技术相比,WireGuard 提供了更低的延迟、更高的速度和更好的连接稳定性。由于 WireGuard 用户标识的性质,NordVPN 引入了 NordLynx,它在 WireGuard 之上实现了一个双 NAT 协议,以增强隐私保护。
使用以下命令启用它
$ nordvpn set technology nordlynx
查看所有可用技术
$ nordvpn set technology --help
连接到 VPN
连接到 VPN。
$ nordvpn connect [[country]/[server]/[country_code]/[city] or [country] [city]]
Provide a [country] argument to automatically connect to a specific country. For example: 'nordvpn set autoconnect on Australia' Provide a [country_code] argument to automatically connect to a specific country. For example: 'nordvpn set autoconnect on us' Provide a [city] argument to automatically connect to a specific city. For example: 'nordvpn set autoconnect on Budapest'
断开与 VPN 的连接。
$ nordvpn disconnect
显示连接状态。
$ nordvpn status
设置
设置协议。
$ nordvpn set protocol [protocol]
Supported values for [protocol]: TCP, UDP Example: nordvpn set protocol TCP
启用或禁用 Kill Switch。此安全功能可在 VPN 服务器连接丢失时阻止您的设备访问 VPN 隧道外的互联网。如果您发现断开 VPN 连接后连接无法正常工作,这可能是由于 Kill Switch 功能存在 bug,您需要禁用它。
$ nordvpn set killswitch [enabled]/[disabled]
Supported values for [disabled]: 0, false, disable, off, disabled Example: nordvpn set killswitch off Supported values for [enabled]: 1, true, enable, on, enabled Example: nordvpn set killswitch on
启用或禁用威胁防护 Lite(以前称为 CyberSec)。启用后,威胁防护 Lite 功能将自动阻止可疑网站,以防止恶意软件或其他网络威胁感染您的设备。此外,您将不会看到任何闪烁的广告。有关其工作原理的更多信息: https://nordvpn.com/features/threat-protection/
$ nordvpn set threatprotectionlite [enabled]/[disabled]
Supported values for [disabled]: 0, false, disable, off, disabled Example: nordvpn set threatprotectionlite off Supported values for [enabled]: 1, true, enable, on, enabled Example: nordvpn set threatprotectionlite on
启用或禁用自动连接。启用后,此功能将在操作系统启动时自动尝试连接到 VPN。
$ nordvpn set autoconnect [enabled]/[disabled] [[country]/[server]/[country_code]/[city] or [country] [city]]
Supported values for [disabled]: 0, false, disable, off, disabled Example: nordvpn set autoconnect off Supported values for [enabled]: 1, true, enable, on, enabled Example: nordvpn set autoconnect on Provide a [country] argument to automatically connect to a specific country. For example: 'nordvpn set autoconnect on Australia' Provide a [country_code] argument to automatically connect to a specific country. For example: 'nordvpn set autoconnect on us' Provide a [city] argument to automatically connect to a specific city. For example: 'nordvpn set autoconnect on Budapest'
设置 DNS 服务器。
$ nordvpn set dns [servers]/[disabled]
Supported values for [disabled]: 0, false, disable, off, disabled Example: nordvpn set dns off Arguments [servers] is a list of IP addresses separated by space Example: nordvpn set dns 0.0.0.0 1.2.3.4
将选项添加到白名单或从中移除。
$ nordvpn whitelist command [command options] [arguments...]
Commands:
add Adds option to whitelist
remove Removes option from whitelist
显示当前设置。
$ nordvpn settings
服务器列表
显示国家列表。
$ nordvpn countries
使用此命令显示特定国家的城市。
$ nordvpn cities [country]
Example: nordvpn cities United_States
替代方法:使用 NetworkManager 连接到 NordVPN
安装
1. 安装 networkmanager 和 networkmanager-openvpn。
2. 使用 NordVPN 服务器页面选择合适的服务器: https://nordvpn.com/servers/ 在 NordVPN 网站上下载相应的 OpenVPN 配置文件: https://nordvpn.com/ovpn/ 将文件保存在用户主目录中的某个位置,或者其他易于记住的位置,以便将来访问。
配置
1. 右键单击桌面环境中的 NetworkManager 小程序,然后单击“编辑连接”。在出现的“网络连接”窗口的左下角,单击加号 (+)。
2. 当您选择连接类型时,单击下拉菜单并一直滚动到底部,直到看到“导入已保存的 VPN 配置”。选择该选项。现在,单击“创建”。
3. 导航到您之前解压缩所有 OpenVPN 文件的目录,然后打开该文件夹中的一个文件。一般而言,您会想要打开与您特别想要的连接相关的文件。
4. 打开一个 OpenVPN 文件后,出现的窗口应该是“编辑 <连接类型>”。输入您的 NordVPN 用户名和密码。密码框中有一个图标,指示凭据的用户权限;根据需要更改设置(如果您不想每次连接时都输入密码,请选择“所有用户的保存”)。
避免 DNS 泄露
为防止 DNS 泄露,您必须
1. 单击“IPv4 设置”。
2. 对于方法,选择“自动 (仅 VPN 地址)”并在“DNS 服务器”字段中手动输入 NordVPN DNS 地址“103.86.96.100, 103.86.99.100”(用逗号分隔)。
3. 单击“编辑 <连接类型>”窗口左下角的“保存”。
自动连接到 VPN
1. 右键单击桌面环境中的 NetworkManager 小程序,然后单击“编辑连接”。
2. 双击您希望自动连接到 VPN 的以太网或 Wifi 连接。
3. 在“通用”选项卡上,单击您希望用于所有连接的“使用此连接时自动连接到 VPN”,并选择正确的配置文件。
4. 对您将与 VPN 一起使用的其他连接重复此操作。
禁用 IPv6
NordVPN 不兼容 IPv6。您可能需要 完全禁用它。
您也可以
1. 右键单击桌面环境中的 NetworkManager 小程序,然后单击“编辑连接”。
2. 双击您希望自动连接到 VPN 的以太网或 Wifi 连接。
3. 在“ipv6”选项卡上,在方法框中选择“忽略”。
使用 Kill Switch
NordVPN Kill Switch 在此方法下将不起作用,您必须使用 ufw 或 iptables 自己创建一个。
这是一个 使用 UFW 的示例。
测试您的配置
您可以使用以下网站
故障排除
连接后没有互联网
如果网络阻止了所有 VPN 协议(包括代理连接),则连接尝试可能会失败。尝试更改协议(例如,更改为 TCP)、使用混淆服务器或 NordLynx 协议。
$ nordvpn set technology openvpn $ nordvpn set protocol tcp $ nordvpn set obfuscate on
请注意,安装了此类服务器的国家列表要短得多。
或者,可能与您本地网络的子网冲突,例如
$ ip route default via 10.1.1.1 dev enp0s31f6 proto dhcp metric 100 10.0.0.0/8 dev enp0s31f6 proto kernel scope link src 10.1.2.86 metric 100 10.5.0.0/16 dev nordlynx proto kernel scope link src 10.5.0.2
要解决此问题,请使用例如白名单您的网络的子网。
$ nordvpn whitelist add subnet 10.0.0.0/8
断开连接后没有互联网
通过 nordvpn d 断开连接后,计算机上可能没有互联网,但 ping(例如 ping 8.8.8.8)仍然可以成功。这最可能是一个 DNS 问题:连接到服务器后,本地 DNS 会被 NordVPN 的 DNS 覆盖,以确保与服务器的安全连接。断开连接后,DNS 被移除,这可能导致问题。这可能是由于 Kill Switch 功能存在 bug,因此您可以通过写入来禁用它。
$ nordvpn set killswitch disabled
可能需要重新启动任何正在运行的 网络管理器。
终端连接故障
如果您在终端连接时遇到问题并收到错误,您需要将您的子网列入白名单并在 NordVPN 上打开一个端口。打开终端并检查您的子网。
$ ip route default via 10.1.1.1 dev enp0s31f6 proto dhcp metric 100 10.0.0.0/8 dev enp0s31f6 proto kernel scope link src 10.1.2.86 metric 100 10.5.0.0/16 dev nordlynx proto kernel scope link src 10.5.0.2
第二个子网 (10.0.0.0/8) 是我们想要在 NordVPN 中列入白名单的子网,您可以使用以下命令执行此操作。
$ nordvpn whitelist add subnet 10.0.0.0/8
如果您想再次将子网列入黑名单,只需运行以下命令即可。
$ nordvpn whitelist remove subnet 10.0.0.0/8
端口 22 是 SSH 工作所需的端口,您可以使用以下命令打开它。
$ nordvpn whitelist add port 22
如果您想再次将端口列入黑名单,只需运行以下命令即可。
$ nordvpn whitelist remove port 22
另请参阅 #将 systemd-resolved 设置为 DNS 解析器。
终端随机断开连接
重置 Kill Switch
如果您在终端中随机断开 NordVPN 连接并且无法重新连接,只需禁用然后重新启用 Kill Switch 即可。
$ nordvpn set killswitch off $ nordvpn set killswitch on
大多数情况下,禁用 Kill Switch 将无法连接,NordVPN 的 Linux 应用程序目前存在很多 bug。
重启守护进程
或者,重新启动 nordvpn.service 可以解决连接问题。
由于最近的一次更新,在守护进程重启时 `iptables` 策略不再被刷新。如果重启无法恢复连接,请尝试先使用以下命令刷新这些表。
# iptables -F
将 systemd-resolved 设置为 DNS 解析器
这里需要注意的是,NordVPN for Linux 似乎设计为使用 systemd-resolved,并在使用其他 DNS 解析器时可能崩溃。您可以按照以下步骤切换到 systemd-resolved。
启动/启用 systemd-resolved.service
备份现有的 resolv.conf
# mv /etc/resolv.conf /etc/resolv.conf.bak
创建指向 stub-resolv.conf 的符号链接
# ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
重启 nordvpnd.service
有关更多信息,请参阅原始来源 此处。
安装 wireguard-tools
在使用 NordLynx(NordVPN 的 WireGuard 技术)时,有时连接会断开,即使在使用 systemd-resolved 作为 DNS 解析器的情况下也是如此。这是由于对 wireguard-tools 有一个未提及的依赖关系,应 安装,然后可以 重启 nordvpnd.service。
终端命令执行延迟
在没有正常运行的 通知系统 的桌面系统上,执行 nordvpn disconnect 等终端命令后可能会出现长时间延迟。通过安装和初始化一个通知代理可以解决此问题。