Virtual Network of Virtual Machines [closed] - testing

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I am developing software that is designed to run on a LAN. When multiple instances of the software are run on the network, they interfere with each other.
I want multiple team members to be able to test the program simultaneously. How would I do so (without altering the program).
My first thought would be to create a bunch of virtual machines running on a local box, with those machines networked together. The important thing is that I cannot generate network traffic outside of my real machine.
Which virtualization software would be the best choice to accomplish this task? How would I configure the software to behave in this manner?

Personally, I like VMWare Server... It pretty much works out of the box, and it handles the vm network cards very well, allowing them to be treated as physical devices (in terms of DHCP etc).
As for configuring the software, well as far as the machines are concerned, they are real. If you assign them static IPs, they may as well be real machines - although you'll find it easier to administer them by remote desktop rather than use the vmware console interface.
EDIT: I actually use VMWare Server in a production environment, running a virtual webserver, virtual DB server and a virtual app server on the same physical box.
VMWare also comes with a great converter tool that can virtualize a physical machine. This made it much simpler for me to consolidate and maintain my servers from three physical machines down to one.
EDIT 2: It's free too ;)

I would suggest VirtualBox. I think virtual network cards it sets up can be connected to a virtual network identified by name, where they can see each other.
The user manual has detailed networking instructions for various scenarios. From the Manual:
6.6. Internal networking
Internal Networking is similar to host
interface networking in that the VM
can directly communicate with the
outside world. However, the "outside
world" is limited to other VMs which
connect to the same internal network.
It runs on several platforms: windows linux osx solaris.

I use Sun xVM.... it does the networking by default to be on a 10.x network, nat'd behind your actual ip. So I'm not sure if that'd interfere with other instances running out on the network or not. But it's free and runs fairly well, and supports hyper-v to boot if you're on a 64bit os and have the processor to support it.

Almost any peice of Virtualization software will enable you to configure various types of networking.
VMware for example offers the following network types:
Bridged - machine appears as a host on the physical lan (not what you want)
NAT - shares your PC's IP (if you want to permit your application to access the physical LAN/internet)
Host-only - private network only visible to the VMs and your PC. If you want to permit internet/LAN access you'll need to run additional software on the host PC.
Custom - if you need to run multiple virtual networks to test things like firewall/webserver/vpn combo configurations and the like
In terms of simplicity and least configuration, VMWare Workstation is probably the ideal choice. It's very easy to use and setup is a breeze. Licensing costs are very reasonable ($190 for a single license, or $900 for 5 licenses) and then to cover yourself for licensing I'd suggest a Microsoft Technet subscription for each team member (Tho if they're all developers and you have MSDN then you're already covered)
There are cheaper alternatives that I'd recommend for hobby use, but if you're in a commercial environment where time is money then VMware will pay for itself in productivity gains very, very quickly.
Lastly, if cost is an issue then you might be able to get away with a single VMware license for configuring the machines and then using the free VMware player to run them, however I'm not sure if it has all the same sandboxed networking features present in VMware Workstation.

