Wednesday, May 07, 2025

Configuring TUN/TAP virtual network interface for use with QEMU on Xubuntu 24.04

Configuring TUN/TAP virtual network interface for use with QEMU on Xubuntu 24.04

I am planning to run qemu-system-ppc to play around QEMU and PPC with networking support. The quest and U-Boot will need to interact with external services, namely, tftp. The recommended network is to have TUN/TAP virtual network interface configured on the host. My host is Xubuntu 24.04/Ubuntu 24.04.

Let's start by creating tap0 using systemd
u1@m18:~$ sudo nvim /etc/systemd/system/tap0.service
Copy/paste content below Change u1 to the user who needs access to tap0

Run command below to create tap0. This should also presist after reboot
u1@m18:~$ sudo systemctl daemon-reexec
u1@m18:~$ sudo systemctl enable --now tap0.service
Create a backup of existing netplan configuration
u1@m18:~$ mkdir ~/backup
u1@m18:~$ cd /etc/netplan
u1@m18:~$ sudo mv * ~/backup
Create new netplan configuration, let us call it 01-netcfg.yaml
u1@m18:~$ sudo touch /etc/netplan01-netcfg.yaml
u1@m18:~$ sudo chmod 600 /etc/netplan/01-netcfg.yaml
u1@m18:~$ sudo nvim /etc/netplan/01-netcfg.yaml
Copy/paste gist below into 01-netcfg.yaml. Note that ens33 is my interface name, so update that as appropriate.

Now disable Network Manager and enable networkd. The command below will reconfure your network, so you need to be on the console and not via ssh.
u1@m18:~$ sudo systemctl stop NetworkManager.service
u1@m18:~$ sudo systemctl disable NetworkManager.service
u1@m18:~$ sudo systemctl start systemd-networkd.service
u1@m18:~$ sudo systemctl enable systemd-networkd.service
Now apply netplan configuration
u1@m18:~$ sudo netplan apply
Running QEMU below and issuing dhcp at U-boot prompt should allow the guest to get IP address from DHCP server. Of course, I am assuming that there is DHCP server in the network.
u1@m18:~$ qemu-system-ppc -M mpc8544ds -cpu mpc8540 -m 512 -nographic -netdev tap,id=net0,ifname=tap0,script=no,downscript=no -device e1000,netdev=net0 -serial mon:stdio

No comments:

Fedora install screen chronicle

Fedora install screen chronicle Below are links to Fedora installation screens. It is interesting to see how it has evolved over time. Fe...