LoginSignup
4
7

More than 5 years have passed since last update.

OpenvSwitchでVXLAN

Posted at

OpenvSwitchでVXLAN

OpenvSwitchでVXLANを試してみた。

環境

  • OS: Ubuntu 16.04

インストール

# apt update
# apt install openvswitch-common openvswitch-switch

Linuxの標準のモジュールのbridgeを使わないように設定する。

# rmmod bridge

トポロジ

vxlan_topology.jpg

OVSに接続しているゲストはLXCを使用した。

コンテナ作成

OVSに接続するコンテナのプロファイルを作成。
デフォルトのプロファイルをコピーしてeth0の設定を変更する。

# lxc profile copy default c100
config: {}
devices:
    eth0:
        host_name: c100
        name: eth0
        nictype: p2p
        type: nic
name: c100
used_by: []

host_nameには、ホスト側で表示されるインターフェース名を指定する。指定しなかった場合は、自動で付与される。今回は、インターフェース名を使用してOVSの設定をするので指定した。
また、nictypeのp2pは、仮想ペアを作り、片方をコンテナに、片方をホストに置かれる。

作成するコンテナごとにプロファイルを作成する。1つのホスト上にc100とc200を作る。

# lxc launch ubuntu:16.04 c100 -p c100 
# lxc launch ubuntu:16.04 c200 -p c200

コンテナにアドレスを付与する。(別のホスト上のコンテナにはIPが被らないように設定する。)

# lxc exec c100 -- ip address add 192.168.100.1/24 dev eth0
# lxc exec c200 -- ip address add 192.168.200.1/24 dev eth0

OVSの設定

仮想スイッチを作成する。

# ovs-vsctl add-br ovs1

vxlanのインターフェースを作成する。今回はタグが100と200で区切るので2つ作成する。

# ovs-vsctl add-port ovs1 vxlan100 tag=100 -- set interface vxlan100 type=vxlan options:remote_ip=172.168.0.2 options:key=100
# ovs-vsctl add-port ovs1 vxlan200 tag=200 -- set interface vxlan200 type=vxlan options:remote_ip=172.168.0.2 options:key=200

コンテナのvethを仮想スイッチに接続する。

# ovs-vsctl add-port ovs1 c100 tag=100
# ovs-vsctl add-port ovs1 c200 tag=200

疎通確認

コンテナから別のコンテナへpingを送信してみる。

# lxc exec c100 -- ping 192.168.100.2
成功する
# lxc exec c100 -- ping 192.168.200.2
失敗する
4
7
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
4
7