Note that from inside the guest, connecting to a port on the "gateway" IP address will connect to that port on the host so for instance "ssh 10.0.2.2" will ssh from the guest to the host.
User Networking is implemented using "slirp", which provides a full TCP/IP stack within QEMU and uses that stack to implement a virtual NAT'd network.Ī typical (default) network is shown below.
In most cases, if you don't have any specific networking requirements other than to be able to access to a web page from your guest, user networking (slirp) is a good choice. The name is used to distinguish backends from each other and must be used even when only one backend is specified. If you want multiple virtual network devices inside the guest they each need their own network backend. The id option gives the name by which the virtual network device and the network backend are associated with each other. There are a number of network backends to choose from depending on your environment.
Network Backends How to create a network backend? QEMU Networking on bsdwiki, showing used networking principles and dealing with BSD hosts.QEMU Networking on, mainly dealing with Linux hosts.Note - As this page is probably very brief or even incomplete you might find these pages rather useful: Don't try to use ping to test your QEMU network configuration! Note - if you are using the (default) SLiRP user networking, then ping (ICMP) will not work, though TCP and UDP will. (Forgetting to specify the backend or the network device will give a warning message such as "Warning: netdev mynet0 has no peer", "Warning: hub 0 is not connected to host network" or "Warning: hub 0 with no nics" the VM will then boot but will not have functioning networking.) Note - if you specify any networking options on the command line (via -net or -netdev) then QEMU will require you to provide options sufficient to define and connect up both parts.
By default QEMU will create a SLiRP user network backend and an appropriate virtual network device for the guest (eg an E1000 PCI card for most x86 PC guests), as if you had typed -net nic -net user on your command line. There are a range of options for each part. the network backend that interacts with the emulated NIC (e.g.the virtual network device that is provided to the guest (e.g.There are two parts to networking within QEMU: 6.2.6 Windows 2000, Windows XP, Windows 7.5.2 How to use tap with a wireless adapter on the host.3.1 How to create a virtual network device?.
2.2.1.2 Advanced user networking options.2.2.1.1 Enabling ping in the guest, on Linux hosts.