Nikhil
Nikhil

Reputation: 286

How to create a virtual network for an application

I'm creating a simple p2p application. To test this I'd like to be able to simulate a simple network of about 2-3 computers, such that each instance of the application thinks its on a different computer and talking with others over the network. I considered qemu, but haven't managed to get networking working using VDE or TUN/TAP. is their any other solution?

Upvotes: 0

Views: 422

Answers (3)

Najib
Najib

Reputation: 11

Here are example using vde and qemu. Not require to configure firewall/routing. Much more simple to setup. Do not need root privilege to run qemu. Easy to use. Tested and working.

# brctl addbr br0
# brctl addif br0 eth0
# dhclient br0
# vde_tunctl -u testuser -t tap0
# ifconfig tap0 up
# brctl addif br0 tap0
# brctl setfd br0 0

$ vde_switch -d -s /tmp/vde0 -M /tmp/vde0mgmt
$ vde_plug2tap -d -s /tmp/vde0 tap0

$ vdeqemu -hda testdisk1.qcow2 ... -net nic,macaddr=... -net vde,sock=/tmp/vde0
$ vdeqemu -hda testdisk2.qcow2 ... -net nic,macaddr=... -net vde,sock=/tmp/vde0

You might refer to simple diagram at http://selamatpagicikgu.wordpress.com/2011/06/08/quickhowto-qemu-networking-using-vde-tuntap-and-bridge/

Upvotes: 1

echoack
echoack

Reputation: 126

I recently set up a small network using VirtualBox and VDE on my laptop that cannot reach the internet. VirtualBox 4.0.6 natively integrates with VDE. Setting up VDE should be as simple as starting your switch:

vde_switch -s /tmp/switch1

Then, selecting "VDE Adapter" as your network adapter for each of your VMs and specifying the name of your adapter as the following will connect all of your VMs to the same switch so they can communicate:

/tmp/switch1

Alternatively (and more simply), you could just choose "Internal Network" as your network adapter and specify the same name for the network in each of your VMs to connect them all together in VBox.

Upvotes: 0

Justin Niessner
Justin Niessner

Reputation: 245429

You might have better luck using VMs running on something like Virtual PC (Sun's Virtual Box is another good alternative).

Upvotes: 4

Related Questions