sudo apt-get update
sudo apt-get upgrade
sudo apt-get install openvswitch-switch
sudo ovs-vsctl show
ovs_version: "2.5.2"
sudo ovs-vsctl add-br br0
sudo ifconfig enp0s31f6 up
sudo ovs-vsctl add-port br0 enp0s31f6
sudo ifconfig enp0s31f6 0
sudo vim /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto br0
iface br0 inet dhcp
sudo /etc/init.d/networking restart
[ ok ] Restarting networking (via systemctl): networking.service.
这时使用ifconfig可以看到br0已经自动获取到IP地址,内外网链接正常。
如果需要手动设置IP则执行以下命令
sudo ifconfig br0 172.31.141.210 netmask 255.255.255.0
sudo route add default gw 172.31.141.254
至此ovs安装与虚拟网桥均创建完成。