はじめに
OpenBlockS 600は堅牢性やLinux採用によるカスタマイズ性の高さなどの特徴から、
今回はさまざまな用途の中でも事例の多い、
OpenVPN
OpenVPNはオープンソースのVPNソフトウェアとしては、
UT-VPN
UT-VPNは公開が2010年6月からと日が浅いですが、
機能としてはOpenVPNで可能な内容がほぼ網羅され、
OpenVPNの導入と設定
今回の記事では、
![図1 ネットワーク構成図 図1 ネットワーク構成図](/assets/images/admin/serial/01/ob600s_2011/0005/thumb/TH800_001t.jpg)
ブリッジ方式では、
また、
OpenBlockSの基本設定
OpenBlockS 600にルータとしての機能も担わせるため、
ネットワーク
Webインターフェースを開き、
![図2 PPPoEの設定 図2 PPPoEの設定](/assets/images/admin/serial/01/ob600s_2011/0005/thumb/TH800_002.jpg)
ファイアウォール
同じくWebインターフェースでファイアウォールの基本設定
UDPとTCPの両方を設定しますが、
![図3 ファイアウォールの設定 図3 ファイアウォールの設定](/assets/images/admin/serial/01/ob600s_2011/0005/thumb/TH800_003.jpg)
OpenVPNの導入
導入はWebインターフェース上のアプリケーションマネージャ
![図4 アプリケーションマネージャ 図4 アプリケーションマネージャ](/assets/images/admin/serial/01/ob600s_2011/0005/thumb/TH800_004.jpg)
リストの絞り込みによりopenvpnが表示されますので、
![図5 openvpnのインストール 図5 openvpnのインストール](/assets/images/admin/serial/01/ob600s_2011/0005/thumb/TH800_005.jpg)
OpenVPNの設定
OpenVPNは一方がサーバとして接続を待ち受け、
証明書の生成
OpenVPNによる接続には、
実行例はそれぞれのリストを参照してください。なお実行は、
- プライベートCAの構築
(図6、 リスト1 ) - サーバ証明書、
秘密鍵の生成 (図7) - クライアント証明書、
秘密鍵の生成 (図8) - DH
(Diffie-Hellman) パラメータの生成 (図9)
export KEY_COUNTRY="JP"
export KEY_PROVINCE="Tokyo"
export KEY_CITY="Chiyoda-ku"
export KEY_ORG="Plat'Home CO.,LTD."
export KEY_EMAIL="[email protected]"
# cd /usr/pkg/etc/openvpn # cp -r /usr/pkg/share/openvpn/easy-rsa/ . # cd easy-rsa/ # vi vars ←変更内容はリスト1を参照 # source vars NOTE: If you run ./clean-all, I will be doing a rm -rf on /usr/pkg/etc/openvpn/easy-rsa/keys # ./clean-all # ./build-ca Generating a 1024 bit RSA private key ..............++++++ ...........................................++++++ writing new private key to 'ca.key' ----- 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. ----- Country Name (2 letter code) [JP]: State or Province Name (full name) [Tokyo]: Locality Name (eg, city) [Chiyoda-ku]: Organization Name (eg, company) [Plat'Home CO.,LTD.]: Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) [Plat'Home CO.,LTD. CA]: Email Address [[email protected]]:
# cd /usr/pkg/etc/openvpn/easy-rsa # source vars NOTE: If you run ./clean-all, I will be doing a rm -rf on /usr/pkg/etc/openvpn/easy-rsa/keys # ./build-key-server server …省略… Country Name (2 letter code) [JP]: State or Province Name (full name) [Tokyo]: Locality Name (eg, city) [Chiyoda-ku]: Organization Name (eg, company) [Plat'Home CO.,LTD.]: Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) [server]: Email Address [[email protected]]: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Using configuration from /usr/pkg/etc/openvpn/easy-rsa/openssl.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows countryName :PRINTABLE:'JP' stateOrProvinceName :PRINTABLE:'Tokyo' localityName :PRINTABLE:'Chiyoda-ku' organizationName :PRINTABLE:'Plat'Home CO.,LTD.' commonName :PRINTABLE:'server' emailAddress :IA5STRING:'[email protected]' Certificate is to be certified until Sep 27 06:05:44 2020 GMT (3650 days) Sign the certificate? [y/n]:y ←yを入力 1 out of 1 certificate requests certified, commit? [y/n]y ←yを入力 Write out database with 1 new entries Data Base Updated
# cd /usr/pkg/etc/openvpn/easy-rsa
# source vars
NOTE: If you run ./clean-all, I will be doing a rm -rf on /usr/pkg/etc/openvpn/easy-rsa/keys
# ./build-key client
…以下省略。操作は図7と同様です…
# cd /usr/pkg/etc/openvpn/easy-rsa # source vars NOTE: If you run ./clean-all, I will be doing a rm -rf on /usr/pkg/etc/openvpn/easy-rsa/keys # ./build-dh Generating DH parameters, 1024 bit long safe prime, generator 2 This is going to take a long time .....................................................+.......................................+........+.............+....................................................................................................................................................+....................................................................+.............++*++*++*
サーバの設定
設定例はリスト2を参照してください。先の手順で作成したca.
port 1194
proto udp
dev tap0
ca ca.crt
cert server.crt
key server.key
dh dh1024.pem
server-bridge
keepalive 10 120
cipher AES-256-CBC
user nobody
group nobody
persist-key
persist-tun
status openvpn-status.log
verb 3
クライアントの設定
設定例はリスト3を参照してください。先の手順で作成したca.
client
dev tap0
proto udp
remote vpnserver.example.org 1194
サーバのホスト名またはIPを指定します ↑
resolv-retry infinite
nobind
user nobody
group nobody
persist-key
persist-tun
ca ca.crt
cert client.crt
key client.key
ns-cert-type server
cipher AES-256-CBC
verb 3
自動実行の設定
OpenBlockS 600の起動時に自動的にopenvpnを実行するために、
openvpn=YES
VPNとLANを結ぶ
これまでの設定でVPNのトンネルはできあがりますが、
OpenVPNでは、
eth="eth1"
eth_ip="192.168.0.1"
eth_netmask="255.255.255.0"
eth_broadcast="192.168.0.255"
今回は2つの拠点を同一のEthernetセグメントとして接続しますので、
PATH=$PATH:/usr/pkg/sbin:/usr/pkg/bin
/bin/sh /usr/pkg/etc/openvpn/bridge-start
以上ですべての設定が完了しました。再起動後はネットワーク設定→ファイアウォール設定→ブリッジ設定→OpenVPN起動の順に処理され、
まとめ
今回はOpenVPNの設定を完了させるところまでご紹介しました。設定手順はそれなりに量がありますが、