Friday, September 11, 2015

Create a virtual router (DD-WRT) in VirtualBox

Okay, this is a pretty long post, but hopefully it captures what you need to create a virtual router in VirtualBox.  Some of the websites I have linked here make it seem so simple, but there is a little more to it and I have tried to capture what you need here.  I also included the links I used so you can refer to them if you run into any challenges.

Download dd-wrt for x86 platform and prepare the image/disk file:

Download the dd-wrt file.  The file can be down loaded from this site. http://www.dd-wrt.com/site/support/router-database Type ‘x86’ in the search box.  Select x86 and then the link labeled ‘DD-WRT X86 Public Vga: Console image’.

Convert the image file to a VM disk by executing the following command in the command prompt window.

cmd> "C:\Program Files\Oracle\VirtualBox\vboxmanage.exe" convertdd dd-wrt_public_vga.image dd-wrt.vmdk

Resized the disk. http://www.dd-wrt.com/phpBB2/viewtopic.php?t=76456  Otherwise it will be stuck at 10MB and may not save your settings.

cmd> "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd --resize 1024 "dd-wrt-x86.vmdk"

Some forums suggest the image needs to be natively installed to the VM.   http://www.dd-wrt.com/phpBB2/viewtopic.php?t=81836

Create a new virtual machine in VirtualBox:

Set the following specifications.

Operating System: Linux
Version: Other Linux (32-bit)
Storage: Choose existing disk: dd-wrt.vmdk
Audio: Clear the checkbox ‘Enable Audio’
Network>Adapter 1: Select PCnet-FAST III as the Adapter Type (under Advanced)

Depending on your desired network configuration, select the appropriate ‘Attached to:’.  I want to create a connection with my home network so I selected ‘Bridged Adapter’ and my computer’s WiFi adapter (which is how my computer connects to my home network).

Network>Adapter 2: Enable the adapter and again select PCnet-FAST III as the Adapter Type.  Select internal network.

I had trouble with the default Intel PRO/1000 MT Desktop where eth0 and eth1 were not being recognized.  The posting from JimmyPage on this thread http://www.dd-wrt.com/phpBB2/viewtopic.php?p=690980 was helpful.

Configure the virtual router:

Turn on DD-WRT VM when the text stops hit enter and log in. 
User: root
Password: admin

At the command prompt enter ‘ifconfig br0 192.168.2.1’ to change the IP address to avoid conflicts with your physical network (assuming it is on 192.168.1.X, which mine was).

Using a separate VM computer, set the network adapter to 'Internal Network'. Turn on the VM computer.  Manually set the IP address to 192.168.2.2. Open a browser in the VM computer and enter 192.168.2.1 to access the DD-WRT webGUI.  Change the username and password and login.  Go to the ‘Setup’ tab and update the following fields (use values appropriate for your network).

WAN Setup
Connection Type: Static IP
WAN IP Address 192.168.1.3
Subnet Mask 255.255.255.0
Gateway 192.168.1.1
DNS 192.168.1.1

Network Setup
Local IP Address 192.168.2.1
Subnet Mask 255.255.255.0

I left the rest of the values on the setup tab as the default.  Click 'Save', then click 'Apply Settings'.  The router should now handout IP addresses to your VMs. Change the settings on the separate VM computer to automatically receive an IP via DHCP. 


The following are additional links I referenced.

This youtube video is pretty helpful and walks through similar steps to those above.

The following links provide an overview of the steps.




Sunday, November 2, 2014

OpenCPU and rapache Installation

I used a combination of installation instructions from http://rapache.net/manual.html and https://github.com/jeroenooms/opencpu-server/tree/master/debian#readme in order to get OpenCPU installed.  This was a process of trial-and-error.  Eventually there were no critical errors and the commands would work.  Building rApache, I used the instruction from the rapache site.  Building OpenCPU I used the instructions from the github link above.  When I first attempted the build there were a few missing dependencies.  I installed these and then retried the build with success.  Installing OpenCPU I used the following instead of the suggested commands.
sudo dpkg -i opencpu-lib*
sudo dpkg -i opencpu-server*
I also opted to install apparmor using the instructions on the github link

Saturday, November 1, 2014

OpenCPU Installation

The installation of OpenCPU on my Debian system is less than simple.  There is no easy apt-get solution so I am working my way through the instruction on https://github.com/jeroenooms/opencpu-server/tree/master/debian#readme.  So far I made it through 'Building OpenCPU packages'.  When I got to the 'debuild' command I got an error 'debuild command not found'.  This was solved by installing the 'devscripts' package (sudo apt-get install devscripts).    

Frameworks

After careful research and consideration I am going to use Drupal as my full stack framework with Bootstrap for the web layer.  I read lots of recommendations for Bootstrap.  The reviews said Drupal was easier to get going than Django.  Eventually I expect I will shift the web app to Python (Django), but I'd rather just get going at this point.  Hence the decision to go with Drupal (PHP) for now.  Looks like Django can also interface with Bootstrap so I'm thinking the shift will not be that bad if/when I get to that point.  On the other side I decided to use opencpu to interface with R.  Again, I'm hoping this will facilitate any eventual shift to Python/Django since opencpu is a framework agnostic API.  I will also install rApache just for good measure, but I don't currently plan to do any R scripting with PHP/Drupal.

Saturday, October 25, 2014

Curl and RCurl getURL

I wanted to use the getURL function from RCurl so I tried to install the RCurl package.  I received this error Cannot find curl-config. In order to clear the error, I had install curl (apt-get install curl).  This didn't work so I ended up trying (libcurl4-gnutls-dev).  I then had to restart R and install R package bitops.  I ran library(RCurl) just to be sure.  getURL is now working.

Friday, October 24, 2014

User Authentication Parameters in .my.cnf

The RMySQL documentation (http://cran.r-project.org/web/packages/RMySQL/RMySQL.pdf) recommends placing user authentication parameters (user, password, database, and host) in the config file. This file is read from $HOME/.my.cnf.  I found this file did not exist so I copied the my.cnf file from /etc/mysql to my home directory and changed ownership (sudo chown...).  Next I added a group and my authentication parameters to the file.  I could then used 'con <- dbConnect(MySQL(), group = "group name")' in R to connect to my database.  This might be more secure if I were to continue using R Studio server from a separate computer, but my plan is to run R scripts locally initiated from PHP files, so I don't think there is any enhancement security in my case, but it does work.