Saturday, September 29, 2012

Creating a ZeroShell Virtual Router

What is ZeroShell?

Zeroshell is a linux-based operating system that is specifically designed to operate as a router. Zeroshell can be used to replace a hardware router or firewall in a home or small office or it can be used to provide NAT and IP routing for virtual machines in a virtualized network. Zeroshell seems to run great in Microsoft Hyper-V, Oracle Virtualbox and VMware ESXi virtualization environments. The name zeroshell comes from the fact that the operating system is designed so that little or no shell access is required for administration. All basic features such as port forwarding, interface configuration, DHCP and QoS are accessible within the web GUI. Zeroshell also comes with built in software for running VPN and DNS servers, also administrable from the WebUI. Unlink other router distributions the free edition of Zeroshell has no limitations and is a breeze to install and configure. I first came across Zeroshell when I was setting up a virtual network for the discovr.us gaming community and I have since moved on to using Zeroshell for personal networking projects. In this guide I’m going to walk through the installation and basic configuration steps needed to get a Zeroshell router up and running in Microsoft HyperV.

For more information about Zeroshell, or to download it visit zeroshell.org

Installing ZeroShell

This guide assumes you are running Windows 2008 or Windows 2008R2 with the HyperV roll installed and operational. For more information on HyperV check out this Blog post. The first thing to do is set-up a virtual machine and virtual network to run Zeroshell. Open the HyperV manager and create a new virtual machine.



Give the machine a hard drive of at least 2GB (I would recommend 3) and allocate it 512mb of RAM (you can reduce the allocated RAM later but we do need at least 512mb for the initial install). When asked what network to connect it to leave the option disconnected for now. After the virtual machine has been created, open up the HyperV virtual network manager. Create two new networks, one (which I will call VM-WAN) will be an external network, allowing Zeroshell to talk with the outside world. The second network will be an internal network (I will call it VM_LAN) and it will allow all the virtual machines to talk with each other directly. When creating an external network HyperV will ask you what physical interface to connect it to. Choose the Ethernet adaptor that you use to connect Windows 2008 to the Internet.


After the virtual networks have been set-up, apply the changes and close the network manager. Next comes the tricky part. To install Zeroshell to a hard disk you must download the appropriate image and extract it onto the target disk. The most efficient way of accomplishing this is to use an Ubuntu Live CD and a second, temporary, virtual hard disk. Hop on over to ubuntu.com and download the latest version of the 32-bit live CD. While Ubuntu is downloading hop back over to HyperV to configure the network and temporary hard disk. Open up the settings for the Zeroshell VM and remove the network adaptor that Windows has added. Then go to “add hardware” and add two new legacy network adaptors to the machine. Connect one adaptor to the WAN network and the other to your LAN network and apply the settings. Next add a new hard drive to Zeroshell by clicking on IDE controller 0 and selecting ‘hard disk.’



Opt to create a new hard disk of size 4GB and select the default options. After your copy of Ubuntu has finished downloading, navigate to the DVD Drive on IDE controller 1 and connect it to the Ubuntu iso you just downloaded.

Apply the settings and then start up the VM.

If everything has been configured correctly your VM should boot off the Ubuntu live CD. And eventually load an Ubuntu desktop. The first thing you’ll need to do upon loading Ubuntu is to format the temporary hard drive you created in the previous step. If you followed these instructions then it should be a 4GB hard disk. Start by launching ‘gparted’ from the home screen.



Once Gparted fires up you should note that there are two hard disks, one 3GB disk and one 4GB disk. Select the 4GB disk and create a new ext3 partition. You will probably want to give it a label, I called mine temp.


Gparted may ask you to initialize the disk with a partition table, you can set up a partition table under “device…. Create partition table”. Apply the changes.

Close Gparted and mount the new partition by selecting it from the sidebar in a file navigation window.


Next, you need to open up Firefox and navigate to the download page for Zeroshell. Make sure you download the 2GB image file by right clicking on it and selecting save as. Save the image to the newly formatted temp hard disk. After the Zeroshell image has finished downloading open up a terminal window and cd to the directory that you have downloaded the Zeroshell image to (in my case /media/temp/). After that extract the image by running

gunzip ZeroShell-2.0.RC1-Soekris-2GB.img.gz.

Finally, write the image to your unused hard drive using the command:

dd if= ZeroShell-2.0.RC1-Soekris-2GB.img of=/dev/sda
Where /dev/sda is the identifier of your first hard disk. (if you followed this guide to the letter then /dev/sda will be your OS drive, however, if you have deviated from these instructions then you may need to use a different drive). You should see something similar to the following output if the copy was successful:

After you see the confirmation message you may shut-down Ubuntu. Before turning the VM back on we need to edit a few settings. After the VM has been turned off, open up its settings in the HyperV manager and remove the 4GB hard drive as it is no longer needed. You should also make sure that the Ubuntu iso has been removed from the VM. Finally you may reduce the amount of allocated RAM to 128 or 256mb, depending on how much load you will be putting on the server. Apply the settings and turn the virtual machine on. If everything was successful you should be presented with the default ZeroShell console.

At this point Zeroshell has been successfully installed and just needs to be configured for network access. If your Zeroshell WAN port is connected to a consumer-level ISP or another LAN then it will likely pull a DHCP address and no additional configuration is required. If, however you need to set a static IP on your WAN then you will need to enter option “I” for “edit interfaces” and enter your static IP. You will also likely need to enter a gateway. Secondly, you will want to set your LAN IP address. I would recommend using an address like ‘192.168.10.1’ rather than the most common ‘192.168.1.1.’ Further information on the configuration of Zeroshell is available at zeroshell.org.

Congratulations, you now have a virtualized router that can be used to provide a private network to all your HyperV virtual machines, and provide Internet access to a large number of VMs.

3 comments:

  1. It is a pleasant post.I leave plenty of comments on plenty of blogs domestically - however there's one position wherever I excellently license a comment - adjusted if the post to treats it.
    lost emails

    ReplyDelete
  2. http://www.zeroshell.org/forum/viewtopic.php?t=3441

    i like your idea of using ubuntu livedisk, but you might prefer just grabbing a pre-made version....

    ReplyDelete
  3. I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work. 192.168.49

    ReplyDelete