Hello to everyone.
I'm trying to configure the network of my host os (Linux Devuan 5) and of my guest OS (FreeBSD 13.2) because I want to have the connection inside the FreeBSD VM,that I have virtualized with qemu / kvm / libvirt on my ARM Chromebook. The procedure that I have explained below is working,nevertheless there is still something to fix. This is what I did :
1) Shut down libvirt
2) Created a bridge br1 manually without any slaves :
3) Added "allow all" to that bridge helper file (bridge.conf, located on /usr/local/etc/qemu/bridge.conf)
4) Started a VM with qemu only, telling it to use a bridge interface "br1". This creates a tap interface "tap0" which is a slave of a bridge "br1"
5) Right after VM start, explicitly set link br1 to "up" :
6) Configured an IP address from within the VM in a new subnet (192.168.20.2/24)
7) Configured IP address in the same subnet for br1 on KVM host (192.168.20.1/24). No IP should be assigned to the tap interface :
8) Configured MASQUERADING for traffic leaving through my standard home interface on the KVM host:
9) Enabled Routing :
That's it. The VM could ping everything,but another step is necessary. When the VM booted totally,until the login prompt,I should open a new terminal and do :
This is a dirty workaround that I don't like too much,but it removes the fake IP address169.254.89.8 from the tap0 and in this way I can ping the world while I'm using the VM. Every time I start a new VM,a new (and always the same) fake ip [169.254.35.253] is assigned to the tap interface and I should delete it everytime WHEN the vm has been fully loaded and it reached the login prompt (really I don't know what's the exact moment when the tap0 is created,so I've assumed that the right time is when the VM reached the login prompt). When this happens,an automatic script should be executed :
otherwise I cannot ping an external domain from within the vm and I will get the error "host unknown". Now,I don't know how to automate the process. What I want to do is to execute that command after 50 seconds that the qemu parameters below are executed :
because this is the time that the qemu parameters need to create the tap0 with the fake IP = 169.254.35.253 that should be deleted.
You know,It's very annoying to start every time a new terminal (because the terminal where the qemu parameters are running is busy) and writing "/bin/ip a fl dev tap0" inside it.
I've tried several methods to execute that command on the Linux OS while the FreeBSD vm was booting,but none of those methods worked. Now,I've got an idea for a new (interesting,from my point of view) approach to solve the "problem". What about to try to execute that command when FreeBSD is running ? It could be something like this :
1) I enable the automatic login on FreeBSD when the login prompt is ready,by configuring username and password in the right config file (In Linux usually I modify the file /etc/gdm3/custom.conf)
2) while FreeBSD is running or some time before it reaches the login prompt,I would like to run the command that I've shown above "/bin/ip a fl dev tap0" on Linux,but while FreeBSD is running. I have no idea at the moment how to do that,because they are different operating systems. But maybe,can I use the Linuxulator ? assuming that the userland is the host os itself (devuan 5),instead of creating a new,fresh userland directly on FreeBSD...unfortunately I'm on arm,so I have some doubts that the Linuxlator works there.
I would like to gather some opinions to understand if the idea is doable. Thanks.
I'm trying to configure the network of my host os (Linux Devuan 5) and of my guest OS (FreeBSD 13.2) because I want to have the connection inside the FreeBSD VM,that I have virtualized with qemu / kvm / libvirt on my ARM Chromebook. The procedure that I have explained below is working,nevertheless there is still something to fix. This is what I did :
1) Shut down libvirt
2) Created a bridge br1 manually without any slaves :
Code:
# ip link add name br1 type bridge
3) Added "allow all" to that bridge helper file (bridge.conf, located on /usr/local/etc/qemu/bridge.conf)
4) Started a VM with qemu only, telling it to use a bridge interface "br1". This creates a tap interface "tap0" which is a slave of a bridge "br1"
5) Right after VM start, explicitly set link br1 to "up" :
Code:
# ip link set br1 up
6) Configured an IP address from within the VM in a new subnet (192.168.20.2/24)
7) Configured IP address in the same subnet for br1 on KVM host (192.168.20.1/24). No IP should be assigned to the tap interface :
Code:
# ip a add 192.168.20.1/24 dev br1
8) Configured MASQUERADING for traffic leaving through my standard home interface on the KVM host:
Code:
# iptables -t nat -A POSTROUTING -o mlan0 -j MASQUERADE
9) Enabled Routing :
Code:
# echo 1 > /proc/sys/net/ipv4/ip_forward
That's it. The VM could ping everything,but another step is necessary. When the VM booted totally,until the login prompt,I should open a new terminal and do :
Code:
# ip a fl dev tap0
This is a dirty workaround that I don't like too much,but it removes the fake IP address169.254.89.8 from the tap0 and in this way I can ping the world while I'm using the VM. Every time I start a new VM,a new (and always the same) fake ip [169.254.35.253] is assigned to the tap interface and I should delete it everytime WHEN the vm has been fully loaded and it reached the login prompt (really I don't know what's the exact moment when the tap0 is created,so I've assumed that the right time is when the VM reached the login prompt). When this happens,an automatic script should be executed :
Code:
/bin/ip a fl dev tap0
otherwise I cannot ping an external domain from within the vm and I will get the error "host unknown". Now,I don't know how to automate the process. What I want to do is to execute that command after 50 seconds that the qemu parameters below are executed :
Code:
qemu-system-arm \
-enable-kvm -serial stdio \
-m 1024 -M virt -cpu cortex-a15 \
-drive if=pflash,format=raw,unit=0,file=$UEFICODE1 \
-drive if=pflash,format=raw,unit=1,file=$UEFIVARS2 \
-drive file=$DISK,media=disk,format=raw \
-net nic,model=virtio,macaddr=52:54:00:00:00:01 -net bridge,br=br1 \
-device virtio-gpu-pci \
-usb -device nec-usb-xhci \
-device usb-kbd -device usb-mouse \
-device vmware-svga,id=video0,vgamem_mb=16
because this is the time that the qemu parameters need to create the tap0 with the fake IP = 169.254.35.253 that should be deleted.
You know,It's very annoying to start every time a new terminal (because the terminal where the qemu parameters are running is busy) and writing "/bin/ip a fl dev tap0" inside it.
I've tried several methods to execute that command on the Linux OS while the FreeBSD vm was booting,but none of those methods worked. Now,I've got an idea for a new (interesting,from my point of view) approach to solve the "problem". What about to try to execute that command when FreeBSD is running ? It could be something like this :
1) I enable the automatic login on FreeBSD when the login prompt is ready,by configuring username and password in the right config file (In Linux usually I modify the file /etc/gdm3/custom.conf)
2) while FreeBSD is running or some time before it reaches the login prompt,I would like to run the command that I've shown above "/bin/ip a fl dev tap0" on Linux,but while FreeBSD is running. I have no idea at the moment how to do that,because they are different operating systems. But maybe,can I use the Linuxulator ? assuming that the userland is the host os itself (devuan 5),instead of creating a new,fresh userland directly on FreeBSD...unfortunately I'm on arm,so I have some doubts that the Linuxlator works there.
I would like to gather some opinions to understand if the idea is doable. Thanks.