ConohaとアプリクラウドをOpenVPNを用いてsite-to-site接続



目的:

conohaのクローズドVMとアプリクラウドのクローズドVMをVPN経由で疎通確認する

アプリクラウドはVMは全てロードバランサ配下に存在しますが、
openvpnであっさりと接続出来ました。


構成図:


パラメータ:IPアドレス

Conoha:

ローカルネットワーク: 10.0.0.0/24
グローバルIPネットワーク: 203.0.113.0/24
VPN VM eth0: 203.0.113.100
VPN VM eth1: 10.0.0.1
クローズドVM eth1: 10.0.0.2

アプリクラウド:

ロードバランサ接続ネットワーク: 10.110.1.0/24
クローズドネットワーク: 10.110.2.0/24
ロードバランサ VIP :198.51.100.10
ロードバランサ NAT IP: 198.51.100.5
VPN VM eth0: 10.110.1.11
VPN VM eth1: 10.110.2.11
クローズドVM eth1: 10.110.2.100


コンパネの作業

アプリプラウド -ロードバランサ設定

コンパネで以下BINDを作成しておく
PORT: UDP
BIND: 198.51.100.10:21001 <-->10.110.1.11:21001

Conoha -ローカルネットワーク作成

ローカルネットワークを作成してVPN VMとクローズドVMにアタッチしておく


OSの設定と作業

アプリクラウド側-VPN用VM作業

パッケージインストール

yum -y install openvpn.x86_64

key作成

openvpn --genkey --secret /etc/openvpn/vpn.key

keyをconoha vmにコピー

scp /etc/openvpn/vpn.key [email protected]:/etc/openvpn/

設定ファイル作成

/etc/openvpn/server.conf
port 21001
proto udp
dev tun
remote 203.0.113.100
local 10.110.1.11
float
ifconfig 10.0.8.1 10.0.8.2
persist-tun
persist-local-ip
comp-lzo
secret /etc/openvpn/vpn.key
route 10.0.0.0 255.255.255.0
user nobody
group nobody
verb 1
keepalive 10 60

router用にパケット転送設定

vim /etc/sysctl.conf
変更:
net.ipv4.ip_forward = 1
追加:
net.core.xfrm_larval_drop = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.eth0.send_redirects = 0
net.ipv4.conf.eth1.send_redirects = 0
net.ipv4.conf.lo.send_redirects = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.eth0.accept_redirects = 0
net.ipv4.conf.eth1.accept_redirects = 0
net.ipv4.conf.lo.accept_redirects = 0
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.eth0.rp_filter = 0
net.ipv4.conf.lo.rp_filter = 0

sysctl -p

サービス再起動

/etc/init.d/openvpn restart

インターフェース確認

tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.0.8.1 P-t-P:10.0.8.2 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:3195 errors:0 dropped:0 overruns:0 frame:0
TX packets:3194 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:268380 (262.0 KiB) TX bytes:268296 (262.0 KiB)


conoha側-VPN用VM作業

パッケージインストール

yum -y install openvpn.x86_64

設定ファイル作成

/etc/openvpn/server.conf
port 21001
proto udp
dev tun
remote 198.41.100.10
local  203.0.113.100
float
ifconfig 10.0.8.2 10.0.8.1
persist-tun
persist-local-ip
comp-lzo
secret /etc/openvpn/vpn.key
route 10.110.2.0 255.255.255.0
user nobody
group nobody
verb 1
keepalive 10 60

router用にパケット転送設定

vim /etc/sysctl.conf
変更:
net.ipv4.ip_forward = 1
追加:
net.core.xfrm_larval_drop = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.eth0.send_redirects = 0
net.ipv4.conf.eth1.send_redirects = 0
net.ipv4.conf.lo.send_redirects = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.eth0.accept_redirects = 0
net.ipv4.conf.eth1.accept_redirects = 0
net.ipv4.conf.lo.accept_redirects = 0
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.eth0.rp_filter = 0
net.ipv4.conf.lo.rp_filter = 0

反映:

sysctl -p

サービス再起動

/etc/init.d/openvpn restart

インターフェース確認

tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.0.8.2 P-t-P:10.0.8.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:3062 errors:0 dropped:0 overruns:0 frame:0
TX packets:3066 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:257208 (251.1 KiB) TX bytes:257544 (251.5 KiB)


ルーティング追加

アプリクラウド側-クローズドVM作業

route add -net 10.0.0.0/24 gw 10.110.2.1 eth1

Conoha側-クローズドVM作業

route add -net 10.110.2.0/24 gw 10.0.0.1 eth1


疎通確認

アプリクラウド側-クローズドVM作業

ping 10.0.0.2

Conoha側-クローズドVM作業

ping 10.110.2.100