Skip to content

Commit

Permalink
added some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ji-podhead authored May 27, 2024
1 parent 8cb1c6a commit a0acfcb
Showing 1 changed file with 38 additions and 19 deletions.
57 changes: 38 additions & 19 deletions docs/libvirt/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ for drv in qemu network nodedev nwfilter secret storage interface; do systemctl
```Bash
virt-manager
```
**check if the NIC was created**
- it usually get installed.

**check if the Virtual Bridge 0" interface was created**

> ![virbr0](https://github.com/ji-podhead/RHEL_9_Foreman_Guide/blob/main/img/virbr0_kvm.png?raw=true)
```Bash
# ifconfig
Expand All @@ -40,27 +41,45 @@ virt-manager
> inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
>...
>```
- [what is virbr0?](https://askubuntu.com/questions/246343/what-is-the-virbr0-interface-used-for)
> - *The virbr0, or "Virtual Bridge 0" interface is used for NAT (Network Address Translation). It is provided by the libvirt library, and virtual environments sometimes use it to connect to the outside network.*
---
- ***if virbr0 is missing, we will create the NIC called br0:***
## Creating and Configuring a Network Bridge on Linux Using nmcli ***(OPTIONAL)***
- whether you need to create a network bridge with virbr0 depends on your specific networking requirements and how you intend to manage network connections for your virtual machines (VMs).
- In many setups, especially those involving libvirt and virtualization management tools like Foreman, a default bridge (virbr0) is often automatically created and managed by these systems. The virbr0 bridge is typically configured to allow VMs managed by libvirt to communicate with external networks, acting as a gateway for them.
- However, if you have specific networking needs that require custom configurations beyond what virbr0 offers, such as bonding, VLAN tagging, or other advanced features, you might choose to manually create and configure a network bridge yourself, similar to the process you described earlier with nmcli. In such cases, naming the bridge something other than virbr0 could be beneficial for clarity and organization, especially if you're managing multiple bridges for different purposes
> The commands you executed are part of the process to create and configure a network bridge on a Linux system. This setup allows virtual machines (VMs) to communicate directly with the physical network, as if they were directly connected to the network via a physical network interface. Here's a comprehensive guide translated into English and formatted in Markdown:
***Step 1: Create a Network Bridge***
```Bash
# sudo nmcli conn add type bridge con-name br0 ifname br0
# sudo nmcli conn add type ethernet slave-type bridge con-name bridge-br0 ifname enp2s0 master br0
# sudo nmcli conn up br0
bash sudo nmcli conn add type bridge con-name br0 ifname br0
```
>```
>Verbindung »br0« (02c66e55-068d-4aca-a03b-1559b32917cd) erfolgreich hinzugefügt.
>Verbindung »bridge-br0« (0cdcc86e-76dd-48e4-9c94-ebb2b68d7f55) erfolgreich hinzugefügt.
>Verbindung wurde erfolgreich aktiviert (master waiting for slaves) (Aktiver D-Bus-Pfad: /org/freedesktop/NetworkManager/ActiveConnection/27)
>```
> - This command creates a new network bridge named `br0`. A network bridge acts like a virtual switch, connecting multiple network interfaces, allowing traffic to be forwarded from one side of the network to another without passing through the physical device it arrived on.
***Step 2: Add a Physical Interface as a Slave to the Bridge***
```Bash
bash sudo nmcli conn add type ethernet slave-type bridge con-name bridge-br0 ifname enp2s0 master br0
```
> - With this command, the physical network interface `enp2s0` is added as a slave to the bridge `br0`. This connects the physical interface with the bridge, routing traffic passing through the bridge over the physical interface `enp2s0`.
***Step 3: Activate the Bridge***
```Bash
bash sudo nmcli conn up br0
```
> - This command activates the bridge `br0`, enabling it to function and forward traffic between connected interfaces.
***Step 4: Assign an IP Address to the Bridge (Optional)***
```Bash
bash sudo nmcli conn modify br0 ipv4.addresses "192.168.200.100/24" ipv4.method manual sudo nmcli conn up br0
```
> - These steps are optional and serve to assign a specific IP address to the bridge or virtual machine. In this example, the bridge `br0` is assigned the address `192.168.200.100` within the subnet `192.168.200.0/24`. After assigning the IP address, the bridge is reactivated to ensure the changes take effect.
> - This configuration enables virtual machines running over the bridge `br0` to communicate directly with the physical network, as if they were directly connected to the network via the physical network interface `enp2s0`. This setup is particularly useful for creating an isolated environment for virtual machines while still providing access to the physical network.

> - ***we assign an ip:***
>```Bash
># sudo nmcli conn modify br0 ipv4.addresses "192.168.200.100/24" ipv4.method manual
># sudo nmcli conn up br0
>```
> >```
> >Verbindung wurde erfolgreich aktiviert (master waiting for slaves) (Aktiver D-Bus-Pfad: /org/freedesktop/NetworkManager/ActiveConnection/28)
> >```

---

Expand Down

0 comments on commit a0acfcb

Please sign in to comment.