This post is about Qemu -nic
. Qemu uses several networking options such as SLIRP, TAP or bridge (those the ones I tried anyway).
-nic
replaces -net
and combines the functionality of -device
and -netdev
. -nic
takes the backend and device type to choose the network configuration between host and guest.
-nic <backend>,<parameters>
User mode Link to heading
Also known as SLIRP. This allows VM to access the internet through NAT provided by the host. In this mode, the gust is not accessible from the host (unless port forwarding is enabled).
qemu-system-x86_64 \
-enable-kvm \
-m 2048 \
-nic user,model=e1000 \
-drive file=linux-2027-qemu-amd64.qcow2,media=disk,if=virtio
TAP Link to heading
The TAP option is more complicated as it works by creating layer 2 tap. It enables the guest to have IP on the host network (From DHCP). The catch with this one it needs root access to create tap and attach the guest to it.
sudo ip tuntap add tap0 mode tap
sudo ip link set tap0 up
qemu-system-x86_64 -nic tap,ifname=tap0,script=no,downscript=no
Bridge Link to heading
This one is most advanced as it creates a bridge on the host and the guest is attached to bridge.
qemu-system-x86_64 -nic bridge,br=br0
qemu-system-x86_64 \
-enable-kvm \
-m 2048 \
-nic user,model=virtio \
-drive file=linux-2027-qemu-amd64.qcow2,media=disk,if=virtio