安装依赖
yum install gcc pkgconfig autoconf automake libtool git make python-devel openssl-devel kernel-devel kernel-debug-devel
下载源码
wget http://openvswitch.org/releases/openvswitch-2.8.1.tar.gz
tar zxvf openvswitch-2.8.1.tar.gz
编译
./configure --prefix=/usr/local/ovs
make -j 4
make install
加载所需的内核模块
modprobe openvswitch
lsmod | grep openvswitch
添加可执行文件路径
vim /etc/profile
export PATH=/usr/local/ovs/share/openvswitch/scripts:/usr/local/ovs/bin:/usr/local/ovs/sbin:$PATH
source /etc/profile
运行openvswitch
ovs-ctl start
ovs-ctl会运行ovsdb-server和ovs-vswitchd
验证一下
ovs-ctl add-br bro
ifconfig eth1 0
ovs-ctl add-port br0 eth1
ifconfig br0 192.168.1.2 netmask 255.255.255.0
route add default gw 192.168.1.1 br0
ip a
ovs-vsctl show