Creating a Bridge and Mapping it to Port (Ethernet
Interface)
ovs-vsctl add-br ov_10nw
ovs-vsctl add-port ov_10nw enp2s0f0
ovs-vsctl add-br ov_9nw
ovs-vsctl add-port ov_9nw en
The bridge name must be the same as created in the XML file.
Viewing the Bridge Mapping
ovs-vsctl show
Example
[root@localhost ~]# ovs-vsctl show
099e8b7e-bf00-4071-be62-ec55f9b543cc
Bridge "ov_9nw"
Port "ov_9nw"
Interface "ov_9nw"
type: internal
Port "enp2s0f1"
Interface "enp2s0f1"
Bridge "ov_10nw"
Port "ov_10nw"
Interface "ov_10nw"
type: internal
Port "enp2s0f0"
Interface "enp2s0f0"
ovs_version: "2.3.1-git3282e51"
Creating XML
Files
Create two XML
files; one for service-nw (10nw) and the other for management (9nw).
Example
10nw_eth0_ov.xml
9nw_eth1_ov.xml
Both XML files
contain VLAN information based on the network, or based on what you want to
allow.
Example: To Allow All
VLANs
<network>
<name>10-nw</name>
<forward mode='bridge'/>
<bridge name='ov_10nw'/>
<virtualport type='openvswitch'/>
<portgroup name='vlan-any' default='yes'>
</portgroup>
</network>
The bridge name
must be the same as created during "ovs-vsctl" command.
If only specific
VLANs need to be allowed, use the following format.
<network>
<name>ov-nw</name>
<forward mode='bridge'/>
<bridge name='bridge_1'/>
<virtualport type='openvswitch'/>
<portgroup name='all_vlans' default='yes'>
</portgroup>
<portgroup name='vlan-152-untagged'>
<vlan>
<vlan mode='native-untagged'/>
<tag id='152'/>
</vlan>
</portgroup>
<portgroup name='vlan-153'>
<vlan>
<tag id='153'/>
</vlan>
</portgroup>
<portgroup name='two-vlan'>
<vlan trunk='yes'>
<tag id='152'/>
<tag id='153'/>
</vlan>
</portgroup>
</network>
In the above
configuration:
-
portgroup
name='all_vlans' → allows all VLANs.
-
portgroup
name='vlan-152-untagged' → allows only untagged VLAN that is 152.
-
portgroup
name='vlan-153' → allows only 153 VLAN.
-
portgroup
name='two-vlan' → allows only two VLANs, that is, 152 and 153.
Allowing CDP
Packets to Forward from Open vSwitch
ovs-vsctl set bridge ov_9nw other-config:forward-bpdu=true
Viewing the
Virtual Network
virsh net-list --all
Deleting the
Default Network
virsh net-undefine default
Creating Virtual
Network
virsh net-define <xml_file_name>
Viewing the
Virtual Network
virsh net-list --all
Starting the
Virtual Network
virsh net-start <network_name_that is in the list>
Example
[root@localhost ~]# virsh net-list --all
Name State Autostart Persistent
----------------------------------------------------------
default inactive no yes
[root@localhost ~]# virsh net-undefine default
Network default has been undefined
[root@localhost ~]# virsh net-define 10nw_eth0_ov.xml
Network 10-nw defined from 10nw_eth0_ov.xml
[root@localhost ~]# virsh net-define 9nw_eth1_ov.xml
Network 9-nw defined from 9nw_eth1_ov.xml
[root@localhost ~]# virsh net-list --all
Name State Autostart Persistent
----------------------------------------------------------
10-nw inactive no yes
9-nw inactive no yes
[root@localhost ~]# virsh net-start 10-nw
Network 10-nw started
[root@localhost ~]#
[root@localhost ~]# virsh net-start 9-nw
Network 9-nw started
[root@localhost ~]# virsh net-list --all
Name State Autostart Persistent
----------------------------------------------------------
10-nw active no yes
9-nw active no yes