247 |
|
|
248 |
@table @option |
@table @option |
249 |
|
|
250 |
@item -n script |
@item -net nic[,vlan=n][,macaddr=addr] |
251 |
Set TUN/TAP network init script [default=/etc/qemu-ifup]. This script |
Create a new Network Interface Card and connect it to VLAN @var{n} (@var{n} |
252 |
is launched to configure the host network interface (usually tun0) |
= 0 is the default). The NIC is currently an NE2000 on the PC |
253 |
corresponding to the virtual NE2000 card. |
target. Optionally, the MAC address can be changed. If no |
254 |
|
@option{-net} option is specified, a single NIC is created. |
255 |
|
|
256 |
|
@item -net user[,vlan=n] |
257 |
|
Use the user mode network stack which requires not administrator |
258 |
|
priviledge to run. This is the default if no @option{-net} option is |
259 |
|
specified. |
260 |
|
|
261 |
|
@item -net tap[,vlan=n][,fd=h][,ifname=name][,script=file] |
262 |
|
Connect the host TAP network interface @var{name} to VLAN @var{n} and |
263 |
|
use the network script @var{file} to configure it. The default |
264 |
|
network script is @file{/etc/qemu-ifup}. If @var{name} is not |
265 |
|
provided, the OS automatically provides one. @option{fd=h} can be |
266 |
|
used to specify the handle of an already opened host TAP interface. Example: |
267 |
|
|
268 |
@item -nics n |
@example |
269 |
|
qemu linux.img -net nic -net tap |
270 |
|
@end example |
271 |
|
|
272 |
|
More complicated example (two NICs, each one connected to a TAP device) |
273 |
|
@example |
274 |
|
qemu linux.img -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \ |
275 |
|
-net nic,vlan=1 -net tap,vlan=1,ifname=tap1 |
276 |
|
@end example |
277 |
|
|
|
Simulate @var{n} network cards (the default is 1). |
|
278 |
|
|
279 |
@item -macaddr addr |
@item -net socket[,vlan=n][,fd=h][,listen=[host]:port][,connect=host:port] |
280 |
|
|
281 |
Set the mac address of the first interface (the format is |
Connect the VLAN @var{n} to a remote VLAN in another QEMU virtual |
282 |
aa:bb:cc:dd:ee:ff in hexa). The mac address is incremented for each |
machine using a TCP socket connection. If @option{listen} is |
283 |
new network interface. |
specified, QEMU waits for incoming connections on @var{port} |
284 |
|
(@var{host} is optional). @option{connect} is used to connect to |
285 |
|
another QEMU instance using the @option{listen} option. @option{fd=h} |
286 |
|
specifies an already opened socket. |
287 |
|
|
288 |
@item -tun-fd fd |
Example: |
289 |
Assumes @var{fd} talks to a tap/tun host network interface and use |
@example |
290 |
it. Read @url{http://bellard.org/qemu/tetrinet.html} to have an |
# launch a first QEMU instance |
291 |
example of its use. |
qemu linux.img -net nic -net socket,listen=:1234 |
292 |
|
# connect the VLAN 0 of this instance to the VLAN 0 of the first instance |
293 |
|
qemu linux.img -net nic -net socket,connect=127.0.0.1:1234 |
294 |
|
@end example |
295 |
|
|
296 |
@item -user-net |
@item -net none |
297 |
Use the user mode network stack. This is the default if no tun/tap |
Indicate that no network devices should be configured. It is used to |
298 |
network init script is found. |
override the default configuration which is activated if no |
299 |
|
@option{-net} options are provided. |
300 |
|
|
301 |
@item -tftp prefix |
@item -tftp prefix |
302 |
When using the user mode network stack, activate a built-in TFTP |
When using the user mode network stack, activate a built-in TFTP |
354 |
Then when you use on the host @code{telnet localhost 5555}, you |
Then when you use on the host @code{telnet localhost 5555}, you |
355 |
connect to the guest telnet server. |
connect to the guest telnet server. |
356 |
|
|
|
@item -dummy-net |
|
|
Use the dummy network stack: no packet will be received by the network |
|
|
cards. |
|
|
|
|
357 |
@end table |
@end table |
358 |
|
|
359 |
Linux boot specific. When using this options, you can use a given |
Linux boot specific: When using these options, you can use a given |
360 |
Linux kernel without installing it in the disk image. It can be useful |
Linux kernel without installing it in the disk image. It can be useful |
361 |
for easier testing of various kernels. |
for easier testing of various kernels. |
362 |
|
|
544 |
|
|
545 |
@table @option |
@table @option |
546 |
@item info network |
@item info network |
547 |
show the network state |
show the various VLANs and the associated devices |
548 |
@item info block |
@item info block |
549 |
show the block devices |
show the block devices |
550 |
@item info registers |
@item info registers |
723 |
|
|
724 |
@section Network emulation |
@section Network emulation |
725 |
|
|
726 |
QEMU simulates up to 6 networks cards (NE2000 boards). Each card can |
QEMU can simulate several networks cards (NE2000 boards on the PC |
727 |
be connected to a specific host network interface. |
target) and can connect them to an arbitrary number of Virtual Local |
728 |
|
Area Networks (VLANs). Host TAP devices can be connected to any QEMU |
729 |
@subsection Using tun/tap network interface |
VLAN. VLAN can be connected between separate instances of QEMU to |
730 |
|
simulate large networks. For simpler usage, a non priviledged user mode |
731 |
This is the standard way to emulate network. QEMU adds a virtual |
network stack can replace the TAP device to have a basic network |
732 |
network device on your host (called @code{tun0}), and you can then |
connection. |
733 |
configure it as if it was a real ethernet card. |
|
734 |
|
@subsection VLANs |
735 |
|
|
736 |
|
QEMU simulates several VLANs. A VLAN can be symbolised as a virtual |
737 |
|
connection between several network devices. These devices can be for |
738 |
|
example QEMU virtual Ethernet cards or virtual Host ethernet devices |
739 |
|
(TAP devices). |
740 |
|
|
741 |
|
@subsection Using TAP network interfaces |
742 |
|
|
743 |
|
This is the standard way to connect QEMU to a real network. QEMU adds |
744 |
|
a virtual network device on your host (called @code{tapN}), and you |
745 |
|
can then configure it as if it was a real ethernet card. |
746 |
|
|
747 |
As an example, you can download the @file{linux-test-xxx.tar.gz} |
As an example, you can download the @file{linux-test-xxx.tar.gz} |
748 |
archive and copy the script @file{qemu-ifup} in @file{/etc} and |
archive and copy the script @file{qemu-ifup} in @file{/etc} and |
749 |
configure properly @code{sudo} so that the command @code{ifconfig} |
configure properly @code{sudo} so that the command @code{ifconfig} |
750 |
contained in @file{qemu-ifup} can be executed as root. You must verify |
contained in @file{qemu-ifup} can be executed as root. You must verify |
751 |
that your host kernel supports the TUN/TAP network interfaces: the |
that your host kernel supports the TAP network interfaces: the |
752 |
device @file{/dev/net/tun} must be present. |
device @file{/dev/net/tun} must be present. |
753 |
|
|
754 |
See @ref{direct_linux_boot} to have an example of network use with a |
See @ref{direct_linux_boot} to have an example of network use with a |
755 |
Linux distribution. |
Linux distribution and @ref{sec_invocation} to have examples of |
756 |
|
command lines using the TAP network interfaces. |
757 |
|
|
758 |
@subsection Using the user mode network stack |
@subsection Using the user mode network stack |
759 |
|
|
760 |
By using the option @option{-user-net} or if you have no tun/tap init |
By using the option @option{-net user} (default configuration if no |
761 |
script, QEMU uses a completely user mode network stack (you don't need |
@option{-net} option is specified), QEMU uses a completely user mode |
762 |
root priviledge to use the virtual network). The virtual network |
network stack (you don't need root priviledge to use the virtual |
763 |
configuration is the following: |
network). The virtual network configuration is the following: |
764 |
|
|
765 |
@example |
@example |
766 |
|
|
767 |
QEMU Virtual Machine <------> Firewall/DHCP server <-----> Internet |
QEMU VLAN <------> Firewall/DHCP server <-----> Internet |
768 |
(10.0.2.x) | (10.0.2.2) |
| (10.0.2.2) |
769 |
| |
| |
770 |
----> DNS server (10.0.2.3) |
----> DNS server (10.0.2.3) |
771 |
| |
| |
774 |
|
|
775 |
The QEMU VM behaves as if it was behind a firewall which blocks all |
The QEMU VM behaves as if it was behind a firewall which blocks all |
776 |
incoming connections. You can use a DHCP client to automatically |
incoming connections. You can use a DHCP client to automatically |
777 |
configure the network in the QEMU VM. |
configure the network in the QEMU VM. The DHCP server assign addresses |
778 |
|
to the hosts starting from 10.0.2.15. |
779 |
|
|
780 |
In order to check that the user mode network is working, you can ping |
In order to check that the user mode network is working, you can ping |
781 |
the address 10.0.2.2 and verify that you got an address in the range |
the address 10.0.2.2 and verify that you got an address in the range |
792 |
redirected from the host to the guest. It allows for example to |
redirected from the host to the guest. It allows for example to |
793 |
redirect X11, telnet or SSH connections. |
redirect X11, telnet or SSH connections. |
794 |
|
|
795 |
|
@subsection Connecting VLANs between QEMU instances |
796 |
|
|
797 |
|
Using the @option{-net socket} option, it is possible to make VLANs |
798 |
|
that span several QEMU instances. See @ref{sec_invocation} to have a |
799 |
|
basic example. |
800 |
|
|
801 |
@node direct_linux_boot |
@node direct_linux_boot |
802 |
@section Direct Linux Boot |
@section Direct Linux Boot |
803 |
|
|