FreeRADIUSを利用したVPN接続
概要
前々回の記事にてRADIUSはネットワークアクセスを制御するための認証プロトコルとして利用されることが多いと記載いたしましたが、今回は実際に、FreeRADIUSの認証機能を利用してVPN接続を行ってみたいと思います。
OpenVPN
ではまずOSSのVPNとして広く利用されているOpenVPNの構築を行っていきます。
尚、今回は以下のような形になるように構築していきます。
IPアドレス | 用途 |
10.15.1.15 | OpenVPNサーバ |
10.15.1.1 | OpenVPNクライアント |
10.8.0.0/24 | OpenVPNにてルーティングするアドレス |
インストール
OpenVPNのパッケージはEPELリポジトリからインストール可能です。必要に応じて有効化を行ってください。
# dnf install openvpn
メタデータの期限切れの最終確認: 0:08:48 前の 2025年08月05日 14時23分07秒 に実施しました。
依存関係が解決しました。
================================================================================
パッケージ Arch バージョン リポジトリー サイズ
================================================================================
インストール:
openvpn x86_64 2.5.11-1.el9 epel 655 k
依存関係のインストール:
pkcs11-helper x86_64 1.27.0-6.el9 epel 62 k
トランザクションの概要
================================================================================
インストール 2 パッケージ
ダウンロードサイズの合計: 717 k
インストール後のサイズ: 1.9 M
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
[=== ] --- B/s | 0 B --:-- ETA(1/2): openvpn-2.5.1 0% [ ] --- B/s | 0 B --:-- ETA(1/2): pkcs11-helper-1.27.0-6.el9.x86_64.rpm 948 kB/s | 62 kB 00:00
(2/2): openvpn-2.5.1 13% [==- ] 1.5 MB/s | 100 kB 00:00 ETA(2/2): openvpn-2.5.11-1.el9.x86_64.rpm 3.6 MB/s | 655 kB 00:00
--------------------------------------------------------------------------------
合計 1.5 MB/s | 717 kB 00:00
トランザクションを確認しています
トランザクションの確認に成功しました。
トランザクションをテストしています
トランザクションのテストに成功しました。
トランザクションを実行しています
準備中 : [========================= ] 1/1 準備中 : 1/1
インストール中 : pkcs11-helper-1.27.0-6.el [ ] 1/2 インストール中 : pkcs11-helper-1.27.0-6.el [===== ] 1/2 インストール中 : pkcs11-helper-1.27.0-6.el [========== ] 1/2 インストール中 : pkcs11-helper-1.27.0-6.el [=============== ] 1/2 インストール中 : pkcs11-helper-1.27.0-6.el [==================== ] 1/2 インストール中 : pkcs11-helper-1.27.0-6.el [===================== ] 1/2 インストール中 : pkcs11-helper-1.27.0-6.el [====================== ] 1/2 インストール中 : pkcs11-helper-1.27.0-6.el [========================= ] 1/2 インストール中 : pkcs11-helper-1.27.0-6.el9.x86_64 1/2
scriptletの実行中: openvpn-2.5.11-1.el9.x86_64 2/2
インストール中 : openvpn-2.5.11-1.el9.x86_ [ ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [= ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [=== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [==== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [===== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [====== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [======= ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [======== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [========= ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [========== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [=========== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [============ ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [============= ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [============== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [=============== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [================ ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [================= ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [================== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [=================== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [==================== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [===================== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [====================== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [======================= ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [======================== ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_ [========================= ] 2/2 インストール中 : openvpn-2.5.11-1.el9.x86_64 2/2
scriptletの実行中: openvpn-2.5.11-1.el9.x86_64 2/2
/usr/lib/tmpfiles.d/radiusd.conf:1: Line references path below legacy directory /var/run/, updating /var/run/radiusd → /run/radiusd; please update the tmpfiles.d/ drop-in file accordingly.
検証中 : openvpn-2.5.11-1.el9.x86_64 1/2
検証中 : pkcs11-helper-1.27.0-6.el9.x86_64 2/2
インストール済み:
openvpn-2.5.11-1.el9.x86_64 pkcs11-helper-1.27.0-6.el9.x86_64
完了しました!
また、OpenVPNの認証で利用する秘密鍵などへの署名のためEasy-RSAも必要となります。もともとはOpenVPNに含まれていたこともあったようですが、現在は含まれておりませんので、別途インストールが必要です。
尚、こちらもEPELリポジトリからインストール可能です。
# dnf install easy-rsa
メタデータの期限切れの最終確認: 0:12:53 前の 2025年08月05日 14時23分07秒 に実施しました。
依存関係が解決しました。
================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
================================================================================
インストール:
easy-rsa noarch 3.2.1-2.el9 epel 66 k
トランザクションの概要
================================================================================
インストール 1 パッケージ
ダウンロードサイズの合計: 66 k
インストール後のサイズ: 216 k
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
[=== ] --- B/s | 0 B --:-- ETA [=== ] --- B/s | 0 B --:-- ETA [ === ] --- B/s | 0 B --:-- ETAeasy-rsa-3.2.1-2.el9 0% [ ] --- B/s | 0 B --:-- ETAeasy-rsa-3.2.1-2.el9.noarch.rpm 611 kB/s | 66 kB 00:00
--------------------------------------------------------------------------------
合計 87 kB/s | 66 kB 00:00
トランザクションを確認しています
トランザクションの確認に成功しました。
トランザクションをテストしています
トランザクションのテストに成功しました。
トランザクションを実行しています
準備中 : 1/1
インストール中 : easy-rsa-3.2.1-2.el9.noar [ ] 1/1 インストール中 : easy-rsa-3.2.1-2.el9.noar [== ] 1/1 インストール中 : easy-rsa-3.2.1-2.el9.noar [=== ] 1/1 インストール中 : easy-rsa-3.2.1-2.el9.noar [==== ] 1/1 インストール中 : easy-rsa-3.2.1-2.el9.noar [======= ] 1/1 インストール中 : easy-rsa-3.2.1-2.el9.noar [=========== ] 1/1 インストール中 : easy-rsa-3.2.1-2.el9.noar [=============== ] 1/1 インストール中 : easy-rsa-3.2.1-2.el9.noar [=================== ] 1/1 インストール中 : easy-rsa-3.2.1-2.el9.noar [====================== ] 1/1 インストール中 : easy-rsa-3.2.1-2.el9.noar [======================= ] 1/1 インストール中 : easy-rsa-3.2.1-2.el9.noar [========================= ] 1/1 インストール中 : easy-rsa-3.2.1-2.el9.noarch 1/1
検証中 : easy-rsa-3.2.1-2.el9.noarch 1/1
インストール済み:
easy-rsa-3.2.1-2.el9.noarch
完了しました!
認証局(CA)の設置とOpenVPN用の証明書と鍵の生成
OpenVPNはサーバとクライアント双方に証明書及び秘密鍵が必要となりますのでそれらを作成していきます。
まずは各証明書へと署名を行う認証局(CA)の証明書と秘密鍵を生成します。
# cp -rp /usr/share/easy-rsa/3.2.1/usr/share/easy-rsa/3.2.1 /etc/opendkimvpn/easy-rsa
# cd /etc/openvpn/easy-rsa
# ./easyrsa init-pki
Notice
------
'init-pki' complete; you may now create a CA or requests.
Your newly created PKI dir is:
* /etc/openvpn/easy-rsa/pki
Using Easy-RSA configuration:
* undefined
# ./easyrsa build-ca
Enter New CA Key Passphrase:
Confirm New CA Key Passphrase:
..+...............+..+.+.........++
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Common Name (eg: your user, host, or server name) [Easy-RSA CA]:vpn-test
Notice
------
CA creation complete. Your new CA certificate is at:
* /etc/openvpn/easy-rsa/pki/ca.crt
Create an OpenVPN TLS-AUTH|TLS-CRYPT-V1 key now: See 'help gen-tls'
Build-ca completed successfully.
次にサーバ用の証明書と秘密鍵を生成します。
# ./easyrsa build-server-full server ・・・最後の引数である「server」部分はサーバのホスト名を指定
......+.....+.+.....+..........+...+..+++..+.......+
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
Notice
------
Private-Key and Public-Certificate-Request files created.
Your files are:
* req: /etc/openvpn/easy-rsa/pki/reqs/server.req
* key: /etc/openvpn/easy-rsa/pki/private/server.key
You are about to sign the following certificate:
Requested CN: 'server'
Requested type: 'server'
Valid for: '825' days
subject=
commonName = server
Type the word 'yes' to continue, or any other input to abort.
Confirm requested details: yes ・・・「yes」と入力
Using configuration from /etc/openvpn/easy-rsa/pki/9e26e7f1/temp.6.1
Enter pass phrase for /etc/openvpn/easy-rsa/pki/private/ca.key:
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName :ASN.1 12:'server'
Certificate is to be certified until Nov 8 06:54:23 2027 GMT (825 days)
Write out database with 1 new entries
Database updated
/usr/bin/which: no bc in (/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)
Notice
------
Inline file created:
* /etc/openvpn/easy-rsa/pki/inline/private/server.inline
Notice
------
Certificate created at:
* /etc/openvpn/easy-rsa/pki/issued/server.crt
最後にクライアント用の証明書と秘密鍵を生成します。
# ./easyrsa build-client-full client ・・・最後の引数である「client」部分はサーバのホスト名を指定
...+...............+...+....+..+.+..++++++++++++++++
Verifying - Enter PEM pass phrase:
-----
Notice
------
Private-Key and Public-Certificate-Request files created.
Your files are:
* req: /etc/openvpn/easy-rsa/pki/reqs/client.req
* key: /etc/openvpn/easy-rsa/pki/private/client.key
You are about to sign the following certificate:
Requested CN: 'client'
Requested type: 'client'
Valid for: '825' days
subject=
commonName = client
Type the word 'yes' to continue, or any other input to abort.
Confirm requested details: yes ・・・「yes」と入力
Using configuration from /etc/openvpn/easy-rsa/pki/9d4b802e/temp.6.1
Enter pass phrase for /etc/openvpn/easy-rsa/pki/private/ca.key:
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName :ASN.1 12:'client'
Certificate is to be certified until Nov 8 07:06:38 2027 GMT (825 days)
Write out database with 1 new entries
Database updated
/usr/bin/which: no bc in (/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)
Notice
------
Inline file created:
* /etc/openvpn/easy-rsa/pki/inline/private/client.inline
Notice
------
Certificate created at:
* /etc/openvpn/easy-rsa/pki/issued/client.crt
続いて、OpenVPNサーバ用にDiffie Hellmanパラメータを生成します。
Diffie HellmanパラメータとはDiffie-Hellman鍵共有法という共通鍵暗号方式に使われるパラメータのことで、OpenVPNではデフォルトでこちらを利用する設定となっています。
# ./easyrsa gen-dh
Generating DH parameters, 2048 bit long safe prime
.....................................................................................................................+.............................+...............................................................................................................................................................................................................................................+...........................................................................................+..............+................................+............+...................................................................................................................................................................................................................................................................+......................................................................................................................+........................+.........................+.....................................................................+................+.............................+........................................+...................+..............................................................................................................................................................................................................................................+.............................................................................+............................................................................................................................+..+................................................................................................................................................................+.......................................+.....................................................................................................................................................+................................................................................+....................................................................................................................................................................................................................+.......................+.............................................................................................+......................+.....................+............................................+..........................................................................................................................................................................+...........................................................................................................................................+............................................................................................................................+.................................................+......................................................................................................................................................................................+.....................................................+.............+................................+.....................................................................................................+...........................................+....................................................................................................................................+...........................................................+................................................+..........................+................................................+............................................+......................................+.........................................................................+..........................................+................................................................................................................+...................................................................................................+.........................................................+...........................................................................................................................................................................................................................+...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................+...............+.....................................................................+........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................+.....................................................................................................................................................+...............................................................................................................+.................................................................................................................................................................................................................................................................................................................+.................................................................................................................................................................................................................................................................+................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................+..........................................................................................................................+........................................+...................................................................................................+.........................................................++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*
DH parameters appear to be ok.
Notice
------
DH parameters of size 2048 created at:
* /etc/openvpn/easy-rsa/pki/dh.pem
続いて、HMAC署名用の鍵を生成します。
HMAC:通信相手同士で互いに共通の秘密鍵を利用してハッシュ化を行うことで、送信者の認証と本文の改ざん検知が可能。
# openvpn --genkey secret ta.key
ここまでで各種証明書と鍵の作成が完了しました。
それぞれの用途と保存場所は以下の通りです。これらをそれぞれの適用場所に保存します。
ファイル名 | 作成場所 | 適用場所 | 目的 |
ca.crt | ./pki | サーバ + すべてのクライアント | ルートCAの証明書 |
ca.key | ./pki/private | 署名するPCのみ | ルートCAの鍵 |
server.crt | ./pki/issued | サーバのみ | サーバの証明書 |
server.key | ./pki/private | サーバのみ | サーバの鍵 |
client.crt | ./pki/issued | クライアントのみ | クライアントの署名書 |
client.key | ./pki/private | クライアントのみ | クライアントの鍵 |
dh.pem | ./pki | サーバのみ | Diffie Hellmanパラメータ |
ta.key | . | サーバ + すべてのクライアント | HMAC署名用の鍵 |
設定
サーバの設定
EPELからインストールを行った場合、OpenVPNサーバ用のディレクトリは「/etc/openvpn/server/」となります。
こちらに先ほど作成した証明書と鍵を配置し、サーバの設定ファイルのサンプルをコピーし編集します。設定値は基本的にデフォルトのままでも動作するようになっており、Diffie Hellmanパラメータのみファイル名が異なるため変更しています。
# cd /etc/openvpn/server/
# ls -la
合計 100
drwxr-x--- 2 root openvpn 292 8月 8 15:44 .
drwxr-xr-x 5 root root 50 8月 5 14:38 ..
-rw------- 1 root root 1192 8月 5 14:46 ca.crt
-rw------- 1 root root 1886 8月 5 14:45 ca.key
-rw------- 1 root root 428 8月 5 16:09 dh.pem
-rw------- 1 root root 20 8月 8 15:37 ipp.txt
-rw------- 1 root root 700 8月 8 15:46 openvpn-status.log
-rw-r--r-- 1 root root 10909 8月 6 09:41 server.conf
-rw-r--r-- 1 root root 10784 7月 18 2024 server.conf.org
-rw------- 1 root root 636 8月 5 16:31 ta.key
# cp -p /usr/share/doc/openvpn/sample/sample-config-files/server.conf .
# cp- p server.conf server.conf.org
# vi server.conf
# diff -u server.conf.org server.conf
--- server.conf.org 2024-07-18 21:46:01.000000000 +0900
+++ server.conf 2025-08-06 09:41:57.905135982 +0900
@@ -82,7 +82,7 @@
# Diffie hellman parameters.
# Generate your own with:
# openssl dhparam -out dh2048.pem 2048
-dh dh2048.pem
+dh dh.pem
# Network topology
# Should be subnet (addressing via IP)
@@ -312,4 +312,4 @@
クライアントの設定
EPELからインストールを行った場合、OpenVPNクライアント用のディレクトリは「/etc/openvpn/client/」となります。
サーバと同様に証明書と鍵を配置し、クライアントの設定ファイルのサンプルをコピーし編集します。
# cd /etc/openvpn/client
# ls -la
合計 36
drwxr-x--- 3 root openvpn 147 8月 6 15:53 .
drwxr-xr-x 4 root root 34 2月 3 2025 ..
-rw------- 1 root root 1192 8月 5 14:46 ca.crt
-rw------- 1 root root 4486 8月 5 16:06 client.crt
-rw------- 1 root root 1886 8月 5 16:06 client.key
-rw-r--r-- 1 root root 636 8月 5 16:32 ta.key
# cp -p /usr/share/doc/openvpn/sample/sample-config-files/client.conf ./
# cp -p client.conf client.conf.org
# vi client.conf
# diff -u client.conf.org client.conf
--- client.conf.org 2022-03-17 20:53:04.000000000 +0900
+++ client.conf 2025-08-06 09:42:20.503877399 +0900
@@ -39,7 +39,8 @@
# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
-remote my-server-1 1194
+remote 10.15.1.15 1194 ・・・OpenVPNサーバのIPアドレスとポート番号を指定
;remote my-server-2 1194
認証テスト
それでは設定が完了したので認証のテストを行っていきます。
rpmパッケージにてダウンロードを行っているため、systemctlコマンドでもopenvpnサービスの制御は可能ですが、今回は認証のログを確認する目的でopenvpnコマンドから直接設定ファイルを指定して起動しています。
ではまず、OpenVPNサーバから起動していきます。
# openvpn /etc/openvpn/server/server.conf
2025-08-18 15:31:55 WARNING: --topology net30 support for server configs with IPv4 pools will be removed in a future release. Please migrate to --topology subnet as soon as possible.
2025-08-18 15:31:55 DEPRECATED OPTION: --cipher set to 'AES-256-CBC' but missing in --data-ciphers (AES-256-GCM:AES-128-GCM). Future OpenVPN version will ignore --cipher for cipher negotiations. Add 'AES-256-CBC' to --data-ciphers or change --cipher 'AES-256-CBC' to --data-ciphers-fallback 'AES-256-CBC' to silence this warning.
2025-08-18 15:31:55 OpenVPN 2.5.11 x86_64-redhat-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Jul 18 2024
2025-08-18 15:31:55 library versions: OpenSSL 3.2.2 4 Jun 2024, LZO 2.10
2025-08-18 15:31:55 net_route_v4_best_gw query: dst 0.0.0.0
2025-08-18 15:31:55 net_route_v4_best_gw result: via 10.15.0.254 dev ens192
2025-08-18 15:31:55 Diffie-Hellman initialized with 2048 bit key
Enter Private Key Password: ********
2025-08-18 15:31:58 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
2025-08-18 15:31:58 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
2025-08-18 15:31:58 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
2025-08-18 15:31:58 net_route_v4_best_gw query: dst 0.0.0.0
2025-08-18 15:31:58 net_route_v4_best_gw result: via 10.15.0.254 dev ens192
2025-08-18 15:31:58 ROUTE_GATEWAY 10.15.0.254/255.255.0.0 IFACE=ens192 HWADDR=00:50:56:9d:44:66
2025-08-18 15:31:58 TUN/TAP device tun0 opened
2025-08-18 15:31:58 net_iface_mtu_set: mtu 1500 for tun0
2025-08-18 15:31:58 net_iface_up: set tun0 up
2025-08-18 15:31:58 net_addr_ptp_v4_add: 10.8.0.1 peer 10.8.0.2 dev tun0
2025-08-18 15:31:58 net_route_v4_add: 10.8.0.0/24 via 10.8.0.2 dev [NULL] table 0 metric -1
2025-08-18 15:31:58 Could not determine IPv4/IPv6 protocol. Using AF_INET
2025-08-18 15:31:58 Socket Buffers: R=[212992->212992] S=[212992->212992]
2025-08-18 15:31:58 UDPv4 link local (bound): [AF_INET][undef]:1194
2025-08-18 15:31:58 UDPv4 link remote: [AF_UNSPEC]
2025-08-18 15:31:58 MULTI: multi_init called, r=256 v=256
2025-08-18 15:31:58 IFCONFIG POOL IPv4: base=10.8.0.4 size=62
2025-08-18 15:31:58 ifconfig_pool_read(), in='client,10.8.0.4,'
2025-08-18 15:31:58 succeeded -> ifconfig_pool_set(hand=0)
2025-08-18 15:31:58 IFCONFIG POOL LIST
2025-08-18 15:31:58 client,10.8.0.4,
2025-08-18 15:31:58 Initialization Sequence Completed
「Initialization Sequence Completed」と表示され、OpenVPNサーバが無事起動されました。
では続いてOpenVPNクライアントを起動していきます。
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:50:56:90:4b:a4 brd ff:ff:ff:ff:ff:ff
inet 10.15.1.1/16 brd 10.15.255.255 scope global noprefixroute ens192
valid_lft forever preferred_lft forever
inet6 fe80::7bdf:3b68:8dac:8bd/64 scope link noprefixroute
valid_lft forever preferred_lft forever
# openvpn /etc/openvpn/client/client.conf
Mon Aug 18 16:11:31 2025 WARNING: file 'ta.key' is group or others accessible
Mon Aug 18 16:11:31 2025 OpenVPN 2.4.12 x86_64-redhat-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Nov 10 2023
Mon Aug 18 16:11:31 2025 library versions: OpenSSL 1.1.1g FIPS 21 Apr 2020, LZO 2.08
Enter Private Key Password: ********
Mon Aug 18 16:11:36 2025 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
Mon Aug 18 16:11:36 2025 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Mon Aug 18 16:11:36 2025 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Mon Aug 18 16:11:36 2025 TCP/UDP: Preserving recently used remote address: [AF_INET]10.15.1.15:1194
Mon Aug 18 16:11:36 2025 Socket Buffers: R=[212992->212992] S=[212992->212992]
Mon Aug 18 16:11:36 2025 UDP link local: (not bound)
Mon Aug 18 16:11:36 2025 UDP link remote: [AF_INET]10.15.1.15:1194
Mon Aug 18 16:11:36 2025 TLS: Initial packet from [AF_INET]10.15.1.15:1194, sid=4ce723f9 c3e19cf2
Mon Aug 18 16:11:36 2025 VERIFY OK: depth=1, CN=vpn-test
Mon Aug 18 16:11:36 2025 VERIFY KU OK
Mon Aug 18 16:11:36 2025 Validating certificate extended key usage
Mon Aug 18 16:11:36 2025 ++ Certificate has EKU (str) TLS Web Server Authentication, expects TLS Web Server Authentication
Mon Aug 18 16:11:36 2025 VERIFY EKU OK
Mon Aug 18 16:11:36 2025 VERIFY OK: depth=0, CN=server
Mon Aug 18 16:11:36 2025 Control Channel: TLSv1.3, cipher TLSv1.3 TLS_AES_256_GCM_SHA384, 2048 bit RSA
Mon Aug 18 16:11:36 2025 [server] Peer Connection Initiated with [AF_INET]10.15.1.15:1194
Mon Aug 18 16:11:37 2025 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
Mon Aug 18 16:11:37 2025 PUSH: Received control message: 'PUSH_REPLY,route 10.8.0.1,topology net30,ping 10,ping-restart 120,ifconfig 10.8.0.6 10.8.0.5,peer-id 0,cipher AES-256-GCM'
Mon Aug 18 16:11:37 2025 OPTIONS IMPORT: timers and/or timeouts modified
Mon Aug 18 16:11:37 2025 OPTIONS IMPORT: --ifconfig/up options modified
Mon Aug 18 16:11:37 2025 OPTIONS IMPORT: route options modified
Mon Aug 18 16:11:37 2025 OPTIONS IMPORT: peer-id set
Mon Aug 18 16:11:37 2025 OPTIONS IMPORT: adjusting link_mtu to 1624
Mon Aug 18 16:11:37 2025 OPTIONS IMPORT: data channel crypto options modified
Mon Aug 18 16:11:37 2025 Data Channel: using negotiated cipher 'AES-256-GCM'
Mon Aug 18 16:11:37 2025 Outgoing Data Channel: Cipher 'AES-256-GCM' initialized with 256 bit key
Mon Aug 18 16:11:37 2025 Incoming Data Channel: Cipher 'AES-256-GCM' initialized with 256 bit key
Mon Aug 18 16:11:37 2025 ROUTE_GATEWAY 10.15.0.254/255.255.0.0 IFACE=ens192 HWADDR=00:50:56:90:4b:a4
Mon Aug 18 16:11:37 2025 TUN/TAP device tun0 opened
Mon Aug 18 16:11:37 2025 TUN/TAP TX queue length set to 100
Mon Aug 18 16:11:37 2025 /sbin/ip link set dev tun0 up mtu 1500
Mon Aug 18 16:11:37 2025 /sbin/ip addr add dev tun0 local 10.8.0.6 peer 10.8.0.5
Mon Aug 18 16:11:37 2025 /sbin/ip route add 10.8.0.1/32 via 10.8.0.5
Mon Aug 18 16:11:37 2025 Initialization Sequence Completed
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:50:56:90:4b:a4 brd ff:ff:ff:ff:ff:ff
inet 10.15.1.1/16 brd 10.15.255.255 scope global noprefixroute ens192
valid_lft forever preferred_lft forever
inet6 fe80::7bdf:3b68:8dac:8bd/64 scope link noprefixroute
valid_lft forever preferred_lft forever
9: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100
link/none
inet 10.8.0.6 peer 10.8.0.5/32 scope global tun0
valid_lft forever preferred_lft foreve
サーバと同様に「Initialization Sequence Completed」と表示され、無事OpenVPNクライアントが起動したことが確認できました。
また、手順内でも確認しているようにOpenVPNクライアントの起動後に10.8.0.0/24がルーティングされていることがわかります。
FreeRADIUSとOpenVPNの連携設定
ここまででOpenVPN単体での設定が完了したので、次にFreeRADIUSと連携する設定を行っていきます。
今回は、コミュニティのドキュメントで紹介されているサードパーティ製のプラグインを利用して連携の設定を行います。
サーバの設定
まずは、上記サイトに記載のRADIUS用のプラグインのインストールを行います。
尚、今回はコチラのプラグインを利用しているため、別途コンパイルインストール用に「開発ツール」のgroup installや、「libgcrypt devel」パッケージなどが必要となりますので別途インストールを行ってください。
# curl -LO https://github.com/ValdikSS/openvpn-radiusplugin/archive/refs/tags/v2.2.tar.gzhttps://github.com/ValdikSS/openvpn-radiusplugin/archive/refs/tags/v2.2.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 229k 0 229k 0 0 228k 0 --:--:-- 0:00:01 --:--:-- 228k
# tar -zxf v2.2.tar.gz
# cd openvpn-radiusplugin-2.2/
# ls
AccountingProcess.cpp Exception.cpp ToDo doxygen.conf
AccountingProcess.h Exception.h User.cpp main.cpp
AcctScheduler.cpp IpcSocket.cpp User.h openvpn-plugin.h
AcctScheduler.h IpcSocket.h UserAcct.cpp radiusplugin.cnf
AuthenticationProcess.cpp Makefile UserAcct.h radiusplugin.cpp
AuthenticationProcess.h Makefile.bsd UserAuth.cpp radiusplugin.h
COPYING PluginContext.cpp UserAuth.h vsascript.pl
ChangeLog PluginContext.h UserPlugin.cpp
Config.cpp README UserPlugin.h
Config.h RadiusClass clean.sh
# make
# ls
AccountingProcess.cpp Config.o RadiusClass UserPlugin.o
AccountingProcess.h Exception.cpp ToDo clean.sh
AccountingProcess.o Exception.h User.cpp doxygen.conf
AcctScheduler.cpp Exception.o User.h main.cpp
AcctScheduler.h IpcSocket.cpp User.o main.o
AcctScheduler.o IpcSocket.h UserAcct.cpp openvpn-plugin.h
AuthenticationProcess.cpp IpcSocket.o UserAcct.h radiusplugin.cnf
AuthenticationProcess.h Makefile UserAcct.o radiusplugin.cpp
AuthenticationProcess.o Makefile.bsd UserAuth.cpp radiusplugin.h
COPYING PluginContext.cpp UserAuth.h radiusplugin.o
ChangeLog PluginContext.h UserAuth.o radiusplugin.so
Config.cpp PluginContext.o UserPlugin.cpp vsascript.pl
Config.h README UserPlugin.h
プラグインのインストールが完了しましたので、必要なファイルである「raidiusplugin.so」と「radiusplugin.cnf」をそれぞれ適切な場所に移動します。
また、「radiusplugin.cnf」については接続するRADIUSサーバに沿った形で設定の変更も行います。(基本的にはIPアドレスとRADIUSクライアントのパスワードを変更するのみです。)
# cp -p raidiusplugin.so /usr/lib64/openvpn/plugins/
# ls /usr/lib634/openvpn/plugins/
openvpn-plugin-auth-pam.so openvpn-plugin-down-root.so radiusplugin.so
# cp -p radiusplugin.cnf /etc/openvpn/server/
# cd /etc/openvpn/server/
# cp -p radiusplugin.cnf radiusplugin.cnf.org
# vi radiusplugin.cnf
# diff -u /etc/openvpn/server/radiusplugin.cnf.org /etc/openvpn/server/radiusplugin.cnf
--- /etc/openvpn/server/radiusplugin.cnf.org 2015-11-23 17:11:20.000000000 +0900
+++ /etc/openvpn/server/radiusplugin.cnf 2025-08-06 09:41:13.391134157 +0900
@@ -19,7 +19,7 @@
# client-cert-not-required (if the option is used or not)
# username-as-common-name (if the option is used or not)
-OpenVPNConfig=/etc/openvpn/server.conf
+OpenVPNConfig=/etc/openvpn/server/server.conf
# Support for topology option in OpenVPN 2.1
@@ -90,13 +90,13 @@
# The UDP port for radius authentication.
authport=1812
# The name or ip address of the radius server.
- name=192.168.0.153
+ name=127.0.0.1
# How many times should the plugin send the if there is no response?
retry=1
# How long should the plugin wait for a response?
wait=1
# The shared secret.
- sharedsecret=testpw
+ sharedsecret=testing123
}
ファイルの移動が完了したら、OpenVPNサーバの設定ファイルにもプラグインの情報を記載します。
# vi /etc/openvpn/server/server.conf
# tail -n 1 /etc/openvpn/server/server.conf
plugin /usr/lib64/openvpn/plugins/radiusplugin.so /etc/openvpn/server/radiusplugin.cnf
クライアントの設定
次にクライアントの設定ですが、OpenVPNクライアントの設定ファイルに「auth-user-pass」を追加すれば完了です。
# vi /etc/openvpn/client/client.conf
# tail -n 1 client.conf
auth-user-pass
認証テスト
ではRADIUSの情報を使ってOpenVPNで認証が可能かどうかテストを行っていきます。
今回も先ほどと同様にopenvpnコマンドにてOpenVPNサーバから起動していきます。
# openvpn server.conf
2025-08-18 16:57:26 WARNING: --topology net30 support for server configs with IPv4 pools will be removed in a future release. Please migrate to --topology subnet as soon as possible.
2025-08-18 16:57:26 DEPRECATED OPTION: --cipher set to 'AES-256-CBC' but missing in --data-ciphers (AES-256-GCM:AES-128-GCM). Future OpenVPN version will ignore --cipher for cipher negotiations. Add 'AES-256-CBC' to --data-ciphers or change --cipher 'AES-256-CBC' to --data-ciphers-fallback 'AES-256-CBC' to silence this warning.
2025-08-18 16:57:26 OpenVPN 2.5.11 x86_64-redhat-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Jul 18 2024
2025-08-18 16:57:26 library versions: OpenSSL 3.2.2 4 Jun 2024, LZO 2.10
2025-08-18 16:57:26 net_route_v4_best_gw query: dst 0.0.0.0
2025-08-18 16:57:26 net_route_v4_best_gw result: via 10.15.0.254 dev ens192
Mon Aug 18 16:57:26 2025 RADIUS-PLUGIN: Configfile name: /etc/openvpn/server/radiusplugin.cnf.
2025-08-18 16:57:26 PLUGIN_INIT: POST /usr/lib64/openvpn/plugins/radiusplugin.so '[/usr/lib64/openvpn/plugins/radiusplugin.so] [/etc/openvpn/server/radiusplugin.cnf]' intercepted=PLUGIN_AUTH_USER_PASS_VERIFY|PLUGIN_CLIENT_CONNECT|PLUGIN_CLIENT_DISCONNECT
2025-08-18 16:57:26 Diffie-Hellman initialized with 2048 bit key
Enter Private Key Password: ********
2025-08-18 16:57:28 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
2025-08-18 16:57:28 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
2025-08-18 16:57:28 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
2025-08-18 16:57:28 net_route_v4_best_gw query: dst 0.0.0.0
2025-08-18 16:57:28 net_route_v4_best_gw result: via 10.15.0.254 dev ens192
2025-08-18 16:57:28 ROUTE_GATEWAY 10.15.0.254/255.255.0.0 IFACE=ens192 HWADDR=00:50:56:9d:44:66
2025-08-18 16:57:28 TUN/TAP device tun0 opened
2025-08-18 16:57:28 net_iface_mtu_set: mtu 1500 for tun0
2025-08-18 16:57:28 net_iface_up: set tun0 up
2025-08-18 16:57:28 net_addr_ptp_v4_add: 10.8.0.1 peer 10.8.0.2 dev tun0
2025-08-18 16:57:28 net_route_v4_add: 10.8.0.0/24 via 10.8.0.2 dev [NULL] table 0 metric -1
2025-08-18 16:57:28 Could not determine IPv4/IPv6 protocol. Using AF_INET
2025-08-18 16:57:28 Socket Buffers: R=[212992->212992] S=[212992->212992]
2025-08-18 16:57:28 UDPv4 link local (bound): [AF_INET][undef]:1194
2025-08-18 16:57:28 UDPv4 link remote: [AF_UNSPEC]
2025-08-18 16:57:28 MULTI: multi_init called, r=256 v=256
2025-08-18 16:57:28 IFCONFIG POOL IPv4: base=10.8.0.4 size=62
2025-08-18 16:57:28 ifconfig_pool_read(), in='client,10.8.0.4,'
2025-08-18 16:57:28 succeeded -> ifconfig_pool_set(hand=0)
2025-08-18 16:57:28 IFCONFIG POOL LIST
2025-08-18 16:57:28 client,10.8.0.4,
2025-08-18 16:57:28 Initialization Sequence Completed
「Initialization Sequence Completed」と表示された上、ログに「RADIUS-PLUGIN: Configfile name: /etc/openvpn/server/radiusplugin.cnf」などの出力あることから、プラグインがきちんと認識された上で起動に成功していることがわかります。
では続いてOpenVPNクライアントの起動も行っていきます。
# openvpn client.conf
Mon Aug 18 17:04:20 2025 WARNING: file 'ta.key' is group or others accessible
Mon Aug 18 17:04:20 2025 OpenVPN 2.4.12 x86_64-redhat-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Nov 10 2023
Mon Aug 18 17:04:20 2025 library versions: OpenSSL 1.1.1g FIPS 21 Apr 2020, LZO 2.08
Enter Auth Username: test-user01
Enter Auth Password: ********
Enter Private Key Password: ********
Mon Aug 18 17:04:29 2025 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
Mon Aug 18 17:04:29 2025 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Mon Aug 18 17:04:29 2025 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Mon Aug 18 17:04:29 2025 TCP/UDP: Preserving recently used remote address: [AF_INET]10.15.1.15:1194
Mon Aug 18 17:04:29 2025 Socket Buffers: R=[212992->212992] S=[212992->212992]
Mon Aug 18 17:04:29 2025 UDP link local: (not bound)
Mon Aug 18 17:04:29 2025 UDP link remote: [AF_INET]10.15.1.15:1194
Mon Aug 18 17:04:29 2025 TLS: Initial packet from [AF_INET]10.15.1.15:1194, sid=6ddf3dd8 7d2d9009
Mon Aug 18 17:04:29 2025 VERIFY OK: depth=1, CN=vpn-test
Mon Aug 18 17:04:29 2025 VERIFY KU OK
Mon Aug 18 17:04:29 2025 Validating certificate extended key usage
Mon Aug 18 17:04:29 2025 ++ Certificate has EKU (str) TLS Web Server Authentication, expects TLS Web Server Authentication
Mon Aug 18 17:04:29 2025 VERIFY EKU OK
Mon Aug 18 17:04:29 2025 VERIFY OK: depth=0, CN=server
Mon Aug 18 17:04:29 2025 Control Channel: TLSv1.3, cipher TLSv1.3 TLS_AES_256_GCM_SHA384, 2048 bit RSA
Mon Aug 18 17:04:29 2025 [server] Peer Connection Initiated with [AF_INET]10.15.1.15:1194
Mon Aug 18 17:04:30 2025 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
Mon Aug 18 17:04:30 2025 PUSH: Received control message: 'PUSH_REPLY,route 10.8.0.1,topology net30,ping 10,ping-restart 120,ifconfig 10.8.0.6 10.8.0.5,peer-id 0,cipher AES-256-GCM'
Mon Aug 18 17:04:30 2025 OPTIONS IMPORT: timers and/or timeouts modified
Mon Aug 18 17:04:30 2025 OPTIONS IMPORT: --ifconfig/up options modified
Mon Aug 18 17:04:30 2025 OPTIONS IMPORT: route options modified
Mon Aug 18 17:04:30 2025 OPTIONS IMPORT: peer-id set
Mon Aug 18 17:04:30 2025 OPTIONS IMPORT: adjusting link_mtu to 1624
Mon Aug 18 17:04:30 2025 OPTIONS IMPORT: data channel crypto options modified
Mon Aug 18 17:04:30 2025 Data Channel: using negotiated cipher 'AES-256-GCM'
Mon Aug 18 17:04:30 2025 Outgoing Data Channel: Cipher 'AES-256-GCM' initialized with 256 bit key
Mon Aug 18 17:04:30 2025 Incoming Data Channel: Cipher 'AES-256-GCM' initialized with 256 bit key
Mon Aug 18 17:04:30 2025 ROUTE_GATEWAY 10.15.0.254/255.255.0.0 IFACE=ens192 HWADDR=00:50:56:90:4b:a4
Mon Aug 18 17:04:30 2025 TUN/TAP device tun0 opened
Mon Aug 18 17:04:30 2025 TUN/TAP TX queue length set to 100
Mon Aug 18 17:04:30 2025 /sbin/ip link set dev tun0 up mtu 1500
Mon Aug 18 17:04:30 2025 /sbin/ip addr add dev tun0 local 10.8.0.6 peer 10.8.0.5
Mon Aug 18 17:04:30 2025 /sbin/ip route add 10.8.0.1/32 via 10.8.0.5
Mon Aug 18 17:04:30 2025 Initialization Sequence Completed
「Initialization Sequence Completed」と表示されたため、ユーザ名とパスワードの項目にてFreeRADIUSが連携しているLDAPのユーザ情報を入力することで無事OpenVPNクライアントが接続できることがわかりました。
まとめ
今回はあくまでFreeRADIUSにVPNを連携させることが目的だったため、OpenVPNについては軽く触れる程度で終わりましたが、FreeRADIUSが実際にネットワークの認証で利用されるということが少しでもイメージできれたのであれば幸いです。
お問い合わせ
弊社では様々なサービスを取り扱っております。
詳細はサービス一覧からご覧ください。
お気軽にお問い合わせください。応対時間 9:30-17:30 [ 土・日・祝日除く ]
お問い合わせ