CentOS7 x86_64 環境に OpenVPN を構築しよう♪

2021年11月28日





CentOS7 x86_64 環境に OpenVPN を構築しよう♪

  • 目的
    CentOS7上で、Open VPN を構築し、クライアントの
    Android 端末から接続が出来るようになる。
  • ゴール
    Open VPN を構築できる。
    Android からアクセスし, VPN でネットサーフィンが出来る。
  • 前提条件
    CentOS7をインストール済で、管理者権限で操作出来ること。

1. OpenVPN のインストール

[root@sakuramoti ~]# ls /etc/yum.repos.d | grep epel /*===============================================================*/ epel-testing.repo epel.repo /*===============================================================*/

epel パッケージがインストールされているかの確認を行います。
上記の様に, epel.repo が出力されることを確認します。
もし, 出力されない場合は, yum install epel-release コマンド
で, epel パッケージをインストールして下さい。

yum -y install openvpn easy-rsa --enablerepo=epel

上記コマンドで, openvpneasy-rsa パッケージをインストール
していきます。 east-rsa とは, 簡単認証局作成ツールで自著名証明書
を作成するためのツールとなります。

[root@sakuramoti ~]# rpm -qa | egrep "(openvpn|easy)" /*===============================================================*/ openvpn-2.4.6-1.el7.x86_64 easy-rsa-3.0.3-1.el7.noarch /*===============================================================*/

上記コマンドで先ほどインストールしたパッケージがインストールされているかの
確認を行います。正常にインストールが行われれば上記の様な状態になります。

2. 簡単認証局作成ツール作成スクリプトの設置

[root@sakuramoti ~]# find / -name "easy-rs*" -exec ls -lFR {} ; /*===============================================================*/ /usr/share/doc/easy-rsa-3.0.3: 合計 20 -rw-r--r-- 1 root root 1305 8月 22 2017 COPYING.md -rw-r--r-- 1 root root 2415 9月 3 2015 ChangeLog -rw-r--r-- 1 root root 3350 9月 3 2015 README.quickstart.md -rw-r--r-- 1 root root 8126 9月 3 2015 vars.example /usr/share/licenses/easy-rsa-3.0.3: 合計 20 -rw-r--r-- 1 root root 18093 9月 3 2015 gpl-2.0.txt /usr/share/easy-rsa: 合計 0 lrwxrwxrwx 1 root root 5 12月 18 02:54 3 -> 3.0.3/ lrwxrwxrwx 1 root root 5 12月 18 02:54 3.0 -> 3.0.3/ drwxr-xr-x 3 root root 62 12月 18 02:54 3.0.3/ /usr/share/easy-rsa/3.0.3: 合計 44 -rwxr-xr-x 1 root root 35985 8月 22 2017 easyrsa* -rw-r--r-- 1 root root 4560 9月 3 2015 openssl-1.0.cnf drwxr-xr-x 2 root root 69 12月 18 02:54 x509-types/ /usr/share/easy-rsa/3.0.3/x509-types: 合計 20 -rw-r--r-- 1 root root 300 9月 3 2015 COMMON -rw-r--r-- 1 root root 426 9月 3 2015 ca -rw-r--r-- 1 root root 192 9月 3 2015 client -rw-r--r-- 1 root root 35 8月 22 2017 san -rw-r--r-- 1 root root 208 9月 3 2015 server /*===============================================================*/

今回, easy-rsa ツールを用いて自己証明書を作成しますので easyrsa
スクリプトがインストールされた場所を上記コマンドで探します。
今回の場合は, /usr/share/easy-rsa/3.0.3 配下にインストールされて
いることが分かりますね。

```bash:command4 [root@sakuramoti ~]# mkdir -pv /etc/openvpn/easyRsa /*===============================================================*/ mkdir: ディレクトリ `/etc/openvpn/easyRsa' を作成しました /*===============================================================*/

上記コマンドで事前に, easy-rsa スクリプトをコピーするディレクトリ
作成しておきます。

