LoginSignup
1
3

More than 5 years have passed since last update.

AWS VPC リージョン間接続

Last updated at Posted at 2016-01-30

AWS VPCをリージョン間で接続するには。
VyOSにconfigを読みこませる方法やバージョンアップなどはまったところを中心にまとめてみる。

構成例

  • ap-northeast-1とus-west-2のVPCをVPNで繋ぐ
    • VPC CIDRはap-northeast-1が172.16.0.0/16でus-west-2を172.17.0.0/16とした
  • カスタマーゲートウェイ(VyOS)はap-northeast-1に置く
            ap-northeast-1                     us-west-2
| 172.16.0.0/16 |<-->| VyOS |<==INTERNET==>| VPN |<-->| 172.17.0.0/16 |

手順概要

ap-northeast-1

  1. VPC作成
  2. VyOSインスタンス構築
  3. us-west-2のVPN設定が完了したらconfigをVyOSに流し込む

us-west-2

  1. VPC作成
  2. VPN接続設定

手順

VPC作成やVPN接続設定は探せば出てくるのでVyOS構築に関して。

VyOSインスタンス構築

1. AWS MarketplaceのVyOS(v1.1.0)を使ってインスタンス起動する

スクリーンショット 2016-01-30 19.30.28.png

2. ソース/宛先チェックの無効化

スクリーンショット 2016-01-30 19.53.40.png

3. v1.1.0にはVPNのバグがあるらしくv1.0.5を使うとかの記述を見かけ試してみたが一部設定が失敗するために最新のバージョンに上げて対処したら上手くいったのでそれを採用した
  a. add system imageで最新のバージョンをインストールする
  b. インストール後rebootをすれば最新のバージョンに置き換わる
$ slogin VyOSインスタンス
vyos@VyOS-AMI:~$ add system image http://packages.vyos.net/iso/release/1.1.6/vyos-1.1.6-amd64.iso
...
vyos@VyOS-AMI:~$ show system image
The system currently has the following image(s) installed:

   1: VyOS-1.1.6 (default boot)
   2: 1.1.0 (running image)
vyos@VyOS-AMI:~$ reboot

us-west-2のVPNの設定をVyOSに流し込む

1. us-west-2のVPN設定のダウンロードをする

スクリーンショット 2016-01-30 19.38.26.png

2. VyOSに流し込む形式に加工する  
  a. local-addressをVyOSのグローバルIPからプライベートIPに変更する(vpn-xxx.txtを編集する)  
  b. 不要行の削除とvbashで実行できるようにする  
$ cat <<EOF > us-west-2.config
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
configure
EOF
$ grep -vE "^(\!|$)" /path/to/vpn-xxx.txt >> us-west-2.config
$ cat <<EOF >> us-west-2.config
commit
save
exit
EOF
scp us-west-2.config VyOSインスタンス:/tmp/
3. scpしたconfigをvbashで実行する
$ slogin VyOSインスタンス
vyos@VyOS-AMI:~$ vbash /tmp/us-west-2.config

その他

ルートテーブルの設定などを正しく行えば晴れて東京とオレゴンのVPCは結ばれます。

以上

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3