| 1 | ### Create bridged networks |
| 2 | |
| 3 | 1. Create a directory for VM data. For example: |
| 4 | |
| 5 | ```none |
| 6 | mkdir /mnt/vmstore/ |
| 7 | cd /mnt/vmstore/ |
| 8 | ``` |
| 9 | |
| 10 | 2. Define the bridge interface, `br0`, for VLAN1 by creating the `/mnt/vmstore/net-br0.xml` file with the following contents: |
| 11 | |
| 12 | ```xml |
| 13 | <network> |
| 14 | <name>br0</name> |
| 15 | <forward mode="bridge" /> |
| 16 | <bridge name="br0" /> |
| 17 | </network> |
| 18 | ``` |
| 19 | |
| 20 | 3. Define the bridge interface, `br0-vlan40`, for VLAN40 by creating the `/mnt/vmstore/net-br0-vlan40.xml` file with the following contents: |
| 21 | |
| 22 | ```xml |
| 23 | <network> |
| 24 | <name>br0-vlan40</name> |
| 25 | <forward mode="bridge" /> |
| 26 | <bridge name="br0-vlan40" /> |
| 27 | </network> |
| 28 | ``` |
| 29 | |
| 30 | 4. Define the bridge interface, `br0-vlan41`, for VLAN41 by creating the `/mnt/vmstore/net-br0-vlan41.xml` file with the following contents: |
| 31 | |
| 32 | ```xml |
| 33 | <network> |
| 34 | <name>br0-vlan41</name> |
| 35 | <forward mode="bridge" /> |
| 36 | <bridge name="br0-vlan41" /> |
| 37 | </network> |
| 38 | ``` |
| 39 | |
| 40 | 5. Enable the virtual (bridged) networks. This consists of three steps (performed for each of the networks): |
| 41 | |
| 42 | 1. Define the network. |
| 43 | 2. Start the network. |
| 44 | 3. Set the network to autostart. |
| 45 | |
| 46 | ``` |
| 47 | virsh net-define net-br0.xml |
| 48 | virsh net-define net-br0-vlan40.xml |
| 49 | virsh net-define net-br0-vlan41.xml |
| 50 | virsh net-start br0 |
| 51 | virsh net-start br0-vlan40 |
| 52 | virsh net-start br0-vlan41 |
| 53 | virsh net-autostart br0 |
| 54 | virsh net-autostart br0-vlan40 |
| 55 | virsh net-autostart br0-vlan41 |
| 56 | ``` |
| 57 | |
| 58 | 6. Test the bridged networks. |
| 59 | |
| 60 | Congratulations, the configuration is complete. You can now create a virtual machine, assign the desired network using your preferred VM configuration tool, and run some tests. |