I got my Raspberry Pi this week, and I have to say that despite the wait (or maybe because of it), the whole user experience of getting this running was exciting. I was reminded of when my Dad brought home our first “Fat Mac” in 1985 (Fat because it had 512k of RAM). Actually, this was a better experience; when we got the Mac home from Computerland we found it had a bad mouse controller and we had to wait until Monday to bring it back. Getting the big Raspberry Pi logo up on the TV felt a little like seeing the Happy Mac for the first time, even though I didn’t have to do anything other than format an SD card.
One of the first things I realized was that the need for a wired Ethernet connection is kind of a hurdle; it goes against the way that most of us get online these days. I only have two wired connections in my house now, in inconvenient locations where our desktop computers used to be years ago. When I’m in the studio out back I’m always connecting via Wifi with my Mac; I thought one of the first things I’d do would be to set the Mac up as a proxy server for the Pi.
A quick aside on peripherals and the Raspberry Pi: I could see how these could add up really quickly. I have an extra DVI monitor so I got a HDMI to DVI cable, and you definitely need a proper micro USB supply (at least 1 amp; your phone charger won’t cut it). Online these are cheap enough; expect to spend at least another $15 to $20, or much more if you try to get these items in retail stores. A $30 Wifi dongle might work, but from reading the forums it seems that the USB ports are a bit under spec and should probably not be thought of as equivalent to a standard computer USB port. Thus, my decision to go with a software proxy solution.
Read on for all the steps for configuring a proxy server on the Mac for your Raspberry Pi.
Step 1: Set up a small network
The simplest network is a crossover cable connecting the two computers. To find out if your Ethernet cable is a crossover, look at both ends side-by-side; if they have the same colored wires in the same order, it isn’t a crossover cable. I had an old four port hub/switch, so I just plugged the Pi and the Mac into that.
Step 2: Configure the network interfaces
On the Mac, open up your Network Preferences and select the wired Ethernet interface from the list at the left. It is probably set up to automatically acquire an IP address; change this to Manually and enter the values shown in the screenshot:
What we’re doing here is just manually setting up a network on the subnet 192.168.10.X with two nodes. You can use other values as long as the first three numbers are the same on the Mac and the Pi.
On the Raspberry Pi, open a new shell (on Raspbian go to Accessories/LXTerminal). Type:
sudo pico /etc/network/interfaces
(Of course, substitute your text editor of choice for pico.) Comment out the line:
#iface eth0 inet dhcp
and add the lines:
auto eth0 iface eth0 inet static address 192.168.10.2 netmask 255.255.255.0
Now restart the network interface:
sudo ifup eth0
You should now be able to ping each computer from the other now. Try this out to test the network:
ping 192.168.10.2 PING 192.168.10.2 (192.168.10.2): 56 data bytes 64 bytes from 192.168.10.2: icmp_seq=0 ttl=64 time=0.823 ms 64 bytes from 192.168.10.2: icmp_seq=1 ttl=64 time=0.798 ms
Looks like it’s working. You should be able to ssh into the Raspberry Pi from your Mac now, if you like:
ssh raspbian@192.168.10.2
3. Install the proxy server
The proxy server is a small program running on the Mac (which is connected to the Internet via Wifi) that listens on a port for http requests. The proxy then grabs the requested resources and forwards them to the requestor. For a proxy on the Mac I used Squidman, a port of Squid with a graphical interface. I didn’t shop around, but Squidman looks excellent to me (http://squidman.net/squidman/). Install the application from the .dmg and run it. You don’t really need to change any of the default settings, but I explicitly listed the IP address of the Raspberry Pi in the Clients tab of the Preferences panel. Click “Start Squid” and you’re good to go.
4. Point the Raspberry Pi at the proxy
If you’re developing on the Raspberry Pi, you’ll be using the apt package manager a lot to install software. To configure apt to use a proxy server, add a new configuration file:
sudo pico /etc/apt/apt.conf.d/01proxy
Add the following line to the file:
Acquire::http::Proxy "http://192.168.10.1:8080";
When you’re done, run:
sudo apt-get update
You should see apt-get retrieve new lists of packages from the Internet over the proxy connection. Now you should be able to follow any instructions for installing software on the Pi.
To configure your web browser (Midori on the default distributions), go to the Preferences and add the following to the Network tab:
(BTW, if you’re wondering how to take a screenshot on the Raspberry Pi, try: sudo apt-get install scrot; scrot).
I’d be the first to admit that my sysadmin skills are a bit rusty and grounded in the 20th Century. If anyone has a better solution to share (or wants to adapt this for Windows or Linux), please post in the comments!
Next stop, installing Pure Data…
ADVERTISEMENT