[root@sakuramoti ~]# cp --preserve=all -vir /usr/share/easy-rsa/3.0.3/. /etc/openvpn/easyRsa /*===============================================================*/ /usr/share/easy-rsa/3.0.3/./easyrsa' -> /etc/openvpn/easyRsa/./easyrsa' /usr/share/easy-rsa/3.0.3/./openssl-1.0.cnf' -> /etc/openvpn/easyRsa/./openssl-1.0.cnf' /usr/share/easy-rsa/3.0.3/./x509-types' -> /etc/openvpn/easyRsa/./x509-types' /usr/share/easy-rsa/3.0.3/./x509-types/COMMON' -> /etc/openvpn/easyRsa/./x509-types/COMMON' /usr/share/easy-rsa/3.0.3/./x509-types/ca' -> /etc/openvpn/easyRsa/./x509-types/ca' /usr/share/easy-rsa/3.0.3/./x509-types/client' -> /etc/openvpn/easyRsa/./x509-types/client' /usr/share/easy-rsa/3.0.3/./x509-types/san' -> /etc/openvpn/easyRsa/./x509-types/san' /usr/share/easy-rsa/3.0.3/./x509-types/server' -> /etc/openvpn/easyRsa/./x509-types/server' /*===============================================================*/

上記コマンドで先ほど作成したディレクトリに, /usr/share/easy-rsa/3.0.3/
配下全てをコピーします。

[root@sakuramoti ~]# ls /etc/openvpn/easyRsa /*===============================================================*/ easyrsa openssl-1.0.cnf x509-types /*===============================================================*/

上記の様な構成になっていれば O.K. です。

3. EasyRSAツールを用いた証明書類の作成

  • 3.1 認証局 ( CA ) の作成

[root@sakuramoti ~]# cd /etc/openvpn/easyRsa/

cd コマンドで今居るディレクトリを変更します。

[root@sakuramoti easyRsa]# pwd /*===============================================================*/ /etc/openvpn/easyRsa /*===============================================================*/

上記の様なディレクトリに居ることを確認します。

[root@sakuramoti easyRsa]# ./easyrsa init-pki /*===============================================================*/ init-pki complete; you may now create a CA or requests. Your newly created PKI dir is: /etc/openvpn/easyRsa/pki /*===============================================================*/

現在居るディレクトリに easyrsa スクリプトがあるのでコレを使って
証明書に必要なディレクトリやクリーンを行う初期化を上記コマンドで行います。

[root@sakuramoti easyRsa]# ./easyrsa build-ca /*===============================================================*/ Generating a 2048 bit RSA private key ......................................+++ ......+++ writing new private key to '/etc/openvpn/easyRsa/pki/private/ca.key.aVHNm1FzSV' Enter PEM pass phrase: Verifying - Enter PEM pass phrase: ----- 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]:sharemyknowledge.jp CA creation complete and you may now import and sign cert requests. Your new CA certificate file for publishing is at: /etc/openvpn/easyRsa/pki/ca.crt /*===============================================================*/

上記の build-ca で, 認証局の作成を行います。
コマンドを実行するとパスフレーズとコモンネームを聞かれますので
任意のパスワードとコモンネームを設定して下さい。
ここで入力したパスワードは後ほど使うのでメモしておいて下さい。
このパスワードは多用することになりますので忘れないようにして下さい。

[root@sakuramoti easyRsa]# cp --preserve=all -vi ./pki/ca.crt /etc/openvpn /*===============================================================*/ ./pki/ca.crt' -> /etc/openvpn/ca.crt' /*===============================================================*/

作成した認証局 ( CA ) を /etc/openvpn 配下にコピーします。

  • 3.2 サーバ証明書の作成

[root@sakuramoti easyRsa]# ./easyrsa build-server-full server nopass /*===============================================================*/ Generating a 2048 bit RSA private key ..............................................................+++ ................................+++ writing new private key to '/etc/openvpn/easyRsa/pki/private/server.key.AKPMKoqgtn' ----- Using configuration from ./openssl-1.0.cnf Enter pass phrase for /etc/openvpn/easyRsa/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 Dec 15 03:35:02 2028 GMT (3650 days) Write out database with 1 new entries Data Base Updated /*===============================================================*/

上記コマンドでサーバ証明書を作成します。
作成するときに, 認証局 ( CA ) 証明を作成するときに入力した
パスワードを聞かれますのでそれをそのまま入力することで
サーバ証明書を作成することが出来ます。
サーバの鍵にパスワードを付けるとサービス起動時に面倒くさいので
nopass 付加して実行しています。

[root@sakuramoti easyRsa]# cp --preserve=all -vi ./pki/issued/server.crt /etc/openvpn; cp --preserve=all -vi ./pki/private/server.key /etc/openvpn /*===============================================================*/ ./pki/issued/server.crt' -> /etc/openvpn/server.crt' ./pki/private/server.key' -> /etc/openvpn/server.key' /*===============================================================*/

