首页 » KVM虚拟化 » kvm环境如何使用openvswitch,centos7使用yum安装openvswitch

kvm环境如何使用openvswitch,centos7使用yum安装openvswitch

 

一定是自带的yum源,阿里源不包含这个软件包

#安装

yum -y install openvswitch*

#启动

systemctl start openvswitch

#开机启动

systemctl enable openvswitch

root[@localhost]# ovs-vsctl add-br br0

root[@localhost]# ovs-vsctl add-port br0 em4

定义一个网络,该网络桥接到ovs网桥上

[root@cnc mnt]# cat test.xml

<network>

<name>test</name>

<forward mode="bridge"/>

<bridge name="br0"/>

<virtualport type="openvswitch"/>

</network>

上面是定义一个网络所需的xml文件,通过文件,我们可以定义该网络的名字、转发的方式、桥的名字以及接口的类型。

步骤如下:

1.创建ovs网桥

[root@cnc mnt]# ovs-vsctl add-br br0

[root@cnc mnt]# ovs-vsctl show

e0738e00-be28-4ac0-8f0b-856bbb9f072c

Bridge test-br

Port test-br

Interface test-br

type: internal

ovs_version: "2.0.0"

2.利用如上xml文件定义网络

[root@cnc mnt]# virsh net-define test.xml

Network test defined from test.xml

[root@cnc mnt]# virsh net-list --all

Name State Autostart Persistent

----------------------------------------------------------

test inactive no yes

[root@cnc mnt]# virsh net-start test

Network test started

[root@cnc mnt]# virsh net-list --all

Name State Autostart Persistent

----------------------------------------------------------

test active no yes

[root@cnc mnt]# virsh net-autostart test

Network test marked as autostarted

原文链接:kvm环境如何使用openvswitch,centos7使用yum安装openvswitch,转载请注明来源!

0