All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] several guests with static ip-address
@ 2005-10-25 20:35 Michael
  2005-10-26  5:59 ` Henrik Nordstrom
  0 siblings, 1 reply; 6+ messages in thread
From: Michael @ 2005-10-25 20:35 UTC (permalink / raw)
  To: qemu-devel

hi qemu list,

is it possible, that several (for example two) guests communicate to one
qemu host, which has only one network interface and every os has it's
own static ip-address?

For me, only one guest and a qemu host with static ip-address
configuration communicate with each other (and with the router, all are
in the same subnet over a tun/bridge interface), but when i would bring
up a second guest os that should communicate with the qemu host (all
with static ip-addresses) it doesn't work.

With two network interfaces  (for two guests) on the qemu host it should
work i think, but with only one?

thanks for any help!

Michael

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] several guests with static ip-address
  2005-10-25 20:35 [Qemu-devel] several guests with static ip-address Michael
@ 2005-10-26  5:59 ` Henrik Nordstrom
  2005-10-26  8:04   ` Michael Kapp
  0 siblings, 1 reply; 6+ messages in thread
From: Henrik Nordstrom @ 2005-10-26  5:59 UTC (permalink / raw)
  To: qemu-devel

On Tue, 25 Oct 2005, Michael wrote:

> is it possible, that several (for example two) guests communicate to one
> qemu host, which has only one network interface and every os has it's
> own static ip-address?

Yes, with TUN networking this works fine. Have used this in

   - bridged including the host interface, giving each QEMU a static ip on 
the LAN.

   - non-bridged, routing via the host, with masquerade firewall rules on 
the host to allow traffic to the LAN. Each qemu in a separate network to 
simplify the host side.

   - vde, routing via the host, with masquerade firewall rules on the host 
for allowing traffic to the LAN. All the qemu instances in the same 
network (but different host addresses).

   - bridged, not including the host interface. Same as vde.

All this is with only one network interface on the host.

Note: when using tun, each qemu instance gets it's own virtual tun/tap 
interface on the host.

Note2: The vde based setup is generally the simplest to get correct.

Regards
Henrik

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] several guests with static ip-address
  2005-10-26  5:59 ` Henrik Nordstrom
@ 2005-10-26  8:04   ` Michael Kapp
  2005-10-26 21:05     ` Henrik Nordstrom
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Kapp @ 2005-10-26  8:04 UTC (permalink / raw)
  To: qemu-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 1785 bytes --]

> On Tue, 25 Oct 2005, Michael wrote:
> 
> > is it possible, that several (for example two) guests communicate to one
> > qemu host, which has only one network interface and every os has it's
> > own static ip-address?
> 
> Yes, with TUN networking this works fine. Have used this in
> 
>    - bridged including the host interface, giving each QEMU a static ip on
> the LAN.
> 
>    - non-bridged, routing via the host, with masquerade firewall rules on 
> the host to allow traffic to the LAN. Each qemu in a separate network to 
> simplify the host side.
> 
>    - vde, routing via the host, with masquerade firewall rules on the host
> for allowing traffic to the LAN. All the qemu instances in the same 
> network (but different host addresses).
> 
>    - bridged, not including the host interface. Same as vde.
> 
> All this is with only one network interface on the host.
> 
> Note: when using tun, each qemu instance gets it's own virtual tun/tap 
> interface on the host.
> 
> Note2: The vde based setup is generally the simplest to get correct.

---

OK, can you give me some hints how to do that?

I've tested it with a tun/bridged setup, but it only work with one guest,
here is my configuration for the qemu-ifup script:

--
 
ifconfig eth0 down
brctl addbr br0
ifconfig eth0 0.0.0.0 promisc up

ifconfig tun1 0.0.0.0 promisc up

ifconfig br0 192.168.1.3 netmask 255.255.255.0 broadcast 192.168.1.255 up
brctl stp br0 off
brctl setfd br0 1
brctl sethello br0 1
brctl addif br0 eth0
brctl addif br0 tun1
route add default gw 192.168.1.1

