25
24

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.

Open vSwicthでVLAN構築

Last updated at Posted at 2014-11-25

Open vSwitchを用いたVLANを構築してみた.
CentOS7はデフォルトでifconfigコマンドが存在しないため,インターフェースへのipアドレスの付与はipコマンドで行う.

#環境
OS: CentOS7.0 minimal
switch: Open vSwitch 2.0.0

#構成図

 |A|                 |C|
   \               /
     |ovs-br0|-------|ovs-br1|
   /               \
 |B|                 |D|

ホスト|A|,|C|はVLAN10, ホスト|B|,|D|はVLAN20に所属させる.

#netnsの作成

ip netns add A
ip netns add B
ip netns add C
ip netns add D

#netns - スイッチ間のリンクの作成

ip link add a0 type veth peer name ovs0-0
ip link add b0 type veth peer name ovs0-1
ip link add c0 type veth peer name ovs1-0
ip link add d0 type veth peer name ovs1-1

#netnsへのインターフェースの追加

ip link set a0 netns A up
ip link set b0 netns B up
ip link set c0 netns C up
ip link set d0 netns D up

#IPアドレスの付与

ip netns exec A ip addr add 1.0.0.1/24 dev a0
ip netns exec B ip addr add 1.0.0.2/24 dev b0
ip netns exec C ip addr add 1.0.0.3/24 dev c0
ip netns exec D ip addr add 1.0.0.4/24 dev d0

#スイッチの作成

ovs-vsctl add-br ovs-br0
ovs-vsctl add-br ovs-br1

#アクセスポートの設定

ovs-vsctl add-port ovs-br0 ovs0-0 tag=10
ovs-vsctl add-port ovs-br0 ovs0-1 tag=20
ovs-vsctl add-port ovs-br1 ovs1-0 tag=10
ovs-vsctl add-port ovs-br1 ovs1-1 tag=20

#トランク用のリンクの作成

ip link add t0 type veth peer name t1

#トランクポートの設定

ovs-vsctl add-port ovs-br0 t0 trunk=10,20
ovs-vsctl add-port ovs-br1 t1 trunk=10,20

#疎通確認

通る場合
ip netns exec A ping 1.0.0.3
ip netns exec B ping 1.0.0.4
通らない場合
ip netns exec A ping 1.0.0.4
ip netns exec B ping 1.0.0.3 
25
24
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
25
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?