Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODA #107: Create snippet files for single-sourcing repetitive instructions #505

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 10 additions & 112 deletions doc/multi-nic-vm-host-with-bonds-and-vlans.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
This guide shows how to configure a virtual machine (VM) host using Netplan and the `virsh` interface. The host in this scenario has four network interface (NICs). The host uses network bonding and three VLAN networks.


## Prerequisites
```{include} reuse/configure-vm-prerequisites.txt

Ensure the following prerequisites are satisfied.
```


### System
Expand Down Expand Up @@ -35,23 +35,9 @@ Ensure the following prerequisites are satisfied.
- Firewall configured; see [UFW](https://help.ubuntu.com/community/UFW).


#### Disable netfilter for bridged interfaces
```{include} reuse/configure-vm-disable-netfilter.txt

To allow communication between the host server, its virtual machines, and the devices in the local VLANs, disable netfilter for bridged interfaces:

1. Add the following lines to the `/etc/systemctl.conf` configuration file:

```
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-arptables = 0
```

2. Apply the changes immediately, without rebooting the host.

```none
sysctl -p /etc/sysctl.conf
```
```


## Netplan configuration
Expand Down Expand Up @@ -155,104 +141,16 @@ Configure Netplan:
```


## Configure virtual networks using `virsh`

The next step is to configure virtual networks defined for `virsh` domains. This is not necessary, but it makes VM deployment and management easier.


### Check networking and delete the default network

1. Check existing virtual networks:

```none
virsh net-list --all
```

There should be one default network as in this example:

```
Name State Autostart Persistent
--------------------------------------------
default active yes yes
```

If needed, use the `net-info` command to gather more details about the default network:

```
virsh net-info default
```

2. Remove the default network:

```
virsh net-destroy default
virsh net-undefine default
```

3. Check network list to confirm the changes have been applied. There should no networks defined now:

```none
virsh net-list --all
```

```{include} reuse/configure-vm-using-virsh.txt

### Create bridged networks
```

1. Create a directory for VM data. For example:

```none
mkdir /mnt/vmstore/
cd /mnt/vmstore/
```
```{include} reuse/configure-vm-check-networking-delete-default.txt

2. Define the bridge interface, `br0`, for VLAN1 by creating the `/mnt/vmstore/net-br0.xml` file with the following contents:
```

```xml
<network>
<name>br0</name>
<forward mode="bridge" />
<bridge name="br0" />
</network>
```

3. Define the bridge interface, `br0-vlan40`, for VLAN40 by creating the `/mnt/vmstore/net-br0-vlan40.xml` file with the following contents:

```xml
<network>
<name>br0-vlan40</name>
<forward mode="bridge" />
<bridge name="br0-vlan40" />
</network>
```

4. Define the bridge interface, `br0-vlan41`, for VLAN41 by creating the `/mnt/vmstore/net-br0-vlan41.xml` file with the following contents:

```xml
<network>
<name>br0-vlan41</name>
<forward mode="bridge" />
<bridge name="br0-vlan41" />
</network>
```

5. Enable the virtual (bridged) networks. This consists of three steps (performed for each of the networks):

1. Define the network.
2. Start the network.
3. Set the network to autostart.

```
virsh net-define net-br0.xml
virsh net-define net-br0-vlan40.xml
virsh net-define net-br0-vlan41.xml
virsh net-start br0
virsh net-start br0-vlan40
virsh net-start br0-vlan41
virsh net-autostart br0
virsh net-autostart br0-vlan40
virsh net-autostart br0-vlan41
```

6. Test the bridged networks.
```{include} reuse/configure-vm-create-bridged-networks.txt

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.
```
34 changes: 34 additions & 0 deletions doc/reuse/configure-vm-check-networking-delete-default.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### Check networking and delete the default network

1. Check existing virtual networks:

```none
virsh net-list --all
```

There should be one default network as in this example:

```
Name State Autostart Persistent
--------------------------------------------
default active yes yes
```

If needed, use the `net-info` command to gather more details about the default network:

```
virsh net-info default
```

2. Remove the default network:

```
virsh net-destroy default
virsh net-undefine default
```

3. Check network list to confirm the changes have been applied. There should no networks defined now:

```none
virsh net-list --all
```
60 changes: 60 additions & 0 deletions doc/reuse/configure-vm-create-bridged-networks.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
### Create bridged networks

1. Create a directory for VM data. For example:

```none
mkdir /mnt/vmstore/
cd /mnt/vmstore/
```

2. Define the bridge interface, `br0`, for VLAN1 by creating the `/mnt/vmstore/net-br0.xml` file with the following contents:

```xml
<network>
<name>br0</name>
<forward mode="bridge" />
<bridge name="br0" />
</network>
```

3. Define the bridge interface, `br0-vlan40`, for VLAN40 by creating the `/mnt/vmstore/net-br0-vlan40.xml` file with the following contents:

```xml
<network>
<name>br0-vlan40</name>
<forward mode="bridge" />
<bridge name="br0-vlan40" />
</network>
```

4. Define the bridge interface, `br0-vlan41`, for VLAN41 by creating the `/mnt/vmstore/net-br0-vlan41.xml` file with the following contents:

```xml
<network>
<name>br0-vlan41</name>
<forward mode="bridge" />
<bridge name="br0-vlan41" />
</network>
```

5. Enable the virtual (bridged) networks. This consists of three steps (performed for each of the networks):

1. Define the network.
2. Start the network.
3. Set the network to autostart.

```
virsh net-define net-br0.xml
virsh net-define net-br0-vlan40.xml
virsh net-define net-br0-vlan41.xml
virsh net-start br0
virsh net-start br0-vlan40
virsh net-start br0-vlan41
virsh net-autostart br0
virsh net-autostart br0-vlan40
virsh net-autostart br0-vlan41
```

6. Test the bridged networks.

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.
17 changes: 17 additions & 0 deletions doc/reuse/configure-vm-disable-netfilter.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#### Disable netfilter for bridged interfaces

To allow communication between the host server, its virtual machines, and the devices in the local VLANs, disable netfilter for bridged interfaces:

1. Add the following lines to the `/etc/systemctl.conf` configuration file:

```
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-arptables = 0
```

2. Apply the changes immediately, without rebooting the host.

```none
sysctl -p /etc/sysctl.conf
```
6 changes: 6 additions & 0 deletions doc/reuse/configure-vm-prerequisites-system.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### System

- Computer with a single network interface card (NIC).
- Ubuntu Server installed.
- KVM and QEMU installed; see [KVM installation](https://help.ubuntu.com/community/KVM/Installation).
- Administrator privileges.
3 changes: 3 additions & 0 deletions doc/reuse/configure-vm-prerequisites.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Prerequisites

Ensure the following prerequisites are satisfied.
3 changes: 3 additions & 0 deletions doc/reuse/configure-vm-using-virsh.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Configure virtual networks using `virsh`

The next step is to configure virtual networks defined for `virsh` domains. This is not necessary, but it makes VM deployment and management easier.
Loading
Loading