LoginSignup
1
0

More than 1 year has passed since last update.

OpenVPNのclient.confサンプルファイル和訳

Posted at

manで出てこないと思ったら/usr/share/doc/の方にマニュアルがあった
この辺のページも参考になる(https://www.openvpn.jp/document/how-to/)

0.0 環境

Rocky Linux 8.5
OpenVPN 2.4

1.1 OpenVPNのインストール

まだOpenVPNをインストールしていない場合は以下の手順でインストール

OpenVPNのインストール
# cat /proc/version
Linux version 4.18.0-348.el8.0.2.x86_64 (mockbuild@dal1-prod-builder001.bld.equ.rockylinux.org) (gcc version 8.5.0 20210514 (Red Hat 8.5.0-3) (GCC)) #1 SMP Sun Nov 14 00:51:12 UTC 2021

# dnf -y install openvpn

# rpm -qa | grep openvpn
openvpn-2.4.12-1.el8.x86_64

1.2 ドキュメントを見てみる

以下のパスにclient.confのサンプルファイル(パラメータの解説つき)が存在

/usr/share/doc/openvpn/sample/sample-config-files/client.conf
# ls -l /usr/share/doc/openvpn/sample/sample-config-files/client.conf
-rw-r--r-- 1 root root 3585  3月 17  2022 /usr/share/doc/openvpn/sample/sample-config-files/client.conf

内容を和訳しながら確認していきましょう(基本DeepL)

ファイルの概要
##############################################
# Sample client-side OpenVPN 2.0 config file #
# for connecting to multi-client server.     #
#                                            #
# This configuration can be used by multiple #
# clients, however each client should have   #
# its own cert and key files.                #
#                                            #
# On Windows, you might want to rename this  #
# file so it has a .ovpn extension           #
##############################################

マルチクライアントサーバーに接続するためのクライアント側OpenVPN 2.0設定ファイルのサンプル

この設定は複数のクライアントで使用することができますが、各クライアントは独自の証明書と鍵ファイルを持つべきです

Windowsでは、このファイルの名前を変更して、拡張子が.ovpnになるようにするとよいでしょう

パラメータ「client」
# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client

私たちがクライアントであり、サーバーから特定の設定ファイルディレクティブを引き出すことを指定します

とりあえずクライアント側にはこれを入れておく

「パラメータdev」
# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun

サーバーで使用している設定と同じものを使用してください。
ほとんどのシステムでは、TUN/TAPインターフェースのファイアウォールを部分的または完全に無効にしないと、VPNは機能しません。

tun:ルート接続(クライアントとサーバが別のセグメントになるやつ)
tap:ブリッジ接続(クライアントとサーバが同じセグメントになるやつ)

パラメータ「dev-node」
# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel
# if you have more than one.  On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
;dev-node MyTap

Windowsは、複数のTAP-Win32アダプターがある場合、ネットワーク接続パネルからTAP-Win32アダプターの名前を必要とします。 XP SP2の場合、TAPアダプタのファイアウォールを無効にする必要がある場合があります

パラメータ「proto」
# Are we connecting to a TCP or
# UDP server?  Use the same setting as
# on the server.
;proto tcp
proto udp

TCPまたはUDPのサーバーに接続しているか? サーバーと同じ設定にしてください。

パラメータ「remote」
# 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 my-server-2 1194

サーバーのホスト名/IPとポートです。サーバー間の負荷分散のために、複数のリモートエントリーを持つことができます。

パラメータ「remote-random」
# Choose a random host from the remote
# list for load-balancing.  Otherwise
# try hosts in the order specified.
;remote-random

ロードバランシングのために、リモートリストからランダムにホストを選択します。 それ以外の場合は、指定された順番でホストを試します。

パラメータ「resolv-retry」
# Keep trying indefinitely to resolve the
# host name of the OpenVPN server.  Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite

OpenVPN サーバーのホスト名を解決するために、無期限に試行し続ける。 ラップトップのようなインターネットに常時接続されていないマシンで非常に有効です。

remoteに指定したサーバの名前解決に失敗した場合、次のサーバに接続するまでに名前解決を再試行する時間を設定する。
resolv-retry 60」とすれば60秒間は名前解決を試みるようになる。

パラメータ「nobind」
# Most clients don't need to bind to
# a specific local port number.
nobind

ほとんどのクライアントは、特定のローカルポート番号にバインドする必要はない。

クライアントからのパケットの送信時にポートを固定せず、動的に割り当てられるようになるらしい

パラメータ「user/group」
# Downgrade privileges after initialization (non-Windows only)
;user nobody
;group nobody

初期化後の権限のダウングレード(非Windowsのみ)

パラメータ「persist-key/persist-tun」
# Try to preserve some state across restarts.
persist-key
persist-tun

再起動の間、何らかの状態を維持するようにする。

パラメータ「http-proxy*」
# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here.  See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]

実際の OpenVPN サーバに到達するために HTTP プロキシを経由して接続している場合、ここにプロキシサーバ/IP とポート番号を記入します。 プロキシサーバで認証が必要な場合は、man ページを参照してください。

パラメータ「mute-replay-warnings」
# Wireless networks often produce a lot
# of duplicate packets.  Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings

ワイヤレスネットワークは、多くの場合、重複パケットを生成します。 このフラグを設定すると、重複パケット警告が無効になります。

パラメータ「ca/cert/key」
# SSL/TLS parms.
# See the server config file for more
# description.  It's best to use
# a separate .crt/.key file pair
# for each client.  A single ca
# file can be used for all clients.
ca ca.crt
cert client.crt
key client.key

SSL/TLSのパラメータです。
詳細はサーバー設定ファイルを参照してください。 各クライアントには、別々の.crt/.keyファイルのペアを使用するのが最善です。 1つのca ファイルはすべてのクライアントに使用できます。

パラメータ「remote-cert-tls」
# Verify server certificate by checking that the
# certicate has the correct key usage set.
# This is an important precaution to protect against
# a potential attack discussed here:
#  http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the keyUsage set to
#   digitalSignature, keyEncipherment
# and the extendedKeyUsage to
#   serverAuth
# EasyRSA can do this for you.
remote-cert-tls server

サーバー証明書を確認し、証明書に正しい鍵の使用法が設定されていることを確認する。
これは、ここ(http://openvpn.net/howto.html#mitm) で説明した潜在的な攻撃から保護するための重要な予防措置です。

この機能を使うには、digitalSignature, keyEncipherment に設定された keyUsage と serverAuth に設定された extendedKeyUsage でサーバ証明書を生成する必要があります。

EasyRSA はこれを行うことができます。

パラメータ「tls-auth」
# If a tls-auth key is used on the server
# then every client must also have the key.
tls-auth ta.key 1

サーバーでtls-authキーを使用する場合、すべてのクライアントもそのキーを持っている必要があります。

パラメータ「cipher」
# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
# 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オプションがサーバで使用されている場合は、ここでも指定する必要があります。v2.4 のクライアント/サーバは、TLS モードで自動的に AES-256-GCM をネゴシエートすることに注意してください。
manページのncp-cipherオプションも参照してください

パラメータ「comp-lzo」
# Enable compression on the VPN link.
# Don't enable this unless it is also
# enabled in the server config file.
#comp-lzo

VPNリンクの圧縮を有効にする。サーバーの設定ファイルでも有効になっていない限り、これを有効にしないでください。

パラメータ「verb」
# Set log file verbosity.
verb 3

ログファイルの詳細度を設定します。

パラメータ「mute」
# Silence repeating messages
;mute 20

繰り返されるメッセージの抑制

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0