You are here:   Research
Register   |  Login
The quickest way to find articles is to use the below search option.

However, if you go to the end of this page, you also find the Blog archive (calendar format) that allows for browsing of older articles.

Search:

Using a virtual router for your lab and test environment

Dec 13

Written by:
12/13/2012 9:29 AM  RssIcon

When build lab and proof-of-concept solutions in a virtual environment it's very useful to also have a virtual router to enable multiple networks to connect, and to simulate a larger environments.

Depending on virtualization platform you can use built-in network configurations to route, and bandwidth-limit network traffic. In this article you learn about creating a virtual router that works with all modern virtual platforms. You have two different options in this article:

  • Option 1 is using a Windows Server 2012 based router.
  • Option 2 is using a Linux (Vyatta) based router.

Scenario

The step-by-step guides in this article configure a virtual router for the fictive ViaMonstra network. For a full IP plan for ViaMonstra network, see http://viamonstra.com/?page_id=25

ViaMonstra has the following three local networks:

New York: 192.168.1.0/24
Stockholm: 192.168.2.0/24
Liverpool: 192.168.3.0/24

In addition ViaMonstra also have Internet access. In a real world (physical) network you would have many routers, but in a virtual environment where all virtual machines are running on the same host you only need one router. This also means that in this guide there are three internal virtual networks (virtual switches in Hyper-V), and one external. In the step-by-step guides I assume you have created the following virtual networks:

Base Configuration

  1. Create the following virtual networks (virtual switches)
    1. External (connected to physical network adapter of your host)
    2. New York (Internal network)
    3. Stockholm (Internal network)
    4. Liverpool (Internal network)
  2. Create a virtual machine named GW01 with four network adapters (1 GB RAM and 60 GB disk) and use following network configuration
    1. Connect network adapter #1 to the External virtual network
    2. Connect network adapter #2 to the New York virtual network
    3. Connect network adapter #3 to the Stockholm virtual network
    4. Connect network adapter #4 to the Liverpool virtual network
  3. On the virtual machine settings, make a note of the Mac Address for each network adapter. In my setup I had the following:
    1. Adapter #1 (External): 00:15:5D:83:40:21
    2. Adapter #2 (New York): 00:15:5D:83:40:22
    3. Adapter #3 (Stockholm): 00:15:5D:83:40:23
    4. Adapter #4 (Liverpool): 00:15:5D:83:40:24

GW01 created with four network adapters.

 

Option 1 - Using a Windows Server 2012 VM with Routing and Remote Access.

  1. Install Windows Server 2012 on GW01 and set the computer name to GW01.
  2. Using Network Connections, configure the networks to the following (use the Mac Address noted earlier to find correct adapter):
    1. Adapter #1:
      1. Name: Internet
      2. IP Address: DHCP
    2. Adapter #2:
      1. Name: New York (192.168.1.0)
      2. IP Address: 192.168.1.1/24
    3. Adapter #3:
      1. Name: Stockholm (192.168.2.0)
      2. IP Address: 192.168.2.1/24
    4. Adapter #4:
      1. Name: Liverpool (192.168.3.0)
      2. IP Address: 192.168.3.1/24

Networks configured in Network Connections.

 

  1. Using Server Manager, add the Remote Access role. Accept the default settings, but on the Role services page also select Routing.
  2. Using Routing and Remote Access, right-click GW01 (local), and select Configure and Enable Routing and Remote Access.
  3. Use the following settings for the Configure and Enable Routing and Remote Access Setup Wizard:
    1. Configuration:
      1. Network address translation (NAT)
    2. NAT Internet Connection:
      1. Select the Internet network interface.

         

Selecting the Internet network interface.

 

  1. Network Selection:
    1. Select the New York network
  2. Name and Address Translation Services
    1. I will set up name and address services later
  1. Done!

    

Option 2 - Using the Vyatta 6.5 Open Source Router.

You can download the free version of Vyatta Open Source Router fon vyatta.org (http://www.vyatta.org/downloads) and a community fork (VyOS) on http://vyos.net/wiki/Main_Page. Note that the free version does not come with a UI for configuring the router, only command line and config files.

Credit goes to Stefan Stranger for writing the initial guide (for version 4.0).

  1. If you want you can reduce the GW01 virtual machine memory to 128 MB. 1 GB is really overkill for Vyatta J
  2. As far as disk goes you can run Vyatta on 1 GB drive (Vyatta recommends 2 GB for production), but I normally keep the 60 GB disk anyway.
  3. Install Vyatta 6.5 by booting the GW01 virtual machine on the vyatta-livecd-virt_VC6.5R1_i386.iso file

Booting the GW01 virtual machine on the vyatta-livecd-virt_VC6.5R1_i386.iso file

  1. Log on as vyatta, using the vyatta password.
  2. Start the installation by running the following command (was install-system in earlier versions)
    1. install system
  3. The setup options are quite self-explanatory, but say No to create a RAID volume (Vyatta thinks you have two drives, when you really only have one).
  4. Once setup is completed, shutdown the VM, eject the CD, and restart the GW01 virtual machine.

    The command for shutdown is: poweroff

  5. Note: You did shutdown the VM and eject the CD, right? (otherwise any changes made later will be lost)
  6. Login and configure the network adapters by running the following commands:
    1. configure
    2. set interfaces ethernet eth0 address dhcp
    3. set interfaces ethernet eth1 address 192.168.1.1/24
    4. set interfaces ethernet eth2 address 192.168.2.1/24
    5. set interfaces ethernet eth3 address 192.168.3.1/24
    6. commit
    7. save
    8. exit
  7. Now you can review the network adapters by running the following commands
    1. sudo ifconfig | more
    2. Show interfaces Ethernet

  1. Configure the NAT configuration by running the following commands:
    1. configure
    2. set nat source rule 10 outbound-interface eth0
    3. set nat source rule 10 source address 192.168.1.0/24
    4. set nat source rule 10 translation address masquerade
    5. commit
    6. save
    7. exit
    8. reboot
  2. Done!

Happy Routing / Johan