Recently there's been a lot of people talking about linux network namespaces, which is a way of creating lightweight virtual hosts. I believe this is also a way to solve your problem.
Mininet (http://mininet.org/) uses this to create emulated networks and it works really well. I have just begun using network namespaces for testing purposes and the performance is quite good with very low memory usage.
Refer also to http://www.opencloudblog.com/?p=66.
I took a sequence of commands from this last link and created a test setup:
#!/bin/bash
# add the namespaces
ip netns add ns1
ip netns add ns2
# create the switch
BRIDGE=ovs-test
ovs-vsctl add-br $BRIDGE
#
#### PORT 1
# create an internal ovs port
ovs-vsctl add-port $BRIDGE tap1 -- set Interface tap1 type=internal
# attach it to namespace
ip link set tap1 netns ns1
# set the ports to up
ip netns exec ns1 ip link set dev tap1 up
#
#### PORT 2
# create an internal ovs port
ovs-vsctl add-port $BRIDGE tap2 -- set Interface tap2 type=internal
# attach it to namespace
ip link set tap2 netns ns2
# set the ports to up
ip netns exec ns2 ip link set dev tap2 up
# add external port eth11
ovs-vsctl add-port $BRIDGE eth11
# configure ip addresses
ip netns exec ns1 ifconfig tap1 192.168.201.1/24
ip netns exec ns2 ifconfig tap2 192.168.201.2/24
The commands above basically create two hosts connected to an Open vSwitch bridge. Both hosts are connected to each other and also connected to the outside world through my eth11 ethernet adapter. Bridging to the outside world is completely optional.
I can run ping and iperf between the virtual hosts like this (the output is a bit messy, but I think it is possible to get the idea):
# ip netns exec ns1 iperf -s &
[1] 22158
# ------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
# ip netns exec ns2 iperf -c 192.168.201.1
------------------------------------------------------------
Client connecting to 192.168.201.1, TCP port 5001
[ 4] local 192.168.201.1 port 5001 connected with 192.168.201.2 port 43469
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.201.2 port 43469 connected with 192.168.201.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 17.3 GBytes 14.9 Gbits/sec
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.0 sec 17.3 GBytes 14.9 Gbits/sec
#

If you're running on Windows or Linux, VMWare Server (mentioned by another poster) and VirtualBox should both do what you want, and they're both free. VirtualBox also runs on Mac OS X and Solaris, if you're so inclined.

In my previous project the guys from the hosting company tell me that they were using VMWare to configure the webfarm, but I don't have any clue of how to do this, though.

Related

Connecting a DVR Tuner to a Plex Server in Hyper-V

is there a way to connect a dvr tuner to a Plex Server hosted in Hyper-V?
I have searched but could not find a Question about this topic.
My build is a Win22 Datacenter Server running Plex in Hyper-V. A Hauppauge dualHD is connected to the Win22 Datacenter Server via USB.
Thanks for your help!
Current Answer
I'm updating my answer as I didn't realize it was a tuner and not a DVR box connected to your TV.
From what I'm seeing online, your best bets are:
use Enhanced Session Mode to connect the device over RDP (which only supports some devices)
use a third-party tool such as Donglify (this is from results on Google. Buy at your own digression) to allow USB passthrough
use a Type 2 hypervisor (VirtualBox, VMware) to run your instance of Plex instead
run Plex outside of Hyper-V on the same system with a sandboxed user
run Plex on another device entirely, such as a Raspberry Pi.
I can't help with the first, as it requires some gpedit.msc magic I cannot do, or second as I have never used one.
3rd option will reduce program speeds which may cause slowdown if multiple people stream at once.
4th option is my personal recommendation, as you bypass the need to use a hypervisor entirely and keep on the same device.
5th is only good if you use a USB-based drive and have a decent bit of experience with Linux.
Old Answer
Kept for the sake of archival.
You'll want to use Powershell and the Add-NetNatStaticMapping cmdlet to allow inbound connections to the Hyper-V server. This will need a vNAT adapter set up. See the linked blog post (not mine) if you need help with that, too.
Assuming the vEthernet connection has an internal IP of 192.168.10.2 and a NAT network name of NATSwitch, with Plex on the default port of 32400:
Add-NetNatStaticMapping -ExternalIPAddress "0.0.0.0/24" -ExternalPort 32400 -Protocol TCP -InternalIPAddress "192.168.10.2" -InternalPort 32400 -NatName NATNetwork
You will most likely need to replace the internal IP, port, and NAT name.
After this is set up, you'll need to point your DVR to the IP of the Windows Server box.
Sites referenced:
Plex support page on ports to forward
A GitHub user's blog, specifically a post on port forwarding

How can I have different ip for differnt distrubutions on wsl2?

I am running 5 different Ubuntu distro on wsl2 but all are having the same ip address.For example Ubuntu 18.04 and Ubuntu 20.04 are having the same ip. Is it possible to have different ips on each Ubuntu versions?
Full disclosure: This answer does not address networking between to wsl2 instances. Rather, it presents - as requested from a commenter - an alternative way to have two guest operating systems to each have their own IP address within a network that is "inside" the host OS.
The following allows for two VMs (rather than wsl2 instances) to have different IP addresses within a network within a host Windows 10 operating system:
Prerequisites in no particular order:
Disable the Hyper-V Windows Feature. This page describes a variety of ways to go about it, but I went the Control Panel route.
Install VirtualBox
Set up a network for the VMs to share:
Open VirtualBox
Click File > Preferences
Click Network
Click the icon with a plus sign (+) in it to add a new network
Create your VMs and connect them to this network
Create the VM and give it an operating system as you would otherwise
Shut down the VM
Select the VM in the main VirtualBox window, click the Settings/gear button
Click Network
Select NAT Network for "Attached to"
Select the name of the network you created above. (A sample that worked for me is below.)
Customize the overall network settings for the VMs
Return to main VirtualBox window > File > Preferences > Network
Click gear icon to edit the network
Click Port Forwarding
Enter details (such as the following, but modified for you needs) to direct traffic from local host to certain IP addresses/ports within this network
You can create new processes with new network namespaces, so you can achieve network isolation.
ip netns add net1
ip netns exec net1 ip addr add 192.168.99.10/24 dev sit0
ip netns exec net1 exec bash
Reference: https://blogs.igalia.com/dpino/2016/04/10/network-namespaces/
May you can try this solution: https://superuser.com/a/1715457/860784, with which I managed to get multiple IPs. And I can ping each other.
However, after reboot these IPs lost, and I still get my distros the same IP, which is exact the windows ip.
May you can sovle your problem and my problem. :)

Cannot do Vagrant ssh after Vagrant up on windows Machine

