Talk:QEMU/Networking

Start/stop firewall
It willn't work on debian, archlinux, frugalware, slackware and other distros. Remove it.
 * Why would it not work? --IsmaelLuceno (discuss • contribs) 08:26, 25 May 2012 (UTC)

Example scripts qemu-ifup qemu-ifdown
I would suggest to split the bridge setup and the qemu-if[up,down] scripts. The current version only supports one tap device, which is not the way the qemu-if[up,down] scripts were ment to be used. I would propose the following change:

To use tap add the following to the qemu command line -net nic -net tap,ifname=$TAP Where $TAP can be something from tap0 to tapn.

A simple setup could consist of one bridge which bridges all qemu tap interfaces to the outside network. For this you need to setup the bridge once. After that you also need to create a tap device for each vm and add it to the bridge. The following scripts do this for you. bridge-up and down need to be called once by you. qemu-ifup and qemu-ifdown are called by qemu if they are in the right place.

Required packages (debian):
 * openvpn (for creating tap devices)
 * bridge-utils (for creating bridge)

Create the following scripts.

bridge-up
INETADDR=192.168.0.10 GATEWAY=192.168.0.1 NETMASK=255.255.255.0 BROADCAST=192.168.0.255 INTERFACE=eth0 BRIDGE=br0 ifdown $INTERFACE ifconfig $INTERFACE 0.0.0.0 promisc up brctl addbr $BRIDGE brctl addif $BRIDGE $INTERFACE ifconfig $BRIDGE $INETADDR netmask $NETMASK broadcast $BROADCAST route add default gw $GATEWAY
 * 1) !/bin/sh
 * 2) script to bring up the tun device in QEMU in bridged mode
 * 3) first parameter is name of tap device (e.g. tap0)
 * 4) some constants specific to the local host - change to suit your host
 * 1) some constants specific to the local host - change to suit your host
 * 1) some constants specific to the local host - change to suit your host
 * 1) First take the interface down, then bring it up with IP address 0.0.0.0
 * 1) First take the interface down, then bring it up with IP address 0.0.0.0
 * 1) Bring up the bridge with INETADDR and add the default route
 * 1) Bring up the bridge with INETADDR and add the default route

bridge-down
INTERFACE=eth0 BRIDGE=br0
 * 1) !/bin/sh
 * 2) Script to bring down and delete bridge br0 when QEMU exits
 * 3) Bring down eth0 and br0
 * 1) Bring down eth0 and br0
 * 1) Bring down eth0 and br0

ifdown $INTERFACE ifdown $BRIDGE ifconfig $BRIDGE down brctl delbr $BRIDGE ifconfig $INTERFACE -promisc ifup eth0
 * 1) Delete the bridge
 * 1) Delete the bridge
 * 1) bring up interface in "normal" mode
 * 1) bring up interface in "normal" mode

/etc/qemu-ifup
BRIDGE=br0
 * 1) !/bin/sh

openvpn --mktun --dev $1 --user `id -un` ifconfig $1 0.0.0.0 promisc up brctl addif $BRIDGE $1

/etc/qemu-ifdown
BRIDGE=br0
 * 1) !/bin/sh

ifconfig $1 down brctl delif $BRIDGE $1 openvpn --rmtun --dev $1 146.52.49.74 (discuss) 10:09, 22 January 2014 (UTC)

mount
mount -t cifs //localhost/someshare /mnt/qemu -o user=test,pass=test,dom=workgroup,port=5556

Can someone explain how to make this work?

Getting guests to talk with each other
How can two or more QEMU guests connect? For example, what is needed so that it is possible to ssh from one guest to another? Or for the web client of one guest to reach a web server on another? Larsnooden (discuss • contribs) 20:17, 11 June 2016 (UTC)

Obsolete options, -net and -netdev
Hi, the manual page for qemu 1:3.1 in Debian 10 states,
 * -net nic ...
 * Legacy option to configure or create an on-board (or machine default) ..."

There is now a -nic option combining the capabilities of -net and -netdev.
 * -nic
 * [tap|bridge|user ...
 * This option is a shortcut for configuring both the on-board (default) guest NIC hardware and the host network backend in one go. ...

Ideally this wikibook should be revised according to the changes.

Thx,    .... PeterEasthope (discuss • contribs) 22:23, 10 March 2021 (UTC)