Android向けL2TP/IPSec-VPNサーバ構築
Published by M-naka on 2012/7/8 (6390 reads)
Android端末向けにL2TP/IPSec-VPNサーバを構築した。
もともと持っていたLifetouchBもIPSecクライアント機能は持っていたのだが、イマイチ気合が足りず構築に踏み切れずにいた。MEDIAS WP N-06CがIPSec対応であることに気付き、3G経由でのIPSec接続を試してみたくなり、改めてIPSec-VPNサーバを立ててみることにした。
Vyattaでアプライアンス……でも良かったのだか、先ずは稼働中の外向きサーバのGungnirでやってみた。結論から言うとVyattaの出番はなく、Gungnirで構築ができた。
先ず前提として、うちのサーバ群はNAPTの後ろで稼動しているので、通常のトランスポートモードが使えず、NAT-traversalを利用することになる。
手順は以下。
1.関連パッケージインストール
yum install openswan xl2tpd
これだけ。
2.コンフィグファイル作成
[/etc/ipsec.conf]
version 2.0
config setup
protostack=netkey
nat_traversal=yes
virtual_private=%4:192.168.1.0/8
oe=off
nhelpers=0
include /etc/ipsec.d/*.conf
[/etc/ipsec.d/l2tp-psk.conf]
conn L2TP-PSK-NAT
rightsubnet=0.0.0.0/0
also=L2TP-PSK-noNAT
conn L2TP-PSK-noNAT
authby=secret
pfs=no
auto=add
keyingtries=3
rekey=no
ikelifetime=8h
keylife=1h
type=transport
left=%defaultroute
leftprotoport=17/1701
right=%any
rightprotoport=17/%any
[/etc/ipsec.d/ipsec.secrets]
: PSK "Pre Shared Key"
[/etc/xl2tpd/xl2tpd.conf]
[lns default]
ip range = 192.168.1.128-192.168.1.254
local ip = 192.168.1.175
require chap = yes
refuse pap = yes
require authentication = yes
name = IPSecL2TP-VPN
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes
[/etc/ppp/options.xl2tpd]
ipcp-accept-local
ipcp-accept-remote
ms-dns 192.168.1.165
ms-dns 192.168.1.155
ms-wins 192.168.1.165
ms-wins 192.168.1.155
persist
#noccp # <コメントアウト
auth
crtscts
idle 1800
mtu 1280 # <1280に変更
mru 1280 # <1280に変更
nodefaultroute
debug
lock
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
proxyarp
connect-delay 5000
logfile /var/log/xl2tpd.l2tp-ipsec.log
[/etc/ppp/chap-secrets]
# Secrets for authentication using CHAP
# client server secret IP addresses
username * "password" *
[/etc/sysctl.conf]
#IPSec Configuration
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.eth0.send_redirects = 0
net.ipv4.conf.lo.send_redirects = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.eth0.accept_redirects = 0
net.ipv4.conf.lo.accept_redirects = 0
crypto.fips_enabled = 1
・・・追記後に「/sbin/sysctl -p」で反映。
3.サービス起動とチェック
/etc/rc.d/init.d/ipsec start
/etc/rc.d/init.d/xl2tpd start
/sbin/ipsec verify
Checking your system to see if IPsec got installed and started correctly:
Version check and ipsec on-path [OK]
Linux Openswan U2.6.21/K2.6.18-274.18.1.el5 (netkey)
Checking for IPsec support in kernel [OK]
NETKEY detected, testing for disabled ICMP send_redirects [OK]
NETKEY detected, testing for disabled ICMP accept_redirects [OK]
Checking for RSA private key (/etc/ipsec.secrets) [OK]
Checking that pluto is running [OK]
Two or more interfaces found, checking IP forwarding [OK]
Checking NAT and MASQUERADEing
Checking for 'ip' command [OK]
Checking for 'iptables' command [OK]
Opportunistic Encryption Support [DISABLED]
になればOK。DISABLEDが出た場合は不具合箇所をipsec verifyしながら順次潰す。
4.ファイアウォールの設定
500/udp(IKE)と4500/udp(NAT-traversal)を開口、サーバ側の受け口となるppp0のFOWARDチェインを追加する。
5.ルータの設定
500/udp(IKE)と4500/udp(NAT-traversal)を開口、Gungnirにパケットフォワードが掛かるようにする。
ここまでやってMEDIAS WP N-06CからL2TP PSK IKEv1プロファイルを使用した接続設定でVPN接続が確立、PingとVPCへのリモートデスクトップ接続が正常に動作することを確認した。
「細い3G」なのでレスポンスはそれなりだが、恐ろしく簡単に繋がる。WiMAX経由でLifetouchBも同様に接続ができるはず。あとでやってみよう。
もともと持っていたLifetouchBもIPSecクライアント機能は持っていたのだが、イマイチ気合が足りず構築に踏み切れずにいた。MEDIAS WP N-06CがIPSec対応であることに気付き、3G経由でのIPSec接続を試してみたくなり、改めてIPSec-VPNサーバを立ててみることにした。
Vyattaでアプライアンス……でも良かったのだか、先ずは稼働中の外向きサーバのGungnirでやってみた。結論から言うとVyattaの出番はなく、Gungnirで構築ができた。
先ず前提として、うちのサーバ群はNAPTの後ろで稼動しているので、通常のトランスポートモードが使えず、NAT-traversalを利用することになる。
手順は以下。
1.関連パッケージインストール
yum install openswan xl2tpd
これだけ。
2.コンフィグファイル作成
[/etc/ipsec.conf]
version 2.0
config setup
protostack=netkey
nat_traversal=yes
virtual_private=%4:192.168.1.0/8
oe=off
nhelpers=0
include /etc/ipsec.d/*.conf
[/etc/ipsec.d/l2tp-psk.conf]
conn L2TP-PSK-NAT
rightsubnet=0.0.0.0/0
also=L2TP-PSK-noNAT
conn L2TP-PSK-noNAT
authby=secret
pfs=no
auto=add
keyingtries=3
rekey=no
ikelifetime=8h
keylife=1h
type=transport
left=%defaultroute
leftprotoport=17/1701
right=%any
rightprotoport=17/%any
[/etc/ipsec.d/ipsec.secrets]
: PSK "Pre Shared Key"
[/etc/xl2tpd/xl2tpd.conf]
[lns default]
ip range = 192.168.1.128-192.168.1.254
local ip = 192.168.1.175
require chap = yes
refuse pap = yes
require authentication = yes
name = IPSecL2TP-VPN
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes
[/etc/ppp/options.xl2tpd]
ipcp-accept-local
ipcp-accept-remote
ms-dns 192.168.1.165
ms-dns 192.168.1.155
ms-wins 192.168.1.165
ms-wins 192.168.1.155
persist
#noccp # <コメントアウト
auth
crtscts
idle 1800
mtu 1280 # <1280に変更
mru 1280 # <1280に変更
nodefaultroute
debug
lock
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
proxyarp
connect-delay 5000
logfile /var/log/xl2tpd.l2tp-ipsec.log
[/etc/ppp/chap-secrets]
# Secrets for authentication using CHAP
# client server secret IP addresses
username * "password" *
[/etc/sysctl.conf]
#IPSec Configuration
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.eth0.send_redirects = 0
net.ipv4.conf.lo.send_redirects = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.eth0.accept_redirects = 0
net.ipv4.conf.lo.accept_redirects = 0
crypto.fips_enabled = 1
・・・追記後に「/sbin/sysctl -p」で反映。
3.サービス起動とチェック
/etc/rc.d/init.d/ipsec start
/etc/rc.d/init.d/xl2tpd start
/sbin/ipsec verify
Checking your system to see if IPsec got installed and started correctly:
Version check and ipsec on-path [OK]
Linux Openswan U2.6.21/K2.6.18-274.18.1.el5 (netkey)
Checking for IPsec support in kernel [OK]
NETKEY detected, testing for disabled ICMP send_redirects [OK]
NETKEY detected, testing for disabled ICMP accept_redirects [OK]
Checking for RSA private key (/etc/ipsec.secrets) [OK]
Checking that pluto is running [OK]
Two or more interfaces found, checking IP forwarding [OK]
Checking NAT and MASQUERADEing
Checking for 'ip' command [OK]
Checking for 'iptables' command [OK]
Opportunistic Encryption Support [DISABLED]
になればOK。DISABLEDが出た場合は不具合箇所をipsec verifyしながら順次潰す。
4.ファイアウォールの設定
500/udp(IKE)と4500/udp(NAT-traversal)を開口、サーバ側の受け口となるppp0のFOWARDチェインを追加する。
5.ルータの設定
500/udp(IKE)と4500/udp(NAT-traversal)を開口、Gungnirにパケットフォワードが掛かるようにする。
ここまでやってMEDIAS WP N-06CからL2TP PSK IKEv1プロファイルを使用した接続設定でVPN接続が確立、PingとVPCへのリモートデスクトップ接続が正常に動作することを確認した。
「細い3G」なのでレスポンスはそれなりだが、恐ろしく簡単に繋がる。WiMAX経由でLifetouchBも同様に接続ができるはず。あとでやってみよう。
Navigate through the articles | |
![]() |
WindowsXP-Pro VM再構築
![]() |
The comments are owned by the poster. We aren't responsible for their content.
|