作成したサーバ証明書の証明書と秘密鍵を上記コマンドで
/etc/openvpn 配下にコピーします。

  • 3.3 DH パラメータの作成と配置

[root@sakuramoti easyRsa]# ./easyrsa gen-dh /*===============================================================*/ Generating DH parameters, 2048 bit long safe prime, generator 2 This is going to take a long time ....................................................................................................................+.....................................................+..............................+..........................................................................................................+......................................................................................................................................................+...............................................................................................................................................................................................+.............................................++*++* DH parameters of size 2048 created at /etc/openvpn/easyRsa/pki/dh.pem /*===============================================================*/

DH パラメータ ( Diffie-Hellman ) は, 暗号化接続の初期段階
でクライアントとサーバが暗号鍵を共有するために使用されるものです。
上記コマンドで作成しますが, マシンのスペックによっては生成に時間が
掛かる場合があります。

[root@sakuramoti easyRsa]# cp --preserve=all -vi ./pki/dh.pem /etc/openvpn /*===============================================================*/ ./pki/dh.pem' -> /etc/openvpn/dh.pem' /*===============================================================*/

先ほど作成した, dh.pem/etc/openvpn 配下にコピーします。

  • 3.4 クライアント証明書廃止リストの作成

[root@sakuramoti easyRsa]# ./easyrsa build-client-full dmy nopass /*===============================================================*/ Generating a 2048 bit RSA private key .......................................+++ .+++ writing new private key to > > '/etc/openvpn/easyRsa/pki/private/dmy.key.oWTmIdk6B9' ----- Using configuration from ./openssl-1.0.cnf Enter pass phrase for /etc/openvpn/easyRsa/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:'dmy' Certificate is to be certified until Dec 15 05:11:12 2028 GMT (3650 days) Write out database with 1 new entries Data Base Updated /*===============================================================*/

上記コマンドで一度, ダミーの証明書を作成します。
実行時に, 認証局 ( CA ) 証明を作成するときに入力したパスワードを聞かれます。

[root@sakuramoti easyRsa]# ./easyrsa revoke dmy /*===============================================================*/ Please confirm you wish to revoke the certificate with the following subject: subject= commonName = dmy Type the word 'yes' to continue, or any other input to abort. Continue with revocation: yes Using configuration from ./openssl-1.0.cnf Enter pass phrase for /etc/openvpn/easyRsa/pki/private/ca.key: Revoking Certificate F9113F979CF7710C6ACAB76BF08625D3. Data Base Updated IMPORTANT!!! Revocation was successful. You must run gen-crl and upload a CRL to your infrastructure in order to prevent the revoked cert from being accepted. /*===============================================================*/

作成したダミーの証明書を上記コマンドで廃止します。
実行時に, 認証局 ( CA ) 証明を作成するときに入力したパスワードを聞かれます。

[root@sakuramoti easyRsa]# ./easyrsa gen-crl /*===============================================================*/ Using configuration from ./openssl-1.0.cnf Enter pass phrase for /etc/openvpn/easyRsa/pki/private/ca.key: An updated CRL has been created. CRL file: /etc/openvpn/easyRsa/pki/crl.pem /*===============================================================*/

上記コマンドで, 証明書失効リストの作成を行います。
実行時に, 認証局 ( CA ) 証明を作成するときに入力したパスワードを聞かれます。

[root@sakuramoti easyRsa]# cp --preserve=all -vi ./pki/crl.pem /etc/openvpn /*===============================================================*/ ./pki/crl.pem' -> /etc/openvpn/crl.pem' /*===============================================================*/

先ほど作成した証明書失効リストを, /etc/openvpn 配下にコピーします。

[root@sakuramoti easyRsa]# chmod o+r /etc/openvpn/crl.pem

先ほどコピーした証明書失効リストのその他のユーザに読取り権限を付加します。

  • 3.5 TLS 認証鍵の作成

[root@sakuramoti ~]# openvpn --genkey --secret /etc/openvpn/ta.key

上記コマンドで TLS 認証鍵を /etc/openvpn 配下に作ります。

