CentOS6.6にOpenSwanとxl2tpdでIPsec+L2TP

Openswanの件はこちらを参照して下さい(^^)

目次

■xl2tpdをインストールする

# yum install xl2tpd

=================================================
パッケージ アーキテクチャ バージョン リポジトリー 容量
=================================================
インストールしています:
xl2tpd x86_64 1.3.6-2.el6 epel 130 k
依存性関連でのインストールをします。:
ppp x86_64 2.4.5-10.el6 base 328 k

トランザクションの要約
=================================================
インストール 2 パッケージ

■設定

0)前提

・対抗VPN:RTX1000

・VPN側グローバルアドレス:接続先VPNサーバー

・VPN側プライベートアドレス:192.168.1.1

・ネットワーク:192.168.1.0/24

1)設定ファイル

・/etc/xl2tpd/xl2tpd.conf
;
; This is a minimal sample xl2tpd configuration file for use
; with L2TP over IPsec.
;
; The idea is to provide an L2TP daemon to which remote Windows L2TP/IPsec
; clients connect. In this example, the internal (protected) network
; is 192.168.1.0/24. A special IP range within this network is reserved
; for the remote clients: 192.168.1.128/25
; (i.e. 192.168.1.128 … 192.168.1.254)
;
; The listen-addr parameter can be used if you want to bind the L2TP daemon
; to a specific IP address instead of to all interfaces. For instance,
; you could bind it to the interface of the internal LAN (e.g. 192.168.1.98
; in the example below). Yet another IP address (local ip, e.g. 192.168.1.99)
; will be used by xl2tpd as its address on pppX interfaces.

[global]
; listen-addr = 192.168.1.98
;
; requires openswan-2.5.18 or higher – Also does not yet work in combination
; with kernel mode l2tp as present in linux 2.6.23+
; ipsec saref = yes
; Use refinfo of 22 if using an SAref kernel patch based on openswan 2.6.35 or
; when using any of the SAref kernel patches for kernels up to 2.6.35.
; saref refinfo = 30
;
; force userspace = yes
;
; debug tunnel = yes

; ここはクライアントとする場合は不要みたい
[lns default]
; リモート接続クライアント端末へ割振るIPアドレス範囲を設定
ip range = 192.168.1.101-192.168.1.200
; リモート接続サーバーのIPアドレス
local ip = 192.168.1.1
; chapによる認証情報暗号化を設定
require chap = yes
; popによる平文認証を拒否
refuse pap = yes
; 認証を必須とする設定
require authentication = yes
; リモート接続サーバー名
name = hokutoeng.aa5.netvolante.jp
; pppでバッグモードに設定
ppp debug = yes
; pppオプションファイルの設定
pppoptfile = /etc/ppp/options.xl2tpd
; ビット長チェックを設定
length bit = yes

[lac L2TP1]
lns =接続先VPNサーバー
require chap = yes
refuse pap = yes
require authentication = yes
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd.conn-1
length bit = yes

; 接続の再接続設定
redial = yes
redial timeout = 10
max redials = 6

/var/log/messages に
Maximum retries exceeded for tunnel 37028. Closing
Connection 44740 closed to ・・・
というエラーが出て接続が切れる現象が発生しましたので、再接続設定を追加した。

・/etc/ppp/options.xl2tpd.conn-1
name kumakake
# 認証を設定しません。設定すると接続できない様子です。
noauth
# ハードウェアフロー制御(RTX/CTS)を使用します。
crtscts
# 最大受信単位(MRU)と最大転送単位(MTU)を指定します。
mtu 1258
mru 1258
# 相手側をゲートウェイとするデフォルト経路は追加しません。
nodefaultroute
# UUCP形式のロックファイルを生成します。
lock
# Proxy ARPにより接続して来たホストがローカルネットワークに有る様に見せます。
proxyarp
# ログファイルの保温場所を指定します。
logfile /var/log/xl2tpd.conn-1.log

・/etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client server secret IP addresses
アカウント名 * “パスワード” *

■起動

接続開始
# ipsec auto —up PEER_L2TP
# /etc/rc.d/init.d/xl2tpd start
# echo “c L2TP1” > /var/run/xl2tpd/l2tp-control

しばらくするとインターフェースとして「ppp0」が作成されます。
接続終了
# echo “d L2TP1” > /var/run/xl2tpd/l2tp-control
# /etc/rc.d/init.d/xl2tpd stop
# ipsec auto –down PEER_L2TP

■備考

VPN側のプライベートアドレスがppp0を通るようにするためにルーティングを追加する必要があります。

# route add -net 192.168.1.0 netmask 255.255.255.0 dev ppp0

たとえば、何もしなかったら10分程度で接続が切断されます。

その後、再起動が動き出しはするのですが、接続されたためしがないですorz

その際、接続終了させて、接続開始をする必要があります。

これは、ちょっと不便ですね。。

切断までの時間を伸ばすのは、サーバー側?クライアント側?

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です