VPNルーターでL2TP/IPsecでVPN接続
前回の記事で、ルーターへのPPPoE接続設定が完了し、インターネットへの接続が可能となりました。
3回目の今回は、PPTP、または、L2TP/IPsecプロトコルを使用したVPN接続ができるように、ルーターへ設定を追加します。
- 1回目:VPNルーター導入時の初期設定
- 2回目:VPNルーターでPPPoE接続
- 3回目:VPNルーターでL2TP/IPsecでVPN接続
- 4回目:VPNルーターのパケットフィルタ設定
- 5回目:VPNルーターのWeb Assistance機能を使う
- 6回目:VPNルーターのログをLinuxサーバで記録
- 7回目:VPNルーターでSNMPトラップを使う
- 番外編1:iPhoneでRTX1100のVPN接続を使う
- 番外編2:iPhoneでPacketiX VPN Serverを使う
外部のスマートフォン(iPphoneやAndroid端末)から、VPNルーターへ接続し、ローカルのネットワークに接続します。IPsecを使用することで、データは暗号化され、機密性や完全性が確保されますので、安心して接続することができます。
<RTX1100によるVPN接続のメリット>
・設置が完了してしまえば、運用が楽
・データは、暗号化されているので安心・安全
・サーバと比較して電気代が安い
VPN接続端末の設定情報
VPN接続を許可する端末(クライアント)は、2ユーザとします。必要に応じて追加します。
iPhoneやAndroid端末は、NATトラバーサルを利用したL2TP/IPsecでVPN接続を行います。
詳細はこちらの YAMAHA L2TP/IPsecドキュメントページ を参照ください。
1) L2TP/PPTPクライアント#1情報
- IPアドレス : 不定
- IPsec事前共有鍵 : ANK大文字・小文字と数字を組み合わせた判りにくい文字列
- PPP認証のユーザー名 : ユーザ名1
- PPP認証のパスワード : パスワード1
2) L2TP/PPTPクライアント#2情報
- IPアドレス : 不定
- IPsec事前共有鍵 : ANK大文字・小文字と数字を組み合わせた判りにくい文字列
- PPP認証のユーザー名 : ユーザ名2
- PPP認証のパスワード : パスワード2
3) VPNルーターの設定
- VPNルータのグローバルアドレス : 61.206.118.xxx
- VPNルータのプライベートアドレス : 192.168.0.1
- L2TPクライアントへ配布するIPアドレス範囲 : 192.168.0.220 -192.168.0.229/24
4) L2TPに関連した設定
- L2TPトンネル認証 : 無し
- L2TPキープアライブ : 使用する インターバル10秒 ダウン検出までのカウント3回
- L2TPキープアライブのログ出力 : 有り
- L2TPトンネルの切断タイマ : 切断タイマを設定しない
- L2TPのコネクション制御に関するログ出力 : 有り
VPNルーター(RTX1100)のL2TP/IPsec設定
RTX1100に、PPTPとL2TP/IPsecの設定を行うと、リモートアクセスVPNのサーバとして動作するようになります。iPhoneやAndroid端末(EVO3D)では、NATトラバーサルを利用したVPN接続を行うことができます。
※NATトラバーサルは、互換性の問題があり、端末によっては接続できない場合もある模様です。
RTX1100では、WindowsパソコンからVPN接続(L2TP/IPsec)する場合は、専用のVPNクライアントソフトウェアをWindowsパソコンへインストールする必要があります。(有償で、1ライセンス10,290円)
詳細はこちらの ヤマハのWebサイト -VPNクライアントソフトウェア(YMS-VPN7) を参照ください。
RTX1100へ経路設定を行います。
[RTX]# ip lan1 proxyarp on
L2TPとPPTP接続を受け入れるための設定(同時接続は2人)を行います。
[RTX]# pp select anonymous [RTX]anonymous# pp bind tunnel1-tunnel4 [RTX]anonymous# pp auth request mschap-v2 [RTX]anonymous# pp auth username ユーザ名1 パスワード1 [RTX]anonymous# pp auth username ユーザ名2 パスワード2 [RTX]anonymous# ppp ipcp ipaddress on [RTX]anonymous# ppp ipcp msext on [RTX]anonymous# ip pp remote address pool 192.168.0.220-192.168.0.229 [RTX]anonymous# ip pp mtu 1258 [RTX]anonymous# pp enable anonymous
L2TP接続で使用するトンネル1を設定する。
[RTX]# tunnel select 1 [RTX]tunnel1# tunnel encapsulation l2tp [RTX]tunnel1# ipsec tunnel 101 [RTX]tunnel1# ipsec sa policy 101 1 esp aes-cbc sha-hmac [RTX]tunnel1# ipsec ike keepalive use 1 off [RTX]tunnel1# ipsec ike local address 1 192.168.0.1 [RTX]tunnel1# ipsec ike nat-traversal 1 on [RTX]tunnel1# ipsec ike pre-shared-key 1 text [IPsec事前共有鍵] [RTX]tunnel1# ipsec ike remote address 1 any [RTX]tunnel1# l2tp tunnel disconnect time off [RTX]tunnel1# l2tp keepalive use on 10 3 [RTX]tunnel1# l2tp keepalive log on [RTX]tunnel1# l2tp syslog on [RTX]tunnel1# ip tunnel tcp mss limit auto [RTX]tunnel1# tunnel enable 1
L2TP接続で使用するトンネル2を設定する。
[RTX]# tunnel select 2 [RTX]tunnel2# tunnel encapsulation l2tp [RTX]tunnel2# ipsec tunnel 102 [RTX]tunnel2# ipsec sa policy 102 2 esp aes-cbc sha-hmac [RTX]tunnel2# ipsec ike keepalive use 2 off [RTX]tunnel2# ipsec ike local address 2 192.168.0.1 [RTX]tunnel2# ipsec ike nat-traversal 2 on [RTX]tunnel2# ipsec ike pre-shared-key 2 text [IPsec事前共有鍵] [RTX]tunnel2# ipsec ike remote address 2 any [RTX]tunnel2# l2tp tunnel disconnect time off [RTX]tunnel2# l2tp keepalive use on 10 3 [RTX]tunnel2# l2tp keepalive log on [RTX]tunnel2# l2tp syslog on [RTX]tunnel2# ip tunnel tcp mss limit auto [RTX]tunnel2# tunnel enable 2
PPTP接続で使用するトンネル3を設定します。
[RTX]# tunnel select 3 [RTX]tunnel3# tunnel encapsulation pptp [RTX]tunnel3# pptp tunnel disconnect time off [RTX]tunnel3# tunnel enable 3 [RTX]tunnel3# tunnel select none
PPTP接続で使用するトンネル4を設定します。
[RTX]# tunnel select 4 [RTX]tunnel4# tunnel encapsulation pptp [RTX]tunnel4# pptp tunnel disconnect time off [RTX]tunnel4# tunnel enable 4 [RTX]tunnel4# tunnel select none
NATを設定します。
[RTX]# nat descriptor masquerade static 1 3 192.168.0.1 esp [RTX]# nat descriptor masquerade static 1 4 192.168.0.1 udp 500 [RTX]# nat descriptor masquerade static 1 5 192.168.0.1 udp 4500 [RTX]# nat descriptor masquerade static 1 6 192.168.0.1 gre [RTX]# nat descriptor masquerade static 1 7 192.168.0.1 tcp 1723
IPsecのトランスポートモードを設定します。
[RTX]# ipsec transport 1 101 udp 1701 [RTX]# ipsec transport 2 102 udp 1701 [RTX]# ipsec auto refresh on
L2TPとPPTPサービスをONします。
[RTX]# l2tp service on [RTX]# pptp service on
動作確認のために、syslogにnoticeとDebug情報の出力を行うようにします。
[RTX]# syslog notice on [RTX]# syslog debug on
ファイアウォール(フィルタ)設定を変更し、VPN接続時のパケットを許可するようにします。
[RTX]# ip filter xx pass * 192.168.0.1 gre * * [RTX]# ip filter xx pass * 192.168.0.1 tcp * 1723 [RTX]# ip filter xx pass * 192.168.0.1 esp * * [RTX]# ip filter xx pass * 192.168.0.1 udp * 500 [RTX]# ip filter xx pass * 192.168.0.1 udp * 1701 [RTX]# ip filter xx pass * 192.168.0.1 udp * 4500
最後に、設定情報を保存して終了します。
[RTX]# save セーブ中... CONFIG0 終了
PPTPによるVPN接続時の動作確認
VPN接続時の簡単な動作確認手順を示します。
接続試験は、SoftBankのスマートフォン(iPhone4)を使用して、3G携帯網から接続します。
1) 最初に、経路情報を確認します。
[RTX]# show ip route 宛先ネットワーク ゲートウェイ インタフェース 種別 付加情報 default - PP[01] static 61.206.118.0/24 192.168.1.1 LAN2 static 192.168.0.0/24 192.168.0.1 LAN1 implicit 192.168.0.220/32 - PP[ANONYMOUS01] temporary 192.168.1.0/24 192.168.1.254 LAN2 implicit (以降は省略)
2) 次に、PPTP情報を確認します。
[RTX]# show status pp anonymous ANONYMOUS[01]: PPTPセッションは接続されています 接続相手: 通信時間: 2分26秒 受信: 69 パケット [15438 オクテット] 送信: 57 パケット [13950 オクテット] PPPオプション LCP Local: CHAP Magic-Number MRU, Remote: Magic-Number ACCM IPCP Local: IP-Address, Remote: IP-Address Primary-DNS(192.168.0.1) Secondary-DNS(203.141.128.35) PP IP Address Local: 192.168.0.1, Remote: 192.168.0.220 IPV6CP Local: Interface-ID, Remote: Interface-ID PP Interface-ID Local:02a0defffe30e2e6, Remote:18f0db64e9f4e667 CCP: None 受けとったUserId: ユーザ名1
3) 次に、PPTPの詳細情報を確認します。
[RTX]# show status pptp ------------------- PPTP INFORMATION ------------------- Number of control table using Tunnel Control: 1, Call Control: 1, GRE Control: 1 TUNNEL[03] Information TCP status: established PPTP Call status: established PPTP Service type: server PAC status: established Remote IP Address: 126.214.68.57 Local IP Address: 192.168.0.1 GRE status: open Transmitted: 66 packets [14908 octets] Received: 83 packets [17291 octets] Transmit left: 0 packet Transmitted ack number: 83 times Transmit ready timeout: 149 times Received ack number: 20 times Received invalid sequence: 0 packet Received delayed sequence: 0 packet Received invalid ack: 0 packet Received delayed ack: 0 packet Received out of sequence: 2 packets Received no data packet: 0 packet
4) 最後に、show logコマンドで、VPN接続時のDebugログを確認します。
2012/04/20 15:10:34 192.168.0.1 TUNNEL[03] PPTP connection is established: 126.214.68.57 2012/04/20 15:10:35 192.168.0.1 PP[ANONYMOUS01] PPTP Connect 2012/04/20 15:10:35 192.168.0.1 PP[ANONYMOUS01] SEND LCP ConfReq in STARTING 2012/04/20 15:10:35 192.168.0.1 ff 03 c0 21 01 01 00 13 01 04 07 00 03 05 c2 23 2012/04/20 15:10:35 192.168.0.1 81 05 06 21 7a 26 2a (略) 2012/04/20 15:10:40 192.168.0.1 PP[ANONYMOUS01] RECV IPCP ConfReq in REQSENT 2012/04/20 15:10:40 192.168.0.1 ff 03 80 21 01 02 00 16 03 06 c0 a8 00 dc 81 06 2012/04/20 15:10:40 192.168.0.1 c0 a8 00 01 83 06 cb 8d 80 23 2012/04/20 15:10:40 192.168.0.1 PP[ANONYMOUS01] SEND IPCP ConfAck in REQSENT 2012/04/20 15:10:40 192.168.0.1 ff 03 80 21 02 02 00 16 03 06 c0 a8 00 dc 81 06 2012/04/20 15:10:40 192.168.0.1 c0 a8 00 01 83 06 cb 8d 80 23 2012/04/20 15:10:41 192.168.0.1 PP[ANONYMOUS01] RECV IPCP ConfAck in ACKSENT 2012/04/20 15:10:41 192.168.0.1 ff 03 80 21 02 02 00 0a 03 06 c0 a8 00 01 2012/04/20 15:10:41 192.168.0.1 PP[ANONYMOUS01] PPP/IPCP up (Local: 192.168.0.1, Remote: 192.168.0.220) 2012/04/20 15:10:41 192.168.0.1 PP[ANONYMOUS01] Local PP IP address 192.168.0.1 2012/04/20 15:10:41 192.168.0.1 PP[ANONYMOUS01] Remote PP IP address 192.168.0.220
L2TP/IPsecによるVPN接続時の動作確認
VPN接続時の簡単な動作確認手順を示します。
接続試験は、auのスマートフォン(EVO3D)を使用して、3G携帯網、または、WiMAX網から接続します。
詳細はこちらの トラブルシューティング – VPN接続できない を参照ください。
1) 最初に、プロバイダとの接続状況を確認します。
[RTX]# show status pp 1 PP[01]: 説明: PPPoEセッションは接続されています 接続相手: e10gmoizm-xxxxxxxx 通信時間: 1日19時間18分40秒 受信: 694921 パケット [646452709 オクテット] 負荷: 0.0% 送信: 576680 パケット [105771692 オクテット] 負荷: 0.0% PPPオプション LCP Local: Magic-Number MRU, Remote: CHAP Magic-Number MRU IPCP Local: Primary-DNS(203.138.71.154) Secondary-DNS(210.150.255.66), Remo te: IP-Address PP IP Address Local: 61.206.118.47, Remote: 210.165.249.215 CCP: None
2) 次に、NATディスクリプタの状態を確認します。
[RTX]# show nat descriptor address 参照NATディスクリプタ : 1, 適用インタフェース : PP[01](1) Masqueradeテーブル 外側アドレス: ipcp/61.206.118.xxx ポート範囲=60000-64095 21個使用中 プロトコル 内側アドレス 宛先 マスカレード TTL(秒) TCP 192.168.0.26.52882 202.229.2.105.80 63674 36 (省略) TCP 192.168.0.1.1723 *.*.*.*.* 1723 static PPTP 192.168.0.1.* *.*.*.*.* * static UDP 192.168.0.1.4500 *.*.*.*.* 4500 static UDP 192.168.0.1.500 *.*.*.*.* 500 static ESP 192.168.0.1.* *.*.*.*.* * static --------------------- - --- 有効なNATディスクリプタテーブルが1個ありました
3) 次に、経路情報を確認します。
[RTX]# show ip route 宛先ネットワーク ゲートウェイ インタフェース 種別 付加情報 default - PP[01] static 61.206.118.0/24 192.168.1.1 LAN2 static 192.168.0.0/24 192.168.0.1 LAN1 implicit 192.168.1.0/24 192.168.1.254 LAN2 implicit (以降は省略)
4) 次に、SA情報を確認します。
[RTX]# show ipsec sa sa sgw connection dir life[s] remote-id -------------------------------------------------------------------------- 1 1 isakmp - 27536 182.249.46.195 2 1 tra[001]esp send 27536 182.249.46.195 3 1 tra[001]esp recv 27536 182.249.46.195 SA[1] 寿命: 27536秒 自分側の識別子: 192.168.0.1 相手側の識別子: 182.249.46.195 プロトコル: IKE NATトラバーサル: あり, キープアライブ: なし SPI: de e1 3d 5e 47 e1 0a 5c a6 68 51 bd b6 13 2e 90 鍵 : ** ** ** ** ** (confidential) ** ** ** ** ** ---------------------------------------------------- SA[2] 寿命: 27536秒 自分側の識別子: 192.168.0.1 相手側の識別子: 182.249.46.195 送受信方向: 送信 プロトコル: ESP (モード: transport) アルゴリズム: AES-CBC (認証: HMAC-SHA) SPI: 0b a2 7b 09 鍵 : ** ** ** ** ** (confidential) ** ** ** ** ** ---------------------------------------------------- SA[3] 寿命: 27536秒 自分側の識別子: 192.168.0.1 相手側の識別子: 182.249.46.195 送受信方向: 受信 プロトコル: ESP (モード: transport) アルゴリズム: AES-CBC (認証: HMAC-SHA) SPI: 12 23 cf 07 鍵 : ** ** ** ** ** (confidential) ** ** ** ** ** ----------------------------------------------------
5) 次に、L2TPの接続状況を確認します。
LocalがRTX1100でRemoteが端末のプライベートアドレスとなります。
[RTX]# show status pp anonymous ANONYMOUS[01]: L2TPセッションは接続されています 接続相手: anonymous 通信時間: 22分48秒 受信: 113 パケット [22317 オクテット] 送信: 59 パケット [18196 オクテット] PPPオプション LCP Local: CHAP Magic-Number MRU, Remote: Magic-Number MRU ACCM IPCP Local: IP-Address, Remote: IP-Address Primary-DNS(192.168.0.1) Secondary-DNS(203.141.xxx.xxx) PP IP Address Local: 192.168.0.1, Remote: 192.168.0.220 CCP: None 受けとったUserId: ユーザ名1
6) 次に、L2TPの詳細状況を確認します。
[RTX]# show status l2tp ------------------- L2TP INFORMATION ------------------- Number of control table using Tunnel Control: 1, Session Control: 1 TUNNEL[1] Information Tunnel State: established Local Tunnel ID: 41736 Remote Tunnel ID: 40471 Local IP Address: 192.168.0.1 Remote IP Address: 182.249.46.195 Local Src Port: 1701 Remote Src Port: 38644 PP bind: ANONYMOUS[1] Vendor: Hostname: anonymous Tunnel has 1 session. Session Information Session State: established Local Session ID: 62649 Remote Session ID: 12396 Received: 113 packets [22317 octets] Transmitted: 59 packets [18196 octets]
7) 最後に、show logコマンドで、VPN接続時のDebugログを確認します。
[RTX]# show log 2012/04/20 20:54:01: [L2TP] recv message AVPs : 2012/04/20 20:54:01: [L2TP] (0)message type SCCRQ 2012/04/20 20:54:01: [L2TP] (2)protocol version 1 revision 0 2012/04/20 20:54:01: [L2TP] (7)hostname anonymous 2012/04/20 20:54:01: [L2TP] (3)framing capability Abit:1 Sbit:0 2012/04/20 20:54:01: [L2TP] (9)assigned tunnel id 38733 2012/04/20 20:54:01: [L2TP] (10)receive window size 1 2012/04/20 20:54:01: [L2TP] recv SCCRQ in idle from 182.249.46.195 2012/04/20 20:54:01: [L2TP] TUNNEL[1] connected from 182.249.46.195 2012/04/20 20:54:01: [L2TP] send message AVPs : 2012/04/20 20:54:01: [L2TP] set (0)message type SCCRP 2012/04/20 20:54:01: [L2TP] set (2)protocol version 1 revision 0 2012/04/20 20:54:01: [L2TP] set (3)framing capability sync 2012/04/20 20:54:01: [L2TP] set (4)bearer capability 0 2012/04/20 20:54:01: [L2TP] set (6)firmware revision 0x500 2012/04/20 20:54:01: [L2TP] set (7)hostname RTX1100 2012/04/20 20:54:01: [L2TP] set (8)vendorname YAMAHA Corporation 2012/04/20 20:54:01: [L2TP] set (9)assigned tunnel id 46121 2012/04/20 20:54:01: [L2TP] set (10)receive window size 1 2012/04/20 20:54:01: [L2TP] send SCCRP to 182.249.46.195 2012/04/20 20:54:02: [L2TP] recv message AVPs : 2012/04/20 20:54:02: [L2TP] (0)message type SCCCN 2012/04/20 20:54:02: [L2TP] recv SCCCN in wait_ctl_conn from 182.249.46.195 2012/04/20 20:54:02: [L2TP] send ZLB to 182.249.46.195 2012/04/20 20:54:02: [L2TP] TUNNEL[1] tunnel 46121 established 2012/04/20 20:54:02: [L2TP] recv message AVPs : 2012/04/20 20:54:02: [L2TP] (0)message type ICRQ 2012/04/20 20:54:02: [L2TP] (14)assigned session id 13597 2012/04/20 20:54:02: [L2TP] (15)call serial number 3683578893 2012/04/20 20:54:02: [L2TP] recv ICRQ in idle from 182.249.46.195 2012/04/20 20:54:02: [L2TP] send message AVPs : 2012/04/20 20:54:02: [L2TP] set (0)message type ICRP 2012/04/20 20:54:02: [L2TP] set (14)assigned session id 43561 2012/04/20 20:54:02: [L2TP] send ICRP to 182.249.46.195 2012/04/20 20:54:02: [L2TP] recv message AVPs : 2012/04/20 20:54:02: [L2TP] (0)message type ICCN 2012/04/20 20:54:02: [L2TP] (24)tx connect speed 100Mbit/s 2012/04/20 20:54:02: [L2TP] (19)framing type 3 2012/04/20 20:54:02: [L2TP] recv ICCN in wait_connect from 182.249.46.195 2012/04/20 20:54:02: [L2TP] send ZLB to 182.249.46.195 2012/04/20 20:54:02: [L2TP] TUNNEL[1] session 43561 established
以上で、「VPNルーターでL2TP/IPsecでVPN接続」を終了します。