Create a bridge network

When creating a vm with virtmanager in Manjaro the default network interface will be on a NAT network. This will give you an IP off the local network and allow access between the host and vm. You can utilize NAT to port forward but if you need local network access to the VM from the local network you will want to create a bridge interface that will provide the VM access to the local network and get an IP accessible by other machines on the network. Below are the steps to complete this using netctl

Create Tap interface and get ethernet device name

create a tap interface and get the device name of the local ethernet adapter in this example my ethernet adapter is enp0s13f0u3

#ip a
2: enp0s13f0u3: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether a0:29:19:89:c3:c1 brd ff:ff:ff:ff:ff:ff

Code language: PHP (php)

now create a tap interface named tap0 and set the device state to up

sudo ip tuntap add mode tap tap0
sudo ip link set dev tap0 up Code language: JavaScript (javascript)

Create kvm-bridge configuration file

Now create a configuration file in /etc/netctl named kvm-bridge this will create a br1 device with the ethernet and tap interfaces and enable DHCP the ExecUpPost sets the mac address to the ethernet mac address.

Description="Bridge Interface br1 : enp0s13f0u3,tap0"
Interface=br1
Connection=bridge
BindsToInterfaces=(enp0s13f0u3 tap0)
IP=dhcp
ExecUpPost="ip link set dev br1 address $(cat /sys/class/net/enp0s13f0u3/address); IP=dhcp; ip_set"
ExecDownPre="IP=dhcp" 


## Ignore (R)STP and immediately activate the bridge
SkipForwardingDelay=yes

Enable and start the bridge

Run the following commands to enable and start the bridge

sudo netctl enable kvm-bridge 
sudo netctl start kvm-bridge 

Now the bridge interface should be created you can verify with

sudo bridge link                                                                                                             ✔ 
2: enp0s13f0u3: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 master br1 state forwarding priority 32 cost 5 
7: tap0: <NO-CARRIER,BROADCAST,MULTICAST,PROMISC,UP> mtu 1500 master br1 state disabled priority 32 cost 2 


sudo brctl show
bridge name	bridge id		STP enabled	interfaces
br1		8000.a0291989c3c1	no		enp0s13f0u3
							tap0Code language: HTML, XML (xml)

This show that the bridge is creates and you will see a new br1 device that should get a DHCP address from the local network.

Set VMs to use br1 device

Now in virt manager you can set the VMs network interface to br1 this will allow the machine to get a DHCP address from the local network

Read full article here

Related posts

Leave A Comment