OpenVPN のための Solaris 用 TAP ドライバ

目次

TAP デバイスを使った設定例

OpenVPN のための Solaris 用 TAP ドライバで作成した TAP デバイスを利用した簡単な設定例をご紹介します。
クライアント、サーバには以下のディレクトリが存在していると仮定しています。(もし無ければ作っておきます)

  • サーバ(ホスト名: server)
    • /etc/openvpn/ ... 設定ファイル置き場
    • /etc/openvpn/keys/ ... 証明書、プライベートキー置き場
    • /etc/openvpn/easy-rsa/ ... OpenVPN のソースコードを展開したディレクトリにある "easy-rsa/" ディレクトリのコピー
  • クライアント(ホスト名: client1)
    • /etc/openvpn/ ... 設定ファイル置き場
    • /etc/openvpn/keys/ ... 証明書、プライベートキー置き場

証明書の発行

基本的にサーバ上の /etc/openvpn/easy-rsa/ ディレクトリで作業します。

準備

# cd /etc/openvpn/easy-rsa
# . ./vars
NOTE: when you run ./clean-all, I will be doing a rm -rf on /etc/openvpn/easy-rsa/keys
# ./clean-all

認証局(CA)の証明書とプライベートキーを発行

# ./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) [KG]:   <--- そのままエンターキーを押す
State or Province Name (full name) [NA]:  <--- そのままエンターキーを押す
Locality Name (eg, city) [BISHKEK]:  <--- そのままエンターキーを押す
Organization Name (eg, company) [OpenVPN-TEST]:  <--- そのままエンターキーを押す
Organizational Unit Name (eg, section) []:  <--- そのままエンターキーを押す
Common Name (eg, your name or your server's hostname) []:server  <--- サーバのホスト名を入力
Email Address [me@myhost.mydomain]:  <--- そのままエンターキーを押す

もちろん、それぞれの項目にちゃんと答えてもかまいません。ここでは手順の簡略化のために「Common Name」だけを入力しています。

サーバの証明書とプライベートキーを発行

# ./build-key-server server
Generating a 1024 bit RSA private key
..................................++++++
...................++++++
writing new private key to 'server.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) [KG]:  <--- そのままエンターキーを押す
State or Province Name (full name) [NA]:  <--- そのままエンターキーを押す
Locality Name (eg, city) [BISHKEK]:  <--- そのままエンターキーを押す
Organization Name (eg, company) [OpenVPN-TEST]:  <--- そのままエンターキーを押す
Organizational Unit Name (eg, section) []:  <--- そのままエンターキーを押す
Common Name (eg, your name or your server's hostname) []:server  <--- 「server」と入力
Email Address [me@myhost.mydomain]:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /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:'KG'
stateOrProvinceName   :PRINTABLE:'NA'
localityName          :PRINTABLE:'BISHKEK'
organizationName      :PRINTABLE:'OpenVPN-TEST'
commonName            :PRINTABLE:'server'
emailAddress          :IA5STRING:'me@myhost.mydomain'
Certificate is to be certified until Apr 23 14:14:55 2016 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

クライアントの証明書とプライベートキーを発行

# ./build-key client1
Generating a 1024 bit RSA private key
........................................................++++++
....++++++
writing new private key to 'client1.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) [KG]:  <--- そのままエンターキーを押す
State or Province Name (full name) [NA]:  <--- そのままエンターキーを押す
Locality Name (eg, city) [BISHKEK]:  <--- そのままエンターキーを押す
Organization Name (eg, company) [OpenVPN-TEST]:  <--- そのままエンターキーを押す
Organizational Unit Name (eg, section) []:  <--- そのままエンターキーを押す
Common Name (eg, your name or your server's hostname) []:client1  <--- クライアントのホスト名を入力
Email Address [me@myhost.mydomain]:  <--- そのままエンターキーを押す

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /etc/openvpn/easy-rsa/openssl.cnf
DEBUG[load_index]: unique_subject = "yes"
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName           :PRINTABLE:'KG'
stateOrProvinceName   :PRINTABLE:'NA'
localityName          :PRINTABLE:'BISHKEK'
organizationName      :PRINTABLE:'OpenVPN-TEST'
commonName            :PRINTABLE:'client1'
emailAddress          :IA5STRING:'me@myhost.mydomain'
Certificate is to be certified until Apr 23 14:22:27 2016 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

Diffie Hellman パラメータの生成

# ./build-dh
Generating DH parameters, 1024 bit long safe prime, generator 2
This is going to take a long time
................................+.........................+..............
...............+.....................................

#

認証局の証明書、サーバ証明書、プライベートキーのコピー

認証局の証明書、サーバ証明書、プライベートキーを /etc/openvpn/keys/ へコピー

# cd /etc/openvpn/easy-rsa/keys/
# cp ca.crt server.crt server.key dh1024.pem /etc/openvpn/keys

認証局の証明書、クライアント証明書、プライベートキーのコピー

ftp などを使ってサーバの /etc/openvpn/easy-rsa/keys/ ディレクトリにある以下のファイルをクライアントの /etc/openvpn/keys/ へコピーします

  • ca.crt
  • client1.crt
  • client1.key

設定ファイル

サーバ用設定ファイル

サーバの /etc/openvpn/ ディレクトリに以下の内容で server.conf ファイルを作成します。

/etc/openvpn/server.conf

dev tap
proto tcp-server
server 192.168.0.0 255.255.255.0
client-to-client
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/server.crt
key /etc/openvpn/keys/server.key
dh /etc/openvpn/keys/dh1024.pem

** この設定では VPN 上で使われる IP は 192.168.0.0 〜 192.168.0.255 になります。

クライアント用設定ファイル

クライアントの /etc/openvpn/ ディレクトリに以下の内容で client.conf ファイルを作成します。

/etc/openvpn/client.conf

remote server
proto tcp-client
dev tap
client
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/client1.crt
key /etc/openvpn/keys/client1.key

設定ファイル内の「remote server」の server とはサーバのホスト名です。

プログラムの起動

サーバ、クライアント上で openvpn コマンドを実行します。引数として、それぞれの設定ファイルを指定します。

サーバ

# /usr/local/sbin/openvpn /etc/openvpn/server.conf
Wed Apr 26 23:57:06 2006 OpenVPN 2.0.7 sparc-sun-solaris2.10 [SSL] built on Apr 26 2006
Wed Apr 26 23:57:06 2006 IMPORTANT: OpenVPN's default port number is now 1194, based on an official port 
number assignment by IANA.  OpenVPN 2.0-beta16 and earlier used 5000 as the default port.
Wed Apr 26 23:57:06 2006 WARNING: --keepalive option is missing from server config
Wed Apr 26 23:57:06 2006 TUN/TAP device tap0 opened
Wed Apr 26 23:57:06 2006 /usr/sbin/ifconfig tap0 192.168.0.1 netmask 255.255.255.0 broadcast + up
Wed Apr 26 23:57:06 2006 Listening for incoming TCP connection on [undef]:1194
Wed Apr 26 23:57:06 2006 TCPv4_SERVER link local (bound): [undef]:1194
Wed Apr 26 23:57:06 2006 TCPv4_SERVER link remote: [undef]
Wed Apr 26 23:57:06 2006 Initialization Sequence Completed

クライアント

# /usr/local/sbin/openvpn /etc/openvpn/client.conf
Wed Apr 26 23:58:14 2006 OpenVPN 2.0.7 sparc-sun-solaris2.9 [SSL] built on Apr 26 2006
Wed Apr 26 23:58:14 2006 IMPORTANT: OpenVPN's default port number is now 1194, based on an official port 
number assignment by IANA.  OpenVPN 2.0-beta16 and earlier used 5000 as the default port.
Wed Apr 26 23:58:14 2006 WARNING: No server certificate verification method has been enabled.  See  
http://openvpn.net/howto.html#mitm for more info.
Wed Apr 26 23:58:14 2006 Attempting to establish TCP connection with 172.29.73.55:1194
Wed Apr 26 23:58:14 2006 TCP connection established with 172.29.73.55:1194
Wed Apr 26 23:58:14 2006 TCPv4_CLIENT link local: [undef]
Wed Apr 26 23:58:14 2006 TCPv4_CLIENT link remote: 172.29.73.55:1194
Wed Apr 26 23:58:16 2006 [server] Peer Connection Initiated with 172.29.73.55:1194
Wed Apr 26 23:58:17 2006 TUN/TAP device tap0 opened
Wed Apr 26 23:58:17 2006 /usr/sbin/ifconfig tap0 192.168.0.2 netmask 255.255.255.0 broadcast + up
Wed Apr 26 23:58:18 2006 Initialization Sequence Completed

サーバ、クライアントともに WARNING メッセージが出てしまいましたが、とりあえず無事接続したようです。気になる方は調べて設定ファイルを変更してみてください。

ifconfig コマンドの実行結果の確認

このとき ifconfig コマンドを実行するとそれぞれ以下のように見えるはずです。

  • サーバ上にて
    # ifconfig tap0
    tap0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 4
           inet 192.168.0.1 netmask ffffff00 broadcast 192.168.0.255
           ether 8:0:20:c6:69:c7
  • クライアント上にて
    # ifconfig tap0
    tap0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 4
           inet 192.168.0.2 netmask ffffff00 broadcast 192.168.0.255
           ether 8:0:20:91:a6:90

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2022-01-03 (月) 16:49:03