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?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.