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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Create TAP interface tap0 | |
Before=network-pre.target | |
Wants=network-pre.target | |
DefaultDependencies=no | |
[Service] | |
Type=oneshot | |
ExecStart=/sbin/ip tuntap add dev tap0 mode tap user u1 | |
ExecStartPost=/sbin/ip link set tap0 up | |
RemainAfterExit=yes | |
[Install] | |
WantedBy=multi-user.target |
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
u1@m18:~$ mkdir ~/backup u1@m18:~$ cd /etc/netplan u1@m18:~$ sudo mv * ~/backup
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
network: | |
version: 2 | |
renderer: networkd | |
ethernets: | |
ens33: | |
dhcp4: no | |
dhcp6: no | |
tap0: | |
optional: true | |
bridges: | |
br0: | |
interfaces: [ens33, tap0] # Added tap0 here | |
dhcp4: yes | |
dhcp6: no | |
parameters: | |
stp: true | |
forward-delay: 4 |
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
u1@m18:~$ sudo netplan apply
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:
Post a Comment