openvswitchでVXLAN環境(unicast)を構築する
今後の検証で使いたいので、CentOSにopenvswitchをインストールしてVXLANを設定済みの環境を構築します。
openvswitchですが、この記事を書いている時点での最新は2.3.0です。今回はopenstackのredhatディストリビューションのレポジトリを追加してインストールします(2.0でも良かったかな・・・)
構成は下図の通りです。openvswitchの他にGNS3を使っています。GNS3はvirtulboxと連携ができますので非常に便利です。
- GNS3
- 全体NWの可視化
- 仮想ネットワークの作成・接続
- Node作成
- キャプチャなど各種NWツール
- virtualbox
- openvswitch用Serverインストール
概要
- openvswitchインストール
- 物理接続・起動
- VXLAN設定
- 動作確認
openvswitchインストール
Junoのレポジトリを追加しようと思いましたが、うっかり6.4で構築していたので時間の兼ね合いで今日はicehouseを使用します。
[root@localhost ~]# yum install -y https://repos.fedorapeople.org/repos/openstack/openstack-icehouse/rdo-release-icehouse-1.noarch.rpm
[root@localhost ~]# yum info openvswitch Name : openvswitch Arch : x86_64 Version : 1.11.0_8ce28d Release : 1.el6ost Size : 1.8 M Repo : openstack-icehouse Summary : Open vSwitch daemon/database/utilities URL : http://openvswitch.org License : ASL 2.0 and LGPLv2+ and SISSL Description : Open vSwitch provides standard network bridging functions and : support for the OpenFlow protocol for remote per-flow control of : traffic.
yum install後にサービスを起動するだけです。本来はovsdbの初スキーマ作成や起動も必要ですので、かなり楽です。
[root@localhost ~]# service openvswitch start /etc/openvswitch/conf.db does not exist ... (warning). Creating empty database /etc/openvswitch/conf.db [ OK ] Starting ovsdb-server [ OK ] Configuring Open vSwitch system IDs [ OK ] Inserting openvswitch module [ OK ] Starting ovs-vswitchd [ OK ] Enabling remote OVSDB managers [ OK ]
物理接続・起動
openvswitchのインストールはvirtualbox単体で実施しました。その後、GNS3で作成した2つのマシンを読み込んで配置してください。
GNS3で以下のように接続します。PCとHUBはGNS3で作成しています。
openvswitch01(eth2) -- HUB -- openvswitch01(eth2)
PC1(eth0) -- openvswitch01(eth3)
PC2(eth0) -- openvswitch02(eth3)
PC3(eth0) -- openvswitch01(eth4)
PC4(eth0) -- openvswitch02(eth4)
・openvswitch01,02
ip link set eth1 up ip link set eth2 up ip link set eth3 up
・openvswitch01
ifconfig eth1 172.16.100.1 netmask 255.255.255.0
・openvswitch02
ifconfig eth1 172.16.100.2 netmask 255.255.255.0
・PC1
ip 192.168.0.1/24
・PC2
ip 192.168.0.2/24
・PC3
ip 192.168.0.1/24
・PC4
ip 192.168.0.2/24
当然、現時点ではPC1〜PC2、PC3〜PC4などの他端末間の通信は成立しません。
VXLAN設定
まずはPC1〜PC2間を接続します。
・openvswitch01
ovs-vsctl add-br ovs01 ovs-vsctl add-port ovs01 eth2 tag=100 ovs-vsctl add-port ovs01 vxlan0 tag=100 -- set interface vxlan0 type=vxlan options:key=100 options:remote_ip=172.16.100.2 ovs-vsctl add-port ovs01 eth3 tag=200 ovs-vsctl add-port ovs01 vxlan1 tag=200 -- set interface vxlan1 type=vxlan options:key=200 options:remote_ip=172.16.100.2
・openvswitch02
ovs-vsctl add-br ovs02 ovs-vsctl add-port ovs02 eth2 tag=100 ovs-vsctl add-port ovs02 vxlan0 tag=100 -- set interface vxlan0 type=vxlan options:key=100 options:remote_ip=172.16.100.1 ovs-vsctl add-port ovs02 eth3 tag=200 ovs-vsctl add-port ovs02 vxlan1 tag=200 -- set interface vxlan1 type=vxlan options:key=200 options:remote_ip=172.16.100.1
動作確認
ovs-vsctlコマンドを使用し、ステータスを確認します。
・openvswitch01
[root@localhost ~]# ovs-vsctl show c80a8940-5448-4c3e-91cb-9ffc629c892b Bridge "ovs01" Port "ovs01" Interface "ovs01" type: internal Port "eth2" tag: 100 Interface "eth2" Port "vxlan0" tag: 100 Interface "vxlan0" type: vxlan options: {key="100", remote_ip="172.16.100.2"} ovs_version: "1.11.0" [root@localhost ~]# ovs-vsctl list interface vxlan0 _uuid : 1c39be86-6e16-4199-9fcd-34cbd2c364be admin_state : up ingress_policing_burst: 0 ingress_policing_rate: 0 link_resets : 0 link_state : up mac_in_use : "aa:af:f1:93:a8:29" name : "vxlan0" ofport : 2 options : {key="100", remote_ip="172.16.100.2"} statistics : {collisions=0, rx_bytes=0, rx_crc_err=0, rx_dropped=0, rx_errors=0, rx_frame_err=0, rx_over_err=0, rx_packets=0, tx_bytes=0, tx_dropped=0, tx_errors=0, tx_packets=0} status : {tunnel_egress_iface="eth1", tunnel_egress_iface_carrier=up} type : vxlan
・openvswitch02
[root@localhost ~]# ovs-vsctl show 8a7e1587-be31-4544-812f-64f0a9c134dd Bridge "ovs02" Port "eth2" tag: 100 Interface "eth2" Port "ovs02" Interface "ovs02" type: internal Port "vxlan0" tag: 100 Interface "vxlan0" type: vxlan options: {key="100", remote_ip="172.16.100.1"} ovs_version: "1.11.0" [root@localhost ~]# ovs-vsctl list interface vxlan0 _uuid : b075c844-f961-4a85-a461-5a8e19842aea admin_state : up ingress_policing_burst: 0 ingress_policing_rate: 0 link_resets : 0 link_state : up mac_in_use : "32:33:4a:43:47:25" name : "vxlan0" ofport : 2 options : {key="100", remote_ip="172.16.100.1"} statistics : {collisions=0, rx_bytes=0, rx_crc_err=0, rx_dropped=0, rx_errors=0, rx_frame_err=0, rx_over_err=0, rx_packets=0, tx_bytes=0, tx_dropped=0, tx_errors=0, tx_packets=0} status : {tunnel_egress_iface="eth1", tunnel_egress_iface_carrier=up} type : vxlan
試しにPC1〜PC2の通信を流してみます。PC1からPingを打つと疎通も取れ、Statisticsでもカウントアップが確認できます。
statistics : {collisions=0, rx_bytes=976, rx_crc_err=0, rx_dropped=0, rx_errors=0, rx_frame_err=0, rx_over_err=0, rx_packets=10, tx_bytes=1700, tx_dropped=0, tx_errors=0, tx_packets=20}
途中のHUBで確認するとvirtual extensible local area networkとしてVNI入りのパケットがキャプチャができます。
次に同一アドレスのPC3〜4向けのVXLANを実施します。
[root@localhost ~]# ovs-vsctl show c80a8940-5448-4c3e-91cb-9ffc629c892b Bridge "ovs01" Port "ovs01" Interface "ovs01" type: internal Port "eth3" tag: 200 Interface "eth3" Port "eth2" tag: 100 Interface "eth2" Port "vxlan1" tag: 200 Interface "vxlan1" type: vxlan options: {key="200", remote_ip="172.16.100.2"} Port "vxlan0" tag: 100 Interface "vxlan0" type: vxlan options: {key="100", remote_ip="172.16.100.2"} ovs_version: "1.11.0"
PCからのPingおよびキャプチャでも問題ないことを確認できました。
今後、この環境を使って何個か検証していきたいと思います。
シェアして頂けると嬉しいです。
参考になったという方がいれば是非お願いしますm(_ _ )m
モチベーション維持の観点で非常に励みになります。
- 作者: 馬場達也,大上貴充,関山宜孝,?畑知也
- 出版社/メーカー: 翔泳社
- 発売日: 2013/09/13
- メディア: 大型本
- この商品を含むブログ (3件) を見る
- 作者: あきみち,宮永直樹,岩田淳
- 出版社/メーカー: オーム社
- 発売日: 2013/07/26
- メディア: 単行本(ソフトカバー)
- この商品を含むブログ (5件) を見る