27
27

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWSでのリージョン間接続(VPN/VyOS)

Last updated at Posted at 2015-01-05

#AWSリージョン間接続

AWSでリージョン間(例えば東京とオレゴン)で通信を行いたい場合、
AWSではVPCピアリングという機能があるが同一リージョンでしか使用できないため、VPNを構築する必要があります。

今回はVyOSを使用して、インスタンスにENIを付与する。
また、AWSのVPC/RouteTablesを追加しない方法で実現する。

##構成図
aws_vpn.jpg

#前準備

・AmazonLinux 最新版のAMI
→ENIを付与する

・VyOS コミュニティAMIの最新版(Version 1.1.0)
→source dest checkを無効にする
→EIPを付与する

##設定方法

###Tokyo AmazonLinux

・ルーティング設定

ip route add 10.110.0.0/16 dev eth1 via 10.102.0.200 table 100
ip rule add from 10.110.0.0/16 table 100
ip rule add to 10.110.0.0/16 table 100

###Tokyo VyOS

Config

set vpn ipsec ipsec-interfaces interface eth0 

set vpn ipsec ike-group ike lifetime 3600
set vpn ipsec ike-group ike proposal 1 encryption aes128
set vpn ipsec ike-group ike proposal 1 hash sha1

set vpn ipsec esp-group esp lifetime 1800
set vpn ipsec esp-group esp proposal 1 encryption aes128
set vpn ipsec esp-group esp proposal 1 hash sha1

set vpn ipsec site-to-site peer [EIP] authentication mode pre-shared-secret 
set vpn ipsec site-to-site peer [EIP] authentication pre-shared-secret XXXXXXXXXXXXXXXXX

set vpn ipsec site-to-site peer [EIP] authentication id @tokyo-vyos
set vpn ipsec site-to-site peer [EIP] authentication remote-id @oregon-vyos

set vpn ipsec site-to-site peer [EIP] default-esp-group esp
set vpn ipsec site-to-site peer [EIP] ike-group ike
set vpn ipsec site-to-site peer [EIP] local-address [LocalIP]
set vpn ipsec site-to-site peer [EIP] tunnel 1 local prefix 10.102.0.0/16
set vpn ipsec site-to-site peer [EIP] tunnel 1 remote prefix 10.110.0.0/16

###Oregon AmazonLinux

*ルーティング設定

ip route add 10.102.0.0/16 dev eth1 via 10.110.0.100 table 100
ip rule add from 10.102.0.0/16 table 100
ip rule add to 10.102.0.0/16 table 100

###Oregon VyOS

Config

set vpn ipsec ipsec-interfaces interface eth0 

set vpn ipsec ike-group ike lifetime 3600
set vpn ipsec ike-group ike proposal 1 encryption aes128
set vpn ipsec ike-group ike proposal 1 hash sha1

set vpn ipsec esp-group esp lifetime 1800
set vpn ipsec esp-group esp proposal 1 encryption aes128
set vpn ipsec esp-group esp proposal 1 hash sha1

set vpn ipsec site-to-site peer [EIP] authentication mode pre-shared-secret 
set vpn ipsec site-to-site peer [EIP] authentication pre-shared-secret XXXXXXXXXXXXXXXXX

set vpn ipsec site-to-site peer [EIP] authentication id @oregon-vyos
set vpn ipsec site-to-site peer [EIP] authentication remote-id @tokyo-vyos

set vpn ipsec site-to-site peer [EIP] default-esp-group esp
set vpn ipsec site-to-site peer [EIP] ike-group ike
set vpn ipsec site-to-site peer [EIP] local-address [LocalIP]
set vpn ipsec site-to-site peer [EIP] tunnel 1 local prefix 10.110.0.0/16
set vpn ipsec site-to-site peer [EIP] tunnel 1 remote prefix 10.102.0.0/16

#etc...

インスタンスにENIを付与することで、
インターネットへ向ける通信と分離ができたほうが良いかと思い実装してみました。

冗長構成などを考えた時に、AWSCLIでRouteTableを書き換える以外の選択肢もありそうです。

27
27
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
27
27

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?