OpenVPN Access Serverの認証をADで行う

2024.05.02

AWS環境において、OpenVPN Access Serverの認証をActive Directoryで行う方法を紹介します。

OpenVPN Access Serverとは

OpenVPN Access Serverは、EC2として動作するリモートアクセスソリューションです。 Webベースのインタフェースを使いながら、OpenVPNプロトコルを使った接続が可能です。 同時接続数の課金であり、2ユーザーまでは無料で利用できます。

AWSのマネージドなOpenVPNプロトコルサービスとしてAWS Client VPNがありますが、執筆時点ではAWS Client VPNには1接続ごとに10Mbpsの帯域制限があります。今回は10Mbps以上の帯域が必要な場合の選択肢として、OpenVPN Access Serverを試します。引用元

There is also a 10 Mbps bandwidth limit per user connection.

OpenVPN Access Serverの起動

AWS Marketplaceから起動します。

起動後、EIPを割り当てます。

初期設定

セッションマネージャーで接続後、sudo su -コマンドを実行すると、初期セットアップがはじまります。 最初の質問はライセンス条項に同意するかという内容です。問題なければyesで進みます。

Please enter 'yes' to indicate your agreement [no]: yes

1台構成のため、デフォルト値のyesで進みます。

Will this be the primary Access Server node?
(enter 'no' to configure as a backup or standby node)
> Press ENTER for default [yes]:

管理Web UIに利用するネットワークインタフェースを指定します。 デフォルト値のプライマリーノードですすめます。

Please specify the network interface and IP address to be
used by the Admin Web UI:
(1) all interfaces: 0.0.0.0
(2) eth0: 10.0.19.27
Please enter the option number from the list above (1- 2).
> Press Enter for default [1]:

OpenVPN CAで使うアルゴリズムを指定します。デフォルト値で進みます。

What public/private type/algorithms do you want to use for the OpenVPN CA?

Recommended choices:

rsa       - maximum compatibility
secp384r1 - elliptic curve, higher security than rsa, allows faster connection setup and smaller user profile files
showall   - shows all options including non-recommended algorithms.
> Press ENTER for default [secp384r1]:

自己証明書もデフォルト値とします。

What public/private type/algorithms do you want to use for the self-signed web certificate?

Recommended choices:

rsa       - maximum compatibility
secp384r1 - elliptic curve, higher security than rsa, allows faster connection setup and smaller user profile files
showall   - shows all options including non-recommended algorithms.
> Press ENTER for default [secp384r1]:

管理画面に使うポートは943です。 変更しないですすめます。

Please specify the port number for the Admin Web UI.
> Press ENTER for default [943]:

OpenVPNデーモンのポートも指定できます。

Please specify the TCP port number for the OpenVPN Daemon
> Press ENTER for default [443]:

すべての通信についてVPNを通すか設定します。 noの場合、指定したネットワークのみがVPNを通ります。 手元のPCでVPN接続し、EC2に接続するようなケースではnoを選択します。

Should client traffic be routed by default through the VPN?
> Press ENTER for default [no]:

DNSトラフィックをVPNを通すか指定します。今回はnoとしました。

Should client DNS traffic be routed by default through the VPN?
> Press ENTER for default [no]:

yesを選択し、プライベートサブネットにはVPN接続を通して接続するよう指定します。

Private subnets detected: ['10.0.0.0/16']

Should private subnets be accessible to clients by default?
> Press ENTER for EC2 default [yes]:

管理画面で使うユーザーはopenvpnです。 パスワードを指定しないとランダムな値で生成してくれます。

Do you wish to login to the Admin UI as "openvpn"?
> Press ENTER for default [yes]:
Type a password for the 'openvpn' account (if left blank, a random password will be generated):
Please, remember this password ******

アクティベーションキーは入力せずにすすみます。

> Please specify your Activation key (or leave blank to specify later):

セットアップが終わると、Web UIのリンクが表示されます。

