YAMAHA の RTX1000 を使って自宅を AWS の VPC と繋いでみたよ

お手頃なお値段でご自宅でも show config できる時代となりました

RTX1000 といえば「ASCII.jp:楽器メーカーが作った傑作VPNルータ「RTX1000」 (1/3)|歴史を変えたこの1台」なわけですが流石に時は流れて「http://auctions.search.yahoo.co.jp/search?ei=UTF-8&p=RTX1000&auccat=0&tab_ex=commerce&s1=cbids&o1=a&slider=0」を見ると 2000 円もあれば送料込みで自宅にやってくるくらいの手軽な存在になっています。というわけで手元に RTX1000 がやってきました。こんにちは!

つわけで RTX1000AWSVPC を繋いでみようと思うんですが、RTX1100 のことなら巷に沢山溢れているので Management Console の作業のことなんかも含め「vpc rtx1100 - Google 検索」でおググりあそばせ。

シリアル <-> USB が無くても何とかなるよ

当然のように初期化されてやってきた RTX1000 には IP address が振られていないので telnet で繋ぐことができません。シリアルケーブルがあれば問題ないわけですが、そういえば個人所有したことがなかったので家にはありません。残念。そんなときの RARP です。Ubuntu なら RARP もいちころです、って「http://hitaki.net/diary/20070115.html」に書いてありました。

# aptitude install rarpd
# cat > /etc/ethers
xx:xx:xx:xx:xx:xx 192.168.100.1
# /etc/init.d/rarpd restart

で、パソコンと RTX1000 の lan1 を繋いで RTX1000 を起動してあげれば

$ telnet 192.168.100.1
Trying 192.168.100.1...
Connected to 192.168.100.1.
Escape character is '^]'.

Password: 

RTX1000 BootROM Ver. 1.04

RTX1000 Rev.8.01.29 (Fri Apr 15 11:50:44 2011)
  Copyright (c) 1994-2011 Yamaha Corporation.
  Copyright (c) 1991-1997 Regents of the University of California.
  Copyright (c) 1995-1996 Jean-loup Gailly and Mark Adler.
  Copyright (c) 1998-2000 Tokyo Institute of Technology.
  Copyright (c) 2000 Japan Advanced Institute of Science and Technology, HOKURIKU.
  Copyright (c) 2002 RSA Security Inc. All rights reserved.
xx:xx:xx:xx:xx:xx, xx:xx:xx:xx:xx:xx, xx:xx:xx:xx:xx:xx, 
Memory 16Mbytes, 3LAN, 1BRI
> 

いぇ〜い、ってほんとは firmware の update をこの次にしたんだけど、省略。TFTP するだけよ。で、とりあえず

> administrator
Passwd:
# console character ascii 
# ip lan1 address 192.168.100.1/24
# save
Saving ... CONFIG0 Done .

これで再起動しても大丈夫。用済みの rarpd はさようなら。

# aptitude purge rarpd

インターネットに繋がっていないと単なる青い箱だ

YAMAHA はサポートが充実しすぎていて「PPP over Ethernet (PPPoE)」を見たらあっという間にインターネットにも繋がってしまいます。フレッツ光が来ているのでちょちょいとインターネットに繋がってしまいました。

ip route default gateway pp 1
pp select 1
 pp always-on on
 pppoe use lan2
 pppoe auto disconnect off
 pp auth accept pap chap
 pp auth myname ID PASSWD
 ppp lcp mru on 1454
 ppp ipcp ipaddress on
 ppp ipcp msext on
 ppp ccp type none
 ip pp mtu 1454
 ip pp nat descriptor 1
 pp enable 1
nat descriptor type 1 masquerade

で、RTX1000 で見てみると

# show status pp 1
PP[01]:
Current PPPoE session status is Connected.
Access Concentrator: BAS
8 seconds  connection.
Received: 106 packets [24188 octets]  Load: 0.0%
Transmitted: 156 packets [41032 octets]  Load: 0.0%
PPP Cofigure Options
    LCP Local: Magic-Number MRU, Remote: CHAP Magic-Number MRU
(略)

繋がりました。ついでに DHCP サーバとかにもしておきましょう。

dhcp service server
dhcp scope 1 192.168.100.128-192.168.100.254/24
dns server pp 1
dns private address spoof on

