QEMU can bridge guest networking to the host via several backends: user-mode networking (simple, no root), tap devices (full performance, requires root), or socket-based for inter-VM communication.
# User-mode networking (default, no root needed) qemu-system-x86_64 -nic user,hostfwd=tcp:127.0.0.1:2222-:22 disk.img # Tap device (bridged, full speed, needs root) sudo qemu-system-x86_64 -nic tap,ifname=tap0,script=no disk.img # No networking qemu-system-x86_64 -nic none disk.img
User-mode networking is the default and needs no setup. The guest gets a DHCP-assigned 10.0.2.x address and can reach the outside world and the host's loopback (127.0.0.1). Port forwarding with hostfwd= exposes guest services on the host: hostfwd=tcp:127.0.0.1:2222-:22 maps host port 2222 to guest port 22 (SSH).
User-mode is slow (host does syscall translation for each packet) and doesn't support all protocols (UDP spoofing breaks some applications). Good for testing; use tap for production.
Tap devices are Linux virtual network interfaces that QEMU can attach to. Setup:
sudo ip tuntap add dev tap0 mode tap user $USER sudo ip link set tap0 up qemu-system-x86_64 -nic tap,ifname=tap0,script=no disk.img
-nic tap bypasses the QEMU network script system and uses a pre-configured tap device. The guest can reach the host's real network at full speed.
Bridge networking connects multiple VMs and the host to the same broadcast domain:
sudo brctl addbr br0 sudo brctl addif br0 eth0 sudo ip link set br0 up sudo qemu-system-x86_64 -nic bridge,br=br0 disk.img
All VMs and the host share the same network segment. VMs get real IP addresses from your DHCP server or static assignment.
For embedded (non-networked) testing, use -nic none to skip the network entirely—faster and simpler.