I am building a sample vagrant box to install Jenkins and push it to atlas cloud.Please find below the steps that I followed.
Vagrant init ubuntu/trusty64
and the normal command to initialize the vagrant machine.
vagrant up
After this if i type command to ssh into the machine
vagrant ssh
It gives me error saying please increase timeout and so.
The main question is how can I ssh into the newly created vagrant machine.
To understand this, I have to go through all the basics. Please find below my findings.
Not attached
In this mode, VirtualBox reports to the guest that a network card is present, but that there is no connection -- as if no
Ethernet cable was plugged into the card. This way it is possible to "pull" the virtual Ethernet cable and disrupt the connection, which can be useful to inform a guest operating system that no network connection is available and enforce a reconfiguration.
Network Address Translation (NAT)
If all you want is to browse the Web, download files and view e-mail inside the guest, then this
default mode should be sufficient for you, and you can safely skip the rest of this section. Please note that there are certain limitations when using Windows file sharing (see Section 6.3.3, “NAT limitations” for details).
NAT Network
The NAT network is a new NAT flavour introduced in VirtualBox latest versions.
Bridged networking
This is for more advanced networking needs such as network simulations and running servers
in a guest. When enabled, VirtualBox connects to one of your installed network cards and exchanges network packets directly, circumventing your host operating system's network stack.
Internal networking
This can be used to create a different kind of software-based network which is visible to selected virtual machines, but not to applications running on the host or to the outside world.
Host-only networking
This can be used to create a network containing the host and a set of virtual machines, without the need for the host's physical network interface. Instead, a virtual network interface (similar to a loopback interface) is created on the host, providing connectivity among virtual machines and the host.
Generic networking
Rarely used modes share the same generic network interface, by allowing the user to select a driver which can be included with VirtualBox or be distributed in an extension pack.
At the moment there are potentially two available sub-modes:
UDP Tunnel
This can be used to interconnect virtual machines running on different hosts directly, easily and transparently, over existing network infrastructure.
VDE (Virtual Distributed Ethernet) networking
This option can be used to connect to a Virtual Distributed Ethernet switch on a Linux or a FreeBSD host. At the moment this needs compiling VirtualBox from sources, as the Oracle packages do not include it.
Out of these, only NAT and Host-only network is important.So, to solve this issue, I modified the predefined Vagrant file with the following code.
jenkins.vm.provider "virtualbox" do |vb|
jenkins.vm.network "private_network",ip:'192.168.56.5',:adapter => 2
jenkins.vm.hostname = 'jenkins.ci'
vb.name = "Jenkins"
end
Here, I have created a private network with static Ip and also, I specified the adapters count to use 2. The Private adapter is Host-only adapter and 1st adapter which is default one is NAT.

Accessing VM's terminal using putty in host OS?

I am working on a project in which we logon to client's machine using Cirtix receiver. The machine which we connect to using Citrix receiver is basically a Windows 7 machine. Once we are in the client's windows box, inside that we have virtual box, in which VM has been added and which has all the needed software for us to do the development; for example JBOSS, database etc.
In the host machine (windows 7), we have putty, and using putty we sometimes login to the VM (i.e. terminal). The confusion which I have is as below:
We login to the VM terminal using IP address: 127.0.0.1. This is where my confusion is. 127.0.0.1 normally is the IP address with which we can refer to the current machine; so how using this IP address we are able to connect to the VM which is added to the virtual box? Doesn't the VM which is in virtualbox has its own IP address with which we can connect to? Or is there some concept which I am not aware of.
Can anyone help me in understanding this? I am not well versed with virtualization, so for the gurus this might be a naive question.
Every VM will have their uuids so to access the VM inside virtualBox or any hypervisor for that matter. so you can use that particular VM uuid and u should be able to console to that VM.
in virtual box try below
You can use: VBoxManage list vms to list all currently registered VMs with their settings, names and UUIDs.
Once you know the UUID you can also start a vm by:
VBoxManage startvm which is essentially same as: VBoxManage startvm "Name-of-vm"
Also Vm has two interfaces one loopback which will have an address of 127.0.0.1 and the rest of the interfaces so to access the VM with particular ip you need to assign an IP to that VM interface and than try with that IP.Also you might have that port 22 open for that loopback ip so may be that is the reason you are able to connect on loopback
I hope this answers your question

how do i reach apache on a vitualbox machine

I am trying to run a virtual LAMP machine on my windows 7 for dev purposes. But i cant figure out how to reach the apache from the host windows 7 system. I did an ifconfig and tried the ipaddress, but to no avail.
If you set virtualbox to use bridged (regular) networking then it's no different from any other machine on the LAN, if you set host only then you can still call it - you just need to know it's IP address.
See http://opensourceexperiments.wordpress.com/2008/04/18/virtualbox-case-study-making-host-only-networking-work-between-two-ubuntu-guest-os-virtual-machine-on-windows-vista-host/
You will need to set the networking mode of your VM in virtualbox.
Bridged will allow others on the LAN
to access your VM.
Host-Only will allow your host and
any other VM's also configured as
host-only to access one another.
Virtual Box Neworking
If you look at the link you will have many different options on the type of networking you can do.
as mentioned earlier, I recommend either:
Bridged networking that makes the box look like an other computer on your network. They you may use ipconfig on the box or verify your router logs.
Host-Only networking is where your windows 7 will be its own network between the box and windows and then you may use the Ip address from ipconfig.