これでブロードバンドルータとしてはひとまず完成。

VPN ルータを VPN で繋ぐぜ

でもその繋ぎ先が今回 AWSVPCVPN Connection となるわけです。どーするかっつーと、

  • Management Console から Customer Gateway を作る (RTX1000 に振られてる Global IP address を入力)
  • Management Console から Virtual Private Gateway を作る
  • Management Console から VPN Connection を作る (上の 2 つの Gateway を指定する)

で、できあがった VPN Connections を選んで Download Configuration から YAMAHA 用の設定ファイルをダウンロードしました。中身はこんな感じで長いです。

(2012/Feb/12 追記: この keepalive の設定は間違いです。死活監視が失敗します。詳細は id:blooper:20120212)

$ cat ~/Downloads/vpn-babf15bb.txt 
# Amazon Web Services
# Virtual Private Cloud

# AWS utilizes unique identifiers to manage the configuration of 
# a VPN Connection. Each VPN Connection is assigned an identifier and is 
# associated with two other identifiers, namely the 
# Customer Gateway Identifier and Virtual Private Gateway Identifier.
#
# Your VPN Connection ID                    : vpn-babf15bb
# Your Virtual Private Gateway ID           : vgw-a7bf15a6
# Your Customer Gateway ID                  : cgw-d2be14d3
#
#
# This configuration consists of two tunnels. Both tunnels must be 
# configured on your Customer Gateway.
(略)

このファイルは RTX1200 用らしくって全てのコマンドが上手く通るわけではないのですが

@@ -66,7 +66,7 @@
 # This option enables IPSec Dead Peer Detection, which causes periodic
 # messages to be sent to ensure a Security Association remains operational.
 
-        ipsec ike keepalive use 1 on dpd 10 3
+        ipsec ike keepalive use 1 on heartbeat 10 3
 
 # --------------------------------------------------------------------------------
 # #3: Tunnel Interface Configuration
@@ -111,7 +111,7 @@
 #
        bgp use on
        bgp autonomous-system 6500
-       bgp neighbor 1 10124 169.254.252.1 hold-time=30 local-address=169.254.252.2
+       bgp neighbor 1 10124 169.254.252.1 hold-time=30
 
 # To advertise additional prefixes to Amazon VPC, copy the 'network' statement and 
 # identify the prefix you wish to advertise. Make sure the 
@@ -171,7 +171,7 @@
 # This option enables IPSec Dead Peer Detection, which causes periodic
 # messages to be sent to ensure a Security Association remains operational.
 
-        ipsec ike keepalive use 2 on dpd 10 3
+        ipsec ike keepalive use 2 on heartbeat 10 3
 
 # --------------------------------------------------------------------------------
 # #3: Tunnel Interface Configuration
@@ -216,7 +216,7 @@
 #
        bgp use on
        bgp autonomous-system 6500
-       bgp neighbor 2 10124 169.254.252.5 hold-time=30 local-address=169.254.252.6
+       bgp neighbor 2 10124 169.254.252.5 hold-time=30
 
 # To advertise additional prefixes to Amazon VPC, copy the 'network' statement and 
 # identify the prefix you wish to advertise. Make sure the 

これくらいの編集で通るようになります、というか keepalive の方は行ごと消してしまっても問題は無いみたい。あと、IPSec を受けるのに masquerade の設定が必要なので以下も追加します:

nat descriptor masquerade static 1 1 192.168.100.1 udp 500
nat descriptor masquerade static 1 2 192.168.100.1 esp

結果、追加の設定はこんな感じ:

tunnel select 1
 ipsec tunnel 201
  ipsec sa policy 201 1 esp aes-cbc sha-hmac
  ipsec ike duration ipsec-sa 1 3600
  ipsec ike encryption 1 aes-cbc
  ipsec ike group 1 modp1024
  ipsec ike hash 1 sha
  ipsec ike keepalive use 1 on heartbeat 10 3
  ipsec ike local address 1 xxx.yyy.zzz.www
  ipsec ike pfs 1 on
  ipsec ike pre-shared-key 1 *
  ipsec ike remote address 1 27.0.1.16
 ipsec tunnel outer df-bit clear
 ip tunnel address 169.254.252.2/30
 ip tunnel remote address 169.254.252.1
 ip tunnel tcp mss limit 1396
 tunnel enable 1