During normal operation, OpenVPN AS can be accessed via these URLs:
Admin  UI: https://EIP:943/admin
Client UI: https://EIP:943/
To login please use the "openvpn" account with "*********" password.

今回は、タイムゾーンをJSTにしました。

sudo dpkg-reconfigure tzdata

OSのアップデートを適用します。

sudo apt-get update && sudo apt-get upgrade

Active Directoryへのユーザー追加

Active Directory ユーザーとコンピューターから、バインド用のユーザーを追加します。

  • ユーザー名:OpenVPNBind
  • パスワードを無期限にするにのみチェック

コマンドを実行し、DistinguishedNameを確認します。 「DistinguishedName : CN=OpenVPNBind,CN=Users,DC=koki,DC=com」といった形で確認できます。

Get-ADUser -Identity OpenVPNBind

ドメインコントローラーのセキュリティグループのインバウンドルールで、OpenVPN Access Serverからのtcp:389を許可します。

Open VPN Access Serverでの設定

Webブラウザでhttps://EIP:943/adminに接続し、管理ログイン画面を表示します。 openvpnユーザーでログインします。 Authentication>LDAPを開きます。以下の内容を変更します。

  • Enable LDAP authentication: Yes
  • Re-verify autologin user on connect: No
  • Primary server: ドメインコントローラーのプライベートIP
  • Use these credentials: Yes
  • Bind DN: CN=OpenVPNBind,CN=Users,DC=koki,DC=com ※バインド用ユーザーを指定
  • Base DN for User Entries: CN=Users,DC=koki,DC=com

Save Settingし、Update Running Serverで反映します。 Authentication>Settingsから、LDAPを指定します。

クライアントからの接続

https://EIP:943/ に接続すると、ユーザーのログイン画面が表示されます。

ログインすると、プラットフォーム別のクライアントと、Yourself (user-locked profile)からは接続のための設定ファイルのダウンロードができます。

一般的なインストーラーです。

インストールしたクライアントを起動し、設定ファイルをインポートします。

インポートしたら、パスワードを入力することで以下のようにVPN接続できます。

管理コンソールからは接続中のユーザを確認できます。

一度ログインしたユーザーについては、User Permissionsに表示されアクセス先のネットワークを指定できます。

帯域のテスト

Windows EC2でiperf3を起動します。

参考値ですが、37Mbps程度の実測値でした。

% iperf3 -c 10.0.14.54
Connecting to host 10.0.14.54, port 5201
[  5] local 172.27.232.2 port 57676 connected to 10.0.14.54 port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  4.38 MBytes  36.7 Mbits/sec
[  5]   1.00-2.00   sec  4.50 MBytes  37.7 Mbits/sec
[  5]   2.00-3.00   sec  3.12 MBytes  26.3 Mbits/sec
[  5]   3.00-4.01   sec  1.75 MBytes  14.6 Mbits/sec
[  5]   4.01-5.01   sec  4.38 MBytes  36.7 Mbits/sec
[  5]   5.01-6.00   sec  4.50 MBytes  37.9 Mbits/sec
[  5]   6.00-7.00   sec  4.00 MBytes  33.6 Mbits/sec
[  5]   7.00-8.00   sec  3.88 MBytes  32.4 Mbits/sec
[  5]   8.00-9.01   sec  3.12 MBytes  26.2 Mbits/sec
[  5]   9.01-10.00  sec  3.62 MBytes  30.4 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-10.00  sec  37.2 MBytes  31.2 Mbits/sec                  sender
[  5]   0.00-10.03  sec  37.1 MBytes  31.0 Mbits/sec                  receiver

iperf Done.

最後に

EC2として、OpenVPN Access Serverを起動し、VPN接続してみました。 ドメインコントローラーにバインドユーザーを作成し、ユーザー名とパスワードをサーバーに登録しておくことで、ADユーザーで認証できました。