Ubuntu

Ubuntu 12.04 で L2TP/IPsec

その後、サーバーを再構築して上手く行ったので、こっちの方がメモとしては役立つ。<2014/10/12追記>

設定までに色々あったのでメモ。<2012/10/20追記>

INTERNET - [ROUTER] - [Ubuntu12.04/VPNサーバー]
                    |- [その他のPC]
                    |- [その他のPC]
な構成



広告


(1) パッケージのインストール
openswan, xl2tpd を使用する。
以前途中までトライしていたので、パッケージはインストール済みだった。

#> sudo dpkg -l openswan xl2tpd&nbspで確認して次へ。

(2) 各種ファイルの設定

PPTPでの接続はできていたので、ルーティングテーブルなどの設定は済んでいる前提。

/etc/ipsec.conf
# /etc/ipsec.conf – Openswan IPsec configuration file
version 2.0
# basic configuration
config setup
dumpdir=/var/run/pluto/
nat_traversal=yes
virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12,%v4:!xxx.xxx.xxx.xxx/xx
oe=off
protostack=auto

    include /etc/ipsec.d/*.conf

xxx.xxx.xxx.xxx/xxにはローカルネットワークの範囲を記載
例) 192.168.1.0/24

/etc/ipsec.d/l2tp-psk.conf

conn L2TP-PSK-NAT
rightsubnet=vhost:%priv
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=VPNサーバーのIPアドレスを記載
leftnexthop=ルーターのIPアドレスを記載
leftprotoport=17/1701
right=%any
rightprotoport=17/%any
# iOSが削除通知をしてこないことへの対応
dpddelay=10
dpdtimeout=90
dpdaction=clear

/etc/ipsec.secrets

xxx.xxx.xxx.xxx %any: PSK “任意のキー”

xxx.xxx.xxx.xxx にはVPNサーバーのIPアドレスを記載

/etc/xl2tpd/xl2tpd.conf
[global] auth file = /etc/ppp/chap-secrets

[lns default] ip range = xxx.xxx.xxx.101-xxx.xxx.xxx.109&nbspクライアントに割り振られるIPアドレス範囲
local ip = xxx.xxx.xxx.100&nbspクライアントに見せるVPNサーバーのIPアドレス
assign ip = yes
refuse chap = yes
refuse pap = yes
require authentication = yes
name = hogeserver
ppp debug = no
pppoptfile = /etc/ppp/options.l2tpd.lns
length bit = yes

/etc/ppp/chap-secrets
username1 hogehoge “pass phrase 1” xxx.xxx.xxx.108
username2 hogehoge “pass phrase 2” xxx.xxx.xxx.109

hogehoge のところにVPNサーバーのホスト名を入れないとうまく動かなかった。
ユーザーごとにIPアドレスを固定に割り振りたかったので設定している。

/etc/ppp/options.l2tpd.lns
require-mschap-v2
ipcp-accept-local
ipcp-accept-remote
ms-dns xxx.xxx.xxx.xxx&nbspDNSサーバのIPアドレス。うちではルーター
ms-wins xxx.xxx.xxx.xxx&nbspwinsサーバーを動かしている場合に指定
noccp
auth
crtscts
idle 1800
nodefaultroute
debug
lock
proxyarp
connect-delay 5000
logfile /var/log/xl2tpd.l2tp-ipsec.log

(3) Firewallの設定
500/udp
4500/udp
1701/udp
を使用するので開放。

多分、espというプロトコルも使う。2013/07/26追記
$ sudo ufw allow proto esp from any

(4) ルーターのNAPT設定
使用中のRT-200KIは「VPNパススルー設定」という便利機能を持っている。
だが、PPTPはうまく動作するが、L2TP/IPsecはうまく動作しない。
(結果的にはこれがラスボスで、超手間取った)

そのため、NAPT設定で
500/udp
4500/udp
1701/udp
をVPNサーバーに向けるようにした。

2012/10/16追記
セキュリティアップデートをしたらカーネル更新あり。
再起動したところ、ipsecが動作しない。

#> sudo ipsec verify
でみてみるとplutoがうまく動作していないが、原因不明。

設定の修正が必要だと思われるが、とりあえずは起動後に
#> sudo service ipsec restart
#> sudo service xl2tpd restart
を実行して回避。

広告

コメントはこちらから お気軽にどうぞ ~ 投稿に関するご意見・感想・他