[root@sakuramoti ~]# cp --preserve=all -vi /usr/share/doc/openvpn-2.4.6/sample/sample-config-files/server.conf /etc/openvpn /*===============================================================*/ /usr/share/doc/openvpn-2.4.6/sample/sample-config-files/server.conf' -> /etc/openvpn/server.conf' /*===============================================================*/ [root@sakuramoti ~]# cp --preserve=all -vi /etc/openvpn/server.conf /etc/openvpn/server.conf.org /*===============================================================*/ /etc/openvpn/server.conf' -> /etc/openvpn/server.conf.org' /*===============================================================*/ [root@sakuramoti ~]# cp --preserve=all -vi /etc/openvpn/server.conf /etc/openvpn/server.conf.bak20181218 /*===============================================================*/ /etc/openvpn/server.conf' -> /etc/openvpn/server.conf.bak20181218' /*===============================================================*/

上記コマンドで, openvpn 設定ファイルをコピーし設定ファイルの複製を作成しています。

  • 3.6 設定ファイルの編集

  • dh dh.pem ← 追加 DH パラメータのファイル名を作成した物に合わせます。
  • push "redirect-gateway def1 bypass-dhcp" ← 追加
    Open VPN が動作しているホストをクライアントのゲートウェイとします。
    ( VPN Client の全ての通信を VPN サーバ経由にする。 )
  • push "dhcp-option DNS 8.8.8.8" ← 追加
    クライアントが使用する DNS サーバを指定します。`
  • client-to-client ← 追加 VPN 上でクライアント同士が接続できるようにする。
  • cipher AES-256-GCM ← 追加 open vpn 2.4 から使用出来ます。暗号化通信方式を指定。
  • ncp-ciphers AES-256-GCM ← 追加 こちらも, open vpn 2.4 から使用出来ます。
  • log-append /var/log/openvpn.log ← 追加 open vpn のログを出力する場所を指定。
  • explicit-exit-notify 1 ← 追加
    サーバを再起動した時などに自動的に再接続できるようにクライアントに通知する機能です。この機能が, サポートされるのは, open vpn 2.4 からです。
  • management localhost 7505 ← 追加 接続クライアントのマネージメントを使用する。
  • crl-verify crl.pem ← 追加 クライアント証明書廃止リストを指定します。
  • mssfix 1280 ← 追加 Samba に接続時の速度低下を防止する。
  • link-mtu 1400 ← 追加 こちらも同様 Samba 接続時に速度低下を防止するための設定。
  • tls-version-min 1.2 ← 追加 TLS 暗号化を強くする設定です。
  • tls-cipher TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384:TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384 ← 追加
    有効な接続方式を指定します。
  • reneg-sec 60 ← 追加 こちらも, TLS接続を強化するための設定となります。
  • 上記内容を /etc/openvpn/server.conf に追記・変更します。
    上記設定以外の追記・変更は行わないでください。クライアントからインターネット接続できなくなる場合があります。
  • comp-lzo などの圧縮関連は有効しないで下さい。
  • 3.7 ファイアウォール関連設定

[root@sakuramoti ~]# cd /etc/ [root@sakuramoti etc]# cp --preserve=all -vi ./sysctl.conf ./sysctl.conf.org /*===============================================================*/ /etc/sysctl.conf' -> /etc/sysctl.conf.org' /*===============================================================*/ [root@sakuramoti etc]# cp --preserve=all -vi ./sysctl.conf ./sysctl.conf.bak20181219 /*===============================================================*/ /etc/sysctl.conf' -> /etc/sysctl.conf.bak20181219' /*===============================================================*/ [root@sakuramoti etc]# echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf

上記で /etc に移動し, sysctl.conf のバックアップを取得しています。
その後, /etc/sysctl.conf に IPv4 フォワードを許可する設定を echo コマンドで追記しています。

[root@sakuramoti etc]# /sbin/sysctl -p

上記コマンドで設定を適用させます。 ( 再起動後も有効にする )

[root@sakuramoti ~]# nmcli d /*===============================================================*/ DEVICE TYPE STATE CONNECTION eth0 ethernet 接続済み System eth0 eth1 ethernet 切断済み- eth2 ethernet 切断済み- lo loopback 管理無し- /*===============================================================*/

現在有効な, NIC インターフェースを調べます。
この場合は, eth0 が, インターネット回線なのでメモっておきます。

[root@sakuramoti etc]# firewall-cmd --add-service openvpn /*===============================================================*/ success /*===============================================================*/

firewall に, open vpn サービスを追加します。

[root@sakuramoti etc]# firewall-cmd --permanent --add-service openvpn /*===============================================================*/ success /*===============================================================*/

上記コマンドで設定を永続化します。

[root@sakuramoti etc]# firewall-cmd --direct --passthrough ipv4 -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE /*===============================================================*/ success /*===============================================================*/

上記コマンドで firewall に, IP マスカレード設定を入れます。 ( NAT 設定 )
コマンドは改変せずこのまま打てば良いです。 eth0 の部分はさっきメモった
内容に変更して下さい。

[root@sakuramoti etc]# firewall-cmd --permanent --direct --passthrough ipv4 -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE /*===============================================================*/ success /*===============================================================*/

上記コマンドで設定を永続化します。
コマンドは改変せずこのまま打てば良いです。 eth0 の部分はさっきメモった
内容に変更して下さい

[root@sakuramoti etc]# firewall-cmd --permanent --zone=trusted --add-interface=tun+ /*===============================================================*/ success /*===============================================================*/

上記コマンドで, firewall に, VPN クライアントから, LAN 内の全アクセスを許可します。
設定は永続化しています。

[root@sakuramoti etc]# firewall-cmd --zone=trusted --add-interface=tun+ /*===============================================================*/ success /*===============================================================*/

上記コマンドで, firewall に, VPN クライアントから, LAN 内の全アクセスを許可します。

[root@sakuramoti etc]# firewall-cmd --reload /*===============================================================*/ success /*===============================================================*/

上記コマンドで, firewall に設定を適用させます。

  • 3.7 クライアントで接続する為に必要な証明書を作成

[root@sakuramoti easyRsa]# cd /etc/openvpn/easyRsa/ ./easyrsa build-client-full android nopass

上記コマンドで, クライアント証明書・秘密鍵( パスフレーズ認証なし )の作成を行います。
実行時に, 認証局 ( CA ) 証明を作成するときに入力したパスワードを聞かれます。

3.8 接続に必要なプロファイルを作成

[root@sakuramoti easyRsa]# cd /etc/openvpn/ vim android.ovpn /*===============================================================*/ client dev tun remote sharemyknowledge.jp 1194 udp key-direction 1 route 0.0.0.0 0.0.0.0 vpn_gateway remote-cert-tls server persist-tun management-query-proxy ncp-ciphers AES-256-GCM link-mtu 1470 mssfix 1430 resolv-retry infinite management localhost 7505 <ca> -----BEGIN CERTIFICATE----- ここに ca.crt の内容をコピペ -----END CERTIFICATE----- </ca> <key> -----BEGIN PRIVATE KEY----- ここに android.key ( クライアントの秘密鍵 ) の内容をコピペ -----END PRIVATE KEY----- </key> <cert> -----BEGIN CERTIFICATE----- ここに android.crt ( クライアント証明書 ) に内容をコピペ -----END CERTIFICATE----- </cert> <tls-auth> -----BEGIN OpenVPN Static key V1----- ここに ta.key の内容をコピペ -----END OpenVPN Static key V1----- </tls-auth> /*===============================================================*/

上記のひな形を使用し, 各証明書の部分だけ各自の環境に合わせて保存して下さい。
こちら, android アプリの, OpenVPN Connect Version 3.0.5.(1816) で動作確認を行っています。
この設定は, 先ほど設定した, server.conf に対応した形になっていますので証明書の部分以外は変更しないようにして下さい。
OpenVPN Connect ? Fast & Safe SSL VPN Client

  • 3.9 仕上げ

open vpn に, server.conf の場所を知らせる。
openvpn /etc/openvpn/server.conf
open vpn サービス開始
systemctl start openvpn@server
再起動後も自動起動する
systemctl enable openvpn@server
完成した android.ovpn ファイルをなるべくセキュアな経路を用いて Android 端末にコピーして下さい。
OpenVPN Connect からプロファイルをインポートし、設定内容を確認した後に接続を行なって正常に接続が出来ネットサーフィンが出来ることを確認します。
接続の際は tailf /var/log/openvpn.log コマンドでログを確認しながらエラーなどが出力されないようにして下さい。 VPN 接続でネットサーフィンがでできれば多少の警告が出力されても問題ありません。

4. 番外編なぐりがきメモ ( 筆者メモなので無視で O.K. です。)

[root@sakuramoti openvpn]# diff -u /etc/openvpn/server.conf.bak20181218 /etc/openvpn/server.conf --- /etc/openvpn/server.conf.bak20181218 2018-04-24 16:12:52.000000000 +0900 +++ /etc/openvpn/server.conf 2018-12-19 07:45:35.016104239 +0900 @@ -82,7 +82,8 @@ # Diffie hellman parameters. # Generate your own with: # openssl dhparam -out dh2048.pem 2048 -dh dh2048.pem +# DH パラメータのファイル名を作成した物に合わせる +dh dh.pem # Network topology # Should be subnet (addressing via IP) @@ -189,7 +190,9 @@ # (The OpenVPN server machine may need to NAT # or bridge the TUN/TAP interface to the internet # in order for this to work properly). -;push "redirect-gateway def1 bypass-dhcp" +# Open VPN が動作しているホストをクライアントのゲートウェイにする +push "redirect-gateway def1 bypass-dhcp" +#push "redirect-gateway def1" # Certain Windows-specific network settings # can be pushed to clients, such as DNS @@ -197,8 +200,10 @@ # http://openvpn.net/faq.html#dhcpcaveats # The addresses below refer to the public # DNS servers provided by opendns.com. -;push "dhcp-option DNS 208.67.222.222" -;push "dhcp-option DNS 208.67.220.220" +#push "dhcp-option DNS 208.67.222.222" +#push "dhcp-option DNS 208.67.220.220" +# クライアントが使う DNS サーバを指定する +push "dhcp-option DNS 8.8.8.8" # Uncomment this directive to allow different # clients to be able to "see" each other. @@ -206,7 +211,7 @@ # To force clients to only see the server, you # will also need to appropriately firewall the # server's TUN/TAP interface. -;client-to-client +client-to-client # Uncomment this directive if multiple clients # might connect with the same certificate/key @@ -249,18 +254,21 @@ # Note that v2.4 client/server will automatically # negotiate AES-256-GCM in TLS mode. # See also the ncp-cipher option in the manpage -cipher AES-256-CBC +cipher AES-256-GCM +ncp-ciphers AES-256-GCM # Enable compression on the VPN link and push the # option to the client (v2.4+ only, for earlier # versions see below) -;compress lz4-v2 -;push "compress lz4-v2" +#compress lz4-v2 +#push "compress lz4-v2" # For compression compatible with older clients use comp-lzo # If you enable it here, you must also # enable it in the client config file. -;comp-lzo +# 圧縮を有効化する +#comp-lzo +#comp-lzo adaptive # The maximum number of concurrently connected # clients we want to allow. @@ -294,7 +302,8 @@ # while "log-append" will append to it. Use one # or the other (but not both). ;log openvpn.log -;log-append openvpn.log +# Open VPN のログファイルの場所を指定する +log-append /var/log/openvpn.log # Set the appropriate level of log # file verbosity. @@ -312,4 +321,20 @@ # Notify the client that when the server restarts so it # can automatically reconnect. -explicit-exit-notify 1 ファイル末尾に改行がありません +explicit-exit-notify 1 + +# 新規追加 +# 接続クライアントのマネージメントを使えるようにする +management localhost 7505 + +# クライアント証明書の廃止リストを指定する +crl-verify crl.pem + +# Samba に接続時の速度低下を防止するための調整 +#fragment 1280 +mssfix 1280 +link-mtu 1400 + +tls-version-min 1.2 +tls-cipher TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384:TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384 +reneg-sec 60

server.conf フル差分

[root@sakuramoti openvpn]# find / -name android.crt -or -name android.key -or -name ca.crt -or -name crl.pem -or -name pc.ovpn -or -name ta.key -or -name android.ovpn /etc/openvpn/easyRsa/pki/private/android.key /etc/openvpn/easyRsa/pki/issued/android.crt /etc/openvpn/easyRsa/pki/ca.crt /etc/openvpn/easyRsa/pki/crl.pem /etc/openvpn/ca.crt /etc/openvpn/crl.pem /etc/openvpn/ta.key /etc/openvpn/android.ovpn

各種証明書など

Windows で接続する場合はこれらのファイルを全て転送する。 WinSCP などで

client dev tun remote sharemyknowledge.jp 1194 udp ca ca.crt cert android.crt key android.key key-direction 1 route 0.0.0.0 0.0.0.0 vpn_gateway remote-cert-tls server tls-auth ta.key 1 persist-tun management-query-proxy ncp-ciphers AES-256-GCM link-mtu 1400 mssfix resolv-retry infinite management localhost 7505 crl-verify crl.pem

pc.ovpn 雛形 動作確認 version openvpn-install-2.4.6-I602
openvpn-install-2.4.6-I602

PC での, Open VPN 設置の様子



centos7vpn