I am trying to boot a virtual machine with my a custom IP address using qemu-system-x86_64
. Referring to qemu-system-x86_64
's tutorials, I found this:
-net nic[,vlan=n][,macaddr=mac][,model=type] [,name=name][,addr=addr][,vectors=v] Create a new Network Interface Card and connect it to VLAN n (n = 0 is the default). The NIC is an e1000 by default on the PC target. -netdev user,id=id[,option][,option][,...]
-net user[,option][,option][,...]
Use the user mode network stack which requires no administrator privilege to run.
I am not able to understand the difference between these two options.
nic
and user
parameters?< QEMU. QEMU supports networking by emulating some popular network cards (NICs), and establishing virtual LANs (VLAN). There are four ways that QEMU guests can be connected: user mode, socket redirection, Tap and VDE networking.
So to conclude: QEMU is a type 2 hypervisor that runs within user space and performs virtual hardware emulation, whereas KVM is a type 1 hypervisor that runs in kernel space, that allows a user space program access to the hardware virtualization features of various processors.
QEMU can emulate a complete machine in software without requiring any hardware virtualization support. Although this is a much less performant method of virtualization, it removes any potential conflicts with the underlying hardware, as QEMU 5.0 supports x86, PowerPC, ARM and SPARC architectures.
VirtualBox is faster and has a better UI than QEMU. It's also a good choice only for x86 and x64 architectures.
To anwser your last question first, you need both options:
qemu <other options> -net nic[,options] -net user[,options]
With this configuration your guest can see the Internet and can also connect to services on the host at 10.0.2.2
If you want to access services on the guest you need to use hostfwd
qemu <other options> -net user,hostfwd=tcp::60022-:22
This will let you do the following to access ssh on the guest from the host:
ssh -p60022 user@localhost
The options to -net nic you can use to change the type of network card from the default for the qemu platform in use. For example if your guest is running an older operating system you might prefer to use -net nic,model=ne2k_pci
over the default e1000
.
To use a custom IP address you need to follow the tutorials that make a bridge and connect both your host and guest. The -net user
option is far simpler if you just want to run up a guest to do some work in a different O/S.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With