Emulate 2 LAN networks?

Discussions related to using VirtualBox on Windows hosts.
Post Reply
davelowndes
Posts: 9
Joined: 4. Feb 2011, 02:56
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Windows Ubuntu

Emulate 2 LAN networks?

Post by davelowndes »

Hi, Is it possible in VirtualBox to simulate two independent LAN networks, both behind a router with a "public" IP address (accessible to my physical network)? E.g.

LAN 1, public IP 192.168.1.21
- machine A, 172.168.1.100
- machine B, 172.168.1.101
LAN 2, public IP 192.168.1.22
- machine A, 172.168.1.100
- machine B, 172.168.1.101

And be able to port forward, e.g. 192.168.1.22:80 -> 172.168.1.100:80 (LAN 2) so any machine in my home network, or in LAN 1 or in LAN 2 would be able to see the service at 192.168.1.22:80?

Thanks!
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Emulate 2 LAN networks?

Post by noteirak »

Sure thing, pretty easy to do with Virtualbox

Depending on how knowledgable you are with networking stuff, I could recommend 2 approachs :
Easy mode : 2 extra VMs under text-mode debian which would be the easiest, config wize
Hard mode : 1 extra VM under pfSense or anything of the like, which requires (a lot) more config, but saves you the extra VM.

You would then have for LAN 1 :
Machine A with 1 internal network interface, under name VLAN001
Machine B with 1 internal network interface, under name VLAN001
Machine Debian 1 with 1 Internal NIC on VLAN001 and 1 Bridged NIC on your host NIC to your normal LAN

You would have for LAN 2 :
Machine A with 1 internal network interface, under name VLAN002
Machine B with 1 internal network interface, under name VLAN002
Machine Debian 1 with 1 Internal NIC on VLAN002 and 1 Bridged NIC on your host NIC to your normal LAN

In case you use a single pfSense VM, use VLANs setup to separate the networks.

In all VMs :
- Configure your VMs with the appropriate IPs following regular OS configuration

In both Debian VMs :
- Configure IP routing
- Enable iptables masquerading on the bridged interface
- Configure iptables firewalling if you wish to

For the specifics, you'll find lots of tutorials & howtos on Internet, especially if you keep to debian or pfSense.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
davelowndes
Posts: 9
Joined: 4. Feb 2011, 02:56
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Windows Ubuntu

Re: Emulate 2 LAN networks?

Post by davelowndes »

Great thanks! I was hoping I could skip extra VMs to act as routers but I guess it's okay, gives me the most power and I'm already familiar with *nix.
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Emulate 2 LAN networks?

Post by noteirak »

You could, but then you need to turn your host into router mode and use Host-Only interfaces. But that would be a nightmare on a Windows Host, so I wouldn't recommend it _at all_
Or you could switch to a linux host :D I've got that kind of setup (with the host doing the routing) on a debian dedicated server and I can say it's working flawlessly.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Post Reply