--

...this works so far. But how can i get another guest into this subnet?

Regards,
Michael

-- 
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] several guests with static ip-address
  2005-10-26  8:04   ` Michael Kapp
@ 2005-10-26 21:05     ` Henrik Nordstrom
  2005-10-27 12:31       ` Michael Kapp
  0 siblings, 1 reply; 6+ messages in thread
From: Henrik Nordstrom @ 2005-10-26 21:05 UTC (permalink / raw)
  To: qemu-devel

On Wed, 26 Oct 2005, Michael Kapp wrote:

> OK, can you give me some hints how to do that?
>
> I've tested it with a tun/bridged setup, but it only work with one guest,
> here is my configuration for the qemu-ifup script:

Each qemu gets it's own tun device, and you need to make sure your script 
gets this proper...

I've never used any qemu-ifup scripts. Very much prefer using static tun 
interfaces, and when I forget I usually set up the host configuration 
manually as root while qemu is running..

> ...this works so far. But how can i get another guest into this subnet?

It's just about adding his tun device to the same bridge, and giving it 
"link up"..

Regards
Henrik

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] several guests with static ip-address
  2005-10-26 21:05     ` Henrik Nordstrom
@ 2005-10-27 12:31       ` Michael Kapp
  2005-10-27 13:31         ` Mario Goppold
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Kapp @ 2005-10-27 12:31 UTC (permalink / raw)
  To: qemu-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 1722 bytes --]

> On Wed, 26 Oct 2005, Michael Kapp wrote:
> 
> > OK, can you give me some hints how to do that?
> >
> > I've tested it with a tun/bridged setup, but it only work with one
> guest,
> > here is my configuration for the qemu-ifup script:
> 
> Each qemu gets it's own tun device, and you need to make sure your script 
> gets this proper...
> 
> I've never used any qemu-ifup scripts. Very much prefer using static tun 
> interfaces, and when I forget I usually set up the host configuration 
> manually as root while qemu is running..
> 
> > ...this works so far. But how can i get another guest into this subnet?
> 
> It's just about adding his tun device to the same bridge, and giving it 
> "link up"..

----

OK, this is the solution for the qemu-ifup scripts (or do it with static
interfaces):

guest1:

brctl addbr br0

ifconfig eth0 down
ifconfig eth0 0.0.0.0 promisc up
ifconfig tun1 0.0.0.0 promisc up
ifconfig br0 192.168.1.98 netmask 255.255.255.0 broadcast 192.168.1.255 up

brctl stp br0 off
brctl setfd br0 1
brctl sethello br0 1
brctl addif br0 eth0
brctl addif br0 tun1
route add default gw 192.168.1.1

--

guest2 (will be started after guest1 is up):

ifconfig tun2 0.0.0.0 promisc up

brctl addif br0 tun2

...and so on, for other guests...
----

That the two guests can communicate with each other, it is neccassary to
bring up the guests with a unique mac-address.

Thanks!

Regards 
Michael


> Regards
> Henrik
> 
> 
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
> 

-- 
10 GB Mailbox, 100 FreeSMS/Monat http://www.gmx.net/de/go/topmail
+++ GMX - die erste Adresse für Mail, Message, More +++

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] several guests with static ip-address
  2005-10-27 12:31       ` Michael Kapp
@ 2005-10-27 13:31         ` Mario Goppold
  0 siblings, 0 replies; 6+ messages in thread
From: Mario Goppold @ 2005-10-27 13:31 UTC (permalink / raw)
  To: qemu-devel

Hi list,

i had the same problem and here is qemu-ifup:

#!/bin/sh
(

# chgrp users /dev/net/tun
# chmod g+w /dev/net/tun

# set -x
MYIP=192.168.0.1

/bin/logger -t $0 "Start for $1"
found=0
DEVS=`/sbin/ifconfig | /bin/awk '/^qbridge/ { print $1 }'`
for D in $DEVS; do
   IP=$(LANG=C /sbin/ifconfig $D | /bin/awk '/inet addr:/ {print substr($2, 
6)}')
   if [ "$IP" == "$MYIP" ]; then
      found=1
   fi
