Sunday, August 28, 2011

Linux Server

A couple of weeks ago I described installation of Ubuntu Linux (11.04), running under Virtual Box on Mac OS X Lion. I got matplotlib (and scipy) installed and running without any difficulty using apt-get alone.

Next, I installed Apache Server 2.2 and configured everything to run Python scripts by using Firefox from Ubuntu on the VM like this:

localhost/cgi-bin/test.py

After struggling a bit, I figured out how to use Virtual Box in NAT mode to do "port forwarding"---by modifying

/etc/apache2/sites-available/default

so then I could launch the script from the host OS by doing

localhost:8080/cgi-bin/test.py

from Safari or by using curl in Terminal.

The next step was to try to access the server from a second machine on my home network. In order to do that, (as I understand it) I can either remain in NAT mode and try to connect via the host machine and port-forwarding, or use "bridging" mode to effectively put the Ubuntu server on the network.

In order to accomplish this, I need to know the ip address of the server as assigned by my Apple Time Capsule router. Now the problem is that this ip address may change with time (since we're getting it from the Time Capsule as a DHCP server). According to the folks I asked on serverfault, I need to switch the Ubuntu network IPv4 settings to manual and ask for a specific ip address and this is correct so far as it goes.

However, the address I ask for in Ubuntu



has to match the range of addresses that the router is set up to hand out. Furthermore, we probably want to have most ip addresses handled dynamically, and only use a static ip for the one machine. If we wanted them all static, we'd go here:


I found the answer here but the setting is actually visible in this screenshot:


Under Internet > DHCP there is a TableView called DHCP reservations. I just reserved the first available ip address. After re-booting Ubuntu and restarting the server, I can run the test script or do:


Now I have to figure out how to access the server from the outside world. I should probably remove the test script from cgi-bin (since it reveals information about paths on the server) and read up on firewall configuration, etc. before I do that. The first problem for this part (not yet solved) is that my ip address from my isp, obtained with

checkip.dyndns.org/

does not seem to be accessible. I get a "Safari can't connect to the server .." message.

1 comment:

fredrik said...

The machine answering om your external IP is the TimeCapsule so you need to turn on port forwarding on it from Airport utilities.