In a previous tutorial we described how are the network devices and virtual machines connected in our VoIP home lab network. We will continue with Open vSwitch and VMware Workstation configuration.
1. VMware Workstation Configuration
Start VMware Workstation.
$ sudo vmware
a) Create new host-only interfaces
By default three VMware interfaces - vmnet0, vmnet1 a vmnet8 are created after VMware Workstation installation. Although these three interfaces match the number of interfaces needed by our VMs we will create another 3 interfaces vmnet10,vmnet11 and vmnet100 that reflect our VLAN ID labeling. To do this select option Edit -> Virtual Network Editor. Clicking on Remove Network button delete all existing interfaces. Then click on Add network button. Enter Network name and select Host-only option.
Picture 1 - Adding a new virtual network
Uncheck option Use local DHCP service to distribute IP adresses to VMs and save settings with Save button. Repeat the same procedure for all remaining vment interfaces. Once you finish, the Virtual Network Editor should look like following.
Picture 2 - Virtual Network Editor
Selecting Host-only option we instruct VMware to create a network connection only between a particular guest and host interface. Normally, is is a private network with no access to any other network. However, we will configure Openvswitch to connect a host network interface to switch itself. In other words, we will connect VM to the rest of our network.
b) Assign a virtual interface to the virtual machine
To let Openvswitch bridge a correct vmnet interface to Openvswitch port we must assign our new created virtual interface to the particular virtual machine. For instance let's assign the interface vmnet10 to the VM with installed Windows 7. Left click on the virtual machine and select Settings option. Navigate to Network Adapter settings. Select an option - Custom: Specific virtual network and choose device /dev/vmnet10 from the list.
Picture 3 - VM settings with installed Windows 7
Continue with assigning a network interface /dev/vmnet11 to the VM with installed Core Linux. Assigning a network interface /dev/vmnet100 to the VM with installed Cisco Unified Communication Manager - CUCM will be done after CUCM installation on VM.
2. Openvswitch Configuration
Even we partly configured Openvswitch in this tutorial we will delete a previous configuration and configure Openvswitch from scratch.
a) Create Openvswitch startup script
In order to get Openvswitch working, an openvswitch kernel module has to be loaded in Linux kernel, configuration database started and openvswitch daemon running. We could configure Debian to perform these tasks at its boot time as it is shown here . Once Debian booted up, Openvswitch would be fully operational. However, it is not preferable method for us to run Openvswitch as we want a virtual switch working only if it is needed. For this reason we will create a startup script start_openvswitch.sh that we start manually. The script is script.
Create a blank file start_openvswitch.sh, copy the rows in to the file and assign execute privileges to the file.
$ chmod +x start_openvswitch.sh
Afterward start the script.
$ ./start_openvswitch.sh
Once the script is started it is probably a good idea to check if openvswitch module is loaded in Linux kernel.
$ lsmod | grep open
openvswitch 61107 0
gre 12475 1 openvswitch
libcrc32c 12394 1 openvswitch
2) Openvswitch Configuration
b) Delete previously configured bridge br0 from database
$ sudo ovs-vsctl del-br br0
c) Create a new bridge br0
$ sudo ovs-vsctl add-br br0
d) Configure a trunk port
We will configure a network interface eth0 to become a trunk port. The trunk port is carrying only the VLAN traffic with ID 10,11 and 100.
$ sudo ovs-vsctl add-port br0 eth0 trunks=10,11,100
e) Configure Access ports
The commands assign virtual machine interfaces to the bridge br0.
$ sudo ovs-vsctl add-port br0 vmnet10 tag=10
$ sudo ovs-vsctl add-port br0 vmnet100 tag=100
$ sudo ovs-vsctl add-port br0 vmnet11 tag=11
f) Create SVI ports – VLAN interfaces
$ sudo ovs-vsctl add-port br0 vlan10 tag=10 -- set interface vlan10 type=internal
$ sudo ovs-vsctl add-port br0 vlan11 tag=11 -- set interface vlan11 type=internal
$ sudo ovs-vsctl add-port br0 vlan100 tag=100 -- set interface vlan100 type=internal
Note Use command /sbin/ifconfig to check if VLAN interfaces has been created.
g) Assign IP addresses to VLAN interfaces
$ sudo /sbin/ifconfig vlan10 192.168.10.253 netmask 255.255.255.0 up
$ sudo /sbin/ifconfig vlan11 192.168.11.253 netmask 255.255.255.0 up
$ sudo /sbin/ifconfig vlan100 192.168.100.253 netmask 255.255.255.0 up
h) Display Openvswitch configuration
The following command displays Openvswitch configuration.
$ sudo ovs-vsctl show
Picture 4 - Openvswitch Configuration
3) Openvswitch Startup Script
Finally we will finish article with adding IP address configuration of VLAN ports to the Openvswitch startup script.
End.
Reference:
http://blog.scottlowe.org/2013/05/28/vlan-trunking-to-guest-domains-with-open-vswitch/
Wow, this is an EXCELLENT post, I've been looking around for a couple of weeks and couldn't find anything that worked on the lab I'm setting up. I really appreciate it!! However, I'm missing just a tiny bit, which I'm guessing you may be able to help based on your awesome understanding on ovs. Short summary;
Base OS of my workstation: Arch Linux
Virtualization Software: VMware Workstation
Physical firewall/router: pfSense (VLAN interfaces live here)
Lab purpose: vSphere lab environment with nested ESXi hosts
Catch: Using your instructions I was able to successfully extend all of my physical environment VLANs to VMware Workstation, however, in the case of ESXi, I require that the virtual NICs (vmnet interface) works also as a trunk port so I can be able to tag traffic inside the ESXi vSwitch. I can easily leave the mgmt kernel of the ESXi untagged and it'll work by simply assigning it to the corresponding vlan interface on the ovs, however, IF I would like to create port-groups for VMs inside ESXi with other VLANs tagged, will the tagged traffic go through to the physical layer, or will my ovs switch limit the traffic to the tag specified on the configuration (based on your post, all vmnets where statically assigned to specific VLAN interfaces)? Meaning; Is there a way to create an additional vmnic on VMware Workstation and also associate it to a port on the ovs as trunk? If this possible, can you help me to understand the concept of apply it based on this scenario?
Thank you!