vxlanでgceとec2の上に仮想ネットワークを作ってみる


OSはubuntu:14.04を使ってみます。

準備

まずはbridge-utilsをインストールします。

apt-get install bridge-utils

あとは、FWの設定で8472/udpを開けておきましょう。

node1(EC2)

  • global ip: 123.10.20.34 (例)
  • local ip: 10.1.2.3
ip li add vxlan0 type vxlan id 10 dev eth0
ip a add 192.168.1.1/24 broadcast 192.168.1.255 dev vxlan0
ip li set vxlan0 up
bridge fdb append 00:00:00:00:00:00 dev vxlan0 dst 210.12.34.56

node2(GCE)

  • global ip: 210.12.34.56 (例)
  • local ip: 10.200.100.5
ip li add vxlan0 type vxlan id 10 dev eth0
ip a add 192.168.1.2/24 broadcast 192.168.1.255 dev vxlan0
ip li set vxlan0 up
bridge fdb append 00:00:00:00:00:00 dev vxlan0 dst 123.10.20.34

これで ec2とgceにまたがる仮想ネットワークifvxlan0の準備ができました。相互にpingも通りますし、ncコマンドでチャットをしてみましょう。

node1

nc -l 192.168.1.1 -p 1234
hello

node2

nc 192.168.1.1 1234
hello

ip li addで指定したidは VNI(VXLAN Network Identifier)です。同じ数字を指定すればok。