Archive for August, 2008

A List Apart: Take The Survey!

ALA I took the survey 2008

Do you make websites? Please take the survey.

If you enjoyed this post, make sure you subscribe to my RSS feed!


How I setup networking for VirtualBox on Ubuntu

Just a quick note: I use VirtualBox daily at work. It provides excellent emulation for my original XP install (the one that came pre-installed on my Dell box!) while my main OS is Ubuntu. Setting up networking is not as straightforward as with VMWare, so here is what I had to do:

First, edit /etc/udev/rules.d/20-names.rules and make sure this line exists:

KERNEL="tun", NAME="net/%k"

Then create this script - you will run it whenever you wish to reconfigure your network:

#!/bin/bash
echo "Erasing old configuration"
sudo route del default
sudo ifconfig tap0 down
sudo ifconfig eth0 down
sudo ifconfig br0 down
sudo brctl delbr br0
sleep 1
 
echo "Creating virtual interface"
sudo chown chris /dev/sdc1
sudo tunctl -t tap0 -u chris
sleep 1
echo "Creating bridge interface"
sudo brctl addbr br0
sleep 1
echo "Making physical interface promiscuous"
sudo ifconfig eth0 0.0.0.0 promisc
sleep 1
echo "Binding bridge to physical interface"
sudo brctl addif br0 eth0
sleep 1
#sudo ifconfig br0 10.255.203.34 netmask 255.255.255.0
echo "Configuring IP address"
sudo ifconfig br0 198.206.186.210 netmask 255.255.255.0
# sudo dhclient br0 # The new way!
sleep 1
echo "Binding bridge to virtual interface"
sudo brctl addif br0 tap0
sleep 1
echo "Enabling virtual interface"
sudo ifconfig tap0 up
sleep 1
#sudo route add default gw 10.255.203.254
echo "Adding default route"
sudo route add default gw 198.206.186.254
echo "All done!"

What’s that, then?
We start by getting rid of any existing configuration; then I change my virtual interface device’s owner to my own user, since I am logged in as a non-root user. Obviously you need to replace ‘chris’ with your own user name. From now on, tap0 will be the virtual interface seen by VirtualBox.
I make sure that my real interface is in promiscuous mode, which then allows me to bind it with a bridge interface.
All that is left to do it configure my bridge interface so that it can take over communicating with the rest of the world!

If you enjoyed this post, make sure you subscribe to my RSS feed!


How To Make The EFF ISP Throttling Tool Work On Leopard

Switzerland LogoI love the idea of Switzerland, the new EFF tool for checking ISP throttling; unfortunately as of release Zero.0.5, Leopard seems to still be a mere afterthought. Here is how I worked around the few things that were not working out of the box.

First, Switzerland is written in Python and will require Psyco. It’s a good thing since Psyco is all about performance. If you do not have it already installed:

svn co http://codespeak.net/svn/psyco/dist/ psyco-dist
cd psyco-dist/
sudo python setup.py install
cd ..

Download Switzerland from https://sourceforge.net/project/showfiles.php?group_id=233013
Extract it and change to its directory; eg

tar zxvf switzerland-0.0.5.tgz
cd switzerland-0.0.5

The FastCollector provided doesn’t work. So…

rm bin/FastCollector.darwin

Now when we build FastCollector, it will be available in /usr/local/bin/FastCollector

Here comes the only moderately scary thing for non-developers. Use the patch command to modify switzerland/client/PacketListener.py. This is the input for patch:

diff --git a/switzerland/client/PacketListener.py b/switzerland/client/PacketListener.py
index 211b68f..dc0bbcc 100755
--- a/switzerland/client/PacketListener.py
+++ b/switzerland/client/PacketListener.py
@@ -93,8 +93,7 @@ class PacketListener(threading.Thread):
         p = platform.system()
         # Implementing the recommendations from
         # http://www.net.t-labs.tu-berlin.de/research/hppc/
-        if p[-3:] == "BSD" or p == "Darwin":
-          print p
+        if p[-3:] == "BSD":
           cmd = ["sysctl","-w","net.bpf.bufsize=10485760"]
           try:     # Recent FreeBSDs
             proc = Popen(cmd, stdin=PIPE, stdout=PIPE)
@@ -110,6 +109,14 @@ class PacketListener(threading.Thread):
             proc = Popen(cmd, stdin=PIPE, stdout=PIPE)
             assert proc.wait() == 0
 
+        elif p == "Darwin":
+          cmd = ["sysctl","-w","debug.bpf_bufsize=10485760"]
+          proc = Popen(cmd, stdin=PIPE, stdout=PIPE)
+          assert proc.wait() == 0
+          cmd[2] = "debug.bpf_maxbufsize=10485760"
+          proc = Popen(cmd, stdin=PIPE, stdout=PIPE)
+          assert proc.wait() == 0
+
         elif p == "Linux":
           vars = [("/proc/sys/net/core/rmem_default", "33554432"),
                   ("/proc/sys/net/core/rmem_max", "33554432"),

Let’s build and install everything:

sudo python setup.py install

Well, it was easy (if it worked!)

Let’s create a log directory for Switzerland:

sudo mkdir /var/log/switzerland-pcaps
sudo chmod a+wx /var/log/switzerland-pcaps

And finally let’s run it:

sudo switzerland-client

or if you wish to run your own server (you need to advertise it too!)

sudo switzerland-client --server yourserveraddress

Questions?

If you enjoyed this post, make sure you subscribe to my RSS feed!