NordVPNで他のすべてを保護しながら、雇用主のVPNを介してリモートで作業する方法は?

NordVPNで他のすべてを保護しながら、雇用主のVPNを介してリモートで作業する方法は?

したがって、目標は簡単です。

  • 雇用主のVPNネットワークでリモートで作業したい。
  • 同時に、NordVPNを介して他のすべてをルーティングしたいと思います。

結局のところ、雇用者でも NordVPN でも、すべてが一部の VPN サービスを受ける必要があります。


しかし、いくつかの要件があります。

  • NordVPN Threat Protectionがオンになっている必要があります(したがってDNS設定はできません)。
  • 手動で変更したくありません。iptables
  • 設定をある程度自動化したいです。

ベストアンサー1

私が見つけたのは、次の初期設定でした。

  1. NordVPNから一時的に切断します。
  2. 包括的な雇用主VPN設定。
  3. キーワードと/デバイスをip route含む行を参照してください。 viatuntap
    • 雇用主のサブネットのリストを抽出します。
  4. nordvpn whitelist add subnet CIDR_NOTATION各サブネットごとに送信してください。
    • すべての個々のアドレスは、サフィックスを含むCIDR表記IPに変換する必要があります。/32
  5. NordVPNに再接続してください。

その後、2つのVPN間で完全に機能するスプリットトンネリングを達成しました。雇用主がプッシュパスを変更しない限り、私は設定について責任を負いません。この場合、初期設定をやり直すと問題が解決します。

一部の雇用主のサブネットはNordVPNと競合する可能性がありますが、私の雇用主はデフォルトで10.0.0.0/8を使用しているため、NordVPNは競合しない他のノードにフェールオーバーしているようです。


これは私に合ったシェルスクリプトです。

#!/bin/bash
set -eo pipefail

function user_can_modify_nordvpn {
    groups | grep -qE "nordvpn|root"
}

echo "First thing to do, is that you need to be disconnected from the NordVPN temporarily."
echo " - the reason is to first establish full connection to your office VPN and fetch all the routes provided by it"
echo " - once we know all the office VPN routes, we will whitelist the involved subnets to NordVPN and start it"
echo " - in that point, both VPNs should work fine - office traffic should be routed through office VPN and everything else through the NordVPN"
echo
read -n 1 -r -p "Now, I need you to prepare for a manual action. I will first disconnect you from NordVPN, so be prepared to spin up your office VPN. Are you ready? (Y/n)"
echo
[[ "$REPLY" =~ ^(Nn)$ ]] && exit 1 || true

if user_can_modify_nordvpn; then
    nordvpn d
else
    sudo nordvpn d
fi

read -n 1 -r -p "NordVPN disconnected. Please spin up your office VPN now. Press any key after you verified successfull connection."

OFFICE_SUBNETS=$(ip route | grep -E "tun|tap" | grep via | awk '{print $1}' | sed 's:^\([^/]\+\)$:\0/32:g' | tee /tmp/office_subnets.txt)

if test "$(echo "$OFFICE_SUBNETS" | wc -l)" -eq 0; then
    echo "ERROR: No 'tun'|'tap' devices found in 'ip route'! So no subnets to add for NordVPN whitelisting." >&2
    exit 1
fi

for subnet in $OFFICE_SUBNETS; do
    if user_can_modify_nordvpn; then
        nordvpn whitelist add subnet "$subnet"
    else
        sudo nordvpn whitelist add subnet "$subnet"
    fi
done

if user_can_modify_nordvpn; then
    nordvpn c
else
    sudo nordvpn c
fi

おすすめ記事