tunnel select 2
 ipsec tunnel 202
  ipsec sa policy 202 2 esp aes-cbc sha-hmac
  ipsec ike duration ipsec-sa 2 3600
  ipsec ike encryption 2 aes-cbc
  ipsec ike group 2 modp1024
  ipsec ike hash 2 sha
  ipsec ike keepalive use 2 on heartbeat 10 3
  ipsec ike local address 2 xxx.yyy.zzz.www
  ipsec ike pfs 2 on
  ipsec ike pre-shared-key 2 *
  ipsec ike remote address 2 27.0.1.144
 ipsec tunnel outer df-bit clear
 ip tunnel address 169.254.252.6/30
 ip tunnel remote address 169.254.252.5
 tunnel enable 2
nat descriptor address outer 1 ipcp
nat descriptor address inner 1 192.168.100.1-192.168.100.254
nat descriptor masquerade static 1 1 192.168.100.1 udp 500
nat descriptor masquerade static 1 2 192.168.100.1 esp
bgp use on
bgp autonomous-system 6500
bgp neighbor 1 10124 169.254.252.1 hold-time=30
bgp neighbor 2 10124 169.254.252.5 hold-time=30
bgp import filter 1 equal 192.168.100.0/24
bgp import 10124 static filter 1
ipsec auto refresh on

bgp configure refresh # BGP の設定変更したらこれを実行する


繋がりました!! でもまだ VPC と Virtual Private Gateway を繋いでいないので VPC の欄が空っぽです。

VPN Connection を VPC と繋いで VPC 内のプライベートなインスタンスにアクセス

RTX1000 と Virtual Private Gateway は繋がったのですが、その Virtual Private Gateway がまだ誰とも繋がっていません。悲しいです。繋ぎましょう。

  • VPC 10.0.0.0/16 を作る
  • Virtual Private GatewayVPC に attach する
  • VPC の中に Subnet 10.0.0.0/24 を作る
  • VPC の Main Route Table に「192.168.100.0/24 を Virtual Private Gateway に route する」というエントリを追加する (本当は別に Route Table 作るべきか?)

これで VPCVPN Connection 経由で RTX1000 と繋がってるはずなので、暫く待つと

# show status bgp neighbor 169.254.252.1 received-routes 
Total routes: 1
*: valid route
  Network            Next Hop        Metric LocPrf Path
* 10.0.0.0/16        169.254.252.1                 10124 IGP
> show status bgp neighbor 169.254.252.1 advertised-routes 
Total routes: 1
*: valid route
  Network            Next Hop        Metric LocPrf Path
* 192.168.100.0/24    192.168.100.1         0        IGP

こんな感じで route table が受信できてることが確認できます。

実際繋ぐぞ!

  • VPC 内に SSH ができる Security Group を作成する
  • Subnet 内にインスタンスを作成する、Security Group は上のやつ

てな感じで作って繋いだりできました。

$ slogin 10.0.0.202 -i ~/Downloads/RTX1000.pem -l ec2-user
Last login: Tue Feb  7 16:38:59 2012 from 192.168.100.2

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

See /usr/share/doc/system-release/ for latest release notes.
There are 23 security update(s) out of 32 total update(s) available
[ec2-user@ip-10-0-0-202 ~]$

ようこそプライベートサブネットへ!

どのくらいの速度で繋がるのか気になるところ

(2012/Feb/12 追記: keepalive の設定のせいで packet loss しています。詳細・修正は id:blooper:20120212)

RTX1000 は AES をソフトウェアで処理していて中々残念です。一方 VPC は 3DES とか受け入れてくれないマッチョな体格です。ここが RTX1100 になると AES もハードで処理してくれてちょっぱやということになるらしいのですが。

つーわけで iperf -s に iperf -c を up/down でやってみました。

単位は Mbps なので、3〜4Mbps しか出ていない悲しい状況です。っつーか ping 打つと packet loss してる:

100 packets transmitted, 85 received, 15% packet loss, time 99227ms
rtt min/avg/max/mdev = 7.419/12.079/72.995/8.752 ms

なんか色々ダメかも。まぁいいか! 繋がったし!