done
/bin/logger -t $0 "found qbridge ? : $found"
if [ $found -eq 0 ]; then
   /sbin/modprobe tun
   /sbin/modprobe bridge
   /bin/logger -t $0 "create qbridge"
   /sbin/brctl addbr qbridge
   /sbin/brctl stp qbridge off
   /sbin/brctl setfd qbridge 1
   /sbin/brctl sethello qbridge 1
   /bin/logger -t $0 "add $1 to qbridge"
   /sbin/brctl addif qbridge $1
   S=`ls -l /dev/net/tun`
   /bin/logger -t $0 "set up $1 $S"
   /sbin/ifconfig $1 0.0.0.0 promisc up
   /sbin/ifconfig qbridge $MYIP netmask 255.255.0.0
   /usr/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
   /sbin/sysctl net.ipv4.ip_forward=1
else
   /bin/logger -t $0 "add $1 to qbridge"
   /sbin/brctl addif qbridge $1
   /sbin/ifconfig $1 0.0.0.0 promisc up
fi

) >> /var/log/qemu-ifup.log 2>&1


This adds the tun? devices to qbridge. You can communicate form host to guest 
and between the guests but you MUST set the mac-sdress at the commandline:

qemu -macaddr 00:01:01:01:01:01 -hda /localhome/qemu/test1.img
qemu -macaddr 00:01:01:01:01:02 -hda /localhome/qemu/test2.img

Have a lot of fun ...
Mario

Am Donnerstag, 27. Oktober 2005 14:31 schrieb Michael Kapp:
> > On Wed, 26 Oct 2005, Michael Kapp wrote:
> > > OK, can you give me some hints how to do that?
> > >
> > > I've tested it with a tun/bridged setup, but it only work with one
> >
> > guest,
> >
> > > here is my configuration for the qemu-ifup script:
> >
> > Each qemu gets it's own tun device, and you need to make sure your script
> > gets this proper...
> >
> > I've never used any qemu-ifup scripts. Very much prefer using static tun
> > interfaces, and when I forget I usually set up the host configuration
> > manually as root while qemu is running..
> >
> > > ...this works so far. But how can i get another guest into this subnet?
> >
> > It's just about adding his tun device to the same bridge, and giving it
> > "link up"..
>
> ----
>
> OK, this is the solution for the qemu-ifup scripts (or do it with static
> interfaces):
>
> guest1:
>
> brctl addbr br0
>
> ifconfig eth0 down
> ifconfig eth0 0.0.0.0 promisc up
> ifconfig tun1 0.0.0.0 promisc up
> ifconfig br0 192.168.1.98 netmask 255.255.255.0 broadcast 192.168.1.255 up
>
> brctl stp br0 off
> brctl setfd br0 1
> brctl sethello br0 1
> brctl addif br0 eth0
> brctl addif br0 tun1
> route add default gw 192.168.1.1
>
> --
>
> guest2 (will be started after guest1 is up):
>
> ifconfig tun2 0.0.0.0 promisc up
>
> brctl addif br0 tun2
>
> ...and so on, for other guests...
> ----
>
> That the two guests can communicate with each other, it is neccassary to
> bring up the guests with a unique mac-address.
>
> Thanks!
>
> Regards
> Michael
>
> > Regards
> > Henrik
> >
> >
> > _______________________________________________
> > Qemu-devel mailing list
> > Qemu-devel@nongnu.org
> > http://lists.nongnu.org/mailman/listinfo/qemu-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-10-27 13:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-25 20:35 [Qemu-devel] several guests with static ip-address Michael
2005-10-26  5:59 ` Henrik Nordstrom
2005-10-26  8:04   ` Michael Kapp
2005-10-26 21:05     ` Henrik Nordstrom
2005-10-27 12:31       ` Michael Kapp
2005-10-27 13:31         ` Mario Goppold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.