tun
(IP レベルトンネル用) と tap
(イーサネットレベルトンネル用) インターフェースをサポートします。実際には、VPN クライアントをイーサネットブリッジ経由でサーバのローカルネットワークに参加させる場合を除いて、tun
インターフェースが最もよく使われます。
pki/ca.crt
) will be stored on all machines (both server and clients) as /etc/ssl/certs/Falcot_CA.crt
. The server's certificate is installed only on the server (pki/issued/vpn.falcot.com.crt
goes to /etc/ssl/certs/vpn.falcot.com.crt
, and pki/private/vpn.falcot.com.key
goes to /etc/ssl/private/vpn.falcot.com.key
with restricted permissions so that only the administrator can read it), with the corresponding Diffie-Hellman parameters (pki/dh.pem
) installed to /etc/openvpn/dh.pem
. Client certificates are installed on the corresponding VPN client in a similar fashion.
/etc/openvpn/*.conf
. Setting up a VPN server is therefore a matter of storing a corresponding configuration file in this directory. A good starting point is /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz
, which leads to a rather standard server. Of course, some parameters need to be adapted: ca
, cert
, key
and dh
need to describe the selected locations (respectively, /etc/ssl/certs/Falcot_CA.crt
, /etc/ssl/vpn.falcot.com.crt
, /etc/ssl/private/vpn.falcot.com.key
and /etc/openvpn/dh.pem
). The server 10.8.0.0 255.255.255.0
directive defines the subnet to be used by the VPN; the server uses the first IP address in that range (10.8.0.1
) and the rest of the addresses are allocated to clients.
tun0
name. However, firewalls are often configured at the same time as the real network interfaces, which happens before OpenVPN starts. Good practice therefore recommends creating a persistent virtual network interface, and configuring OpenVPN to use this pre-existing interface. This further allows choosing the name for this interface. To this end, openvpn --mktun --dev vpn --dev-type tun
creates a virtual network interface named vpn
with type tun
; this command can easily be integrated in the firewall configuration script, or in an up
directive of the /etc/network/interfaces
file, or a udev rule can be added to that end. The OpenVPN configuration file must also be updated accordingly, with the dev vpn
and dev-type tun
directives.
10.8.0.1
アドレスの VPN サーバにアクセスできるだけです。クライアントをローカルネットワーク (192.168.0.0/24) へアクセスできる状態にするには、push route 192.168.0.0 255.255.255.0
指示文を OpenVPN 設定に追加します。こうすることで、VPN クライアントは自動的にネットワーク経路を取得し、VPN 経由でローカルネットワークに到達できるようになります。さらに、ローカルネットワークにいるマシンに対して VPN サーバに通じる VPN への経路を知らせる必要もあります (VPN サーバがゲートウェイにインストールされている場合、これは自動的に動きます)。別の方法として、VPN サーバが IP マスカレードを動かすように設定する方法があります。そうすれば、VPN クライアントからの接続はあたかもクライアントが VPN サーバからアクセスしたかのように見えます (第 10.1 節「ゲートウェイ」を参照してください)。
/etc/openvpn/
に設定ファイルを置きます。標準的な設定の良い足掛かりとして /usr/share/doc/openvpn/examples/sample-config-files/client.conf
が用意されています。remote vpn.falcot.com 1194
指示文は OpenVPN サーバのアドレスとポート番号を表します。さらに ca
、cert
、key
も鍵ファイルの場所に合わせて設定が必要です。
AUTOSTART
directive to none
in the /etc/default/openvpn
file. Starting or stopping a given VPN connection is always possible with the commands systemctl start openvpn@name
and systemctl stop openvpn@name
(where the connection name matches the one defined in /etc/openvpn/name.conf
).
tun*
) を作り、仮想インターフェースをあたかも物理インターフェースのように設定することが可能です。このトンネルシステムを有効化するにはまず、SSH サーバの設定ファイル (/etc/ssh/sshd_config
) の中で PermitTunnel
を「yes」に設定しなければいけません。SSH 接続を確立する際には、-w any:any
オプションを使って明示的にトンネルの作成を要求しなければいけません (ここで any
は必要な tun
デバイス番号で置き替えます)。トンネルを作成するには、サーバおよびクライアント側でそのユーザが管理者権限を持っていることが必要です。そうすればネットワークデバイスを作成することが可能です (言い換えれば、接続は root で確立されなければいけません)。
/etc/ipsec.conf
contains the parameters for IPsec tunnels (or Security Associations, in the IPsec terminology) that the host is concerned with. There are many configuration examples in /usr/share/doc/libreswan/
, but Libreswan's online documentation has more examples with explanations:
systemctl
; for example, systemctl start ipsec
will start the IPsec service.
/etc/ppp/options.pptp
、/etc/ppp/peers/falcot
、/etc/ppp/ip-up.d/falcot
、/etc/ppp/ip-down.d/falcot
を作成しました。
例 10.3 /etc/ppp/peers/falcot
ファイル
# vpn.falcot.com は PPTP サーバです pty "pptp vpn.falcot.com --nolaunchpppd" # "vpn" ユーザで本人確認して接続します user vpn remotename pptp # 暗号化を有効にします require-mppe-128 file /etc/ppp/options.pptp ipparam falcot
pptpd
は Linux 用の PPTP サーバです。主設定ファイル /etc/pptpd.conf
にはいくつかの変更が必要です。すなわち localip (ローカル IP アドレス) と remoteip (リモート IP アドレス) を変更する必要があります。以下の例では、PPTP サーバは常に 192.168.0.199
アドレスを使い、PPTP クライアントは 192.168.0.200
から 192.168.0.250
までの IP アドレスを受け取ります。
例 10.6 /etc/pptpd.conf
ファイル
# TAG: speed # # PPTP デーモンの通信速度を指定します。 # speed 115200 # TAG: option # # PPP オプションファイルの場所を指定します。 # PPP はデフォルトで '/etc/ppp/options' を使います # option /etc/ppp/pptpd-options # TAG: debug # # syslog に詳細なデバッグ情報を出力します # # debug # TAG: localip # TAG: remoteip # # ローカルとリモートの IP アドレス範囲を指定します。 # # コンマで区切ることで、単独の IP アドレスおよび # IP アドレス範囲を指定できます。以下は利用例です。 # # 192.168.0.234,192.168.0.245-249,192.168.0.254 # # 以下の重要な制約事項に注意してください。 # # 1. コンマ間およびアドレス内部で空白文字を使わないでください。 # # 2. MAX_CONNECTIONS よりも多くの IP アドレス を指定した場合、 # 使われる IP アドレスはリストの先頭から MAX_CONNECTIONS # 個までの IP アドレスです。それ以外は使われません。 # # 3. アドレス範囲を略記しないでください! たとえば 234 から 238 の範囲を指定するために # 234-8 と記述するのは間違いです。その代わり 234-238 と記述してください。 # # 4. ローカル IP は 1 つだけでも構いません。この場合、すべてのローカル IP は # 指定したものになります。しかしながら、同時接続中のクライアントには # 必ず異なるリモート IP を割り振らなければいけません。 # #localip 192.168.0.234-238,192.168.0.245 #remoteip 192.168.1.234-238,192.168.1.245 #localip 10.0.1.1 #remoteip 10.0.1.2-100 localip 192.168.0.199 remoteip 192.168.0.200-250
/etc/ppp/pptpd-options
を編集して、PPTP サーバの使う PPP 設定を変更します。重要なパラメータはサーバ名 (pptp
)、ドメイン名 (falcot.com
)、DNS と WINS サーバの IP アドレスです。
例 10.7 /etc/ppp/pptpd-options
ファイル
## pppd の syslog デバッグを有効化します #debug ## 「サーバ名」を chap-secrets 内の自分のサーバ名として指定したものに変更します name pptp ## ドメイン名をローカルドメインに変更します domain falcot.com ## 以下は WinXXXX クライアントに対して ## 適当とされるデフォルトセキュリティ関連設定です # Debian の pppd パッケージは MSCHAP と MPPE の両方をサポートしています。そのため # ここでは両方を有効化しています。カーネルの MPPE サポートが必須という点にも注意してください! auth require-chap require-mschap require-mschap-v2 require-mppe-128 ## サービスに対応するアドレスを指定してください ms-dns 192.168.0.1 ms-wins 192.168.0.1 ## ネットマスクを指定してください netmask 255.255.255.0 ## 一部のデフォルト設定 nodefaultroute proxyarp lock
vpn
ユーザ (と対応するパスワード) を /etc/ppp/chap-secrets
ファイルに登録します。サーバ名だけは、アスタリスク (*
) を使える他のインスタンスと異なり、明示的に指定しなければいけません。さらに、Windows PPTP クライアントはユーザ名ではなく DOMAIN\\USER
という形を認証を行います。このため、/etc/ppp/chap-secrets
ファイルに FALCOT\\vpn
ユーザが追加されています。ユーザに割り当てる IP アドレスを明記することも可能です。IP アドレスフィールドのアスタリスクは動的にアドレスを割り当てることを意味します。