Introduction
If you saw me at DefCon this year, you probably saw me using my HP Jornada. There was also a pretty good chance that you saw me getting it online in strange ways...HACK THE PLANET! (Or just dial up a BBS...) |
Yes, that's a Raspberry Pi Model B inside a case made of LEGO bricks. |
Setting up Arch Linux
Being no stranger to building embedded systems, I decided to go with a bare-bones Arch Linux ARM install on a 2GB SD card. You could likely run with an even smaller card if you wanted to. The installation instructions are pretty straight-forward if you're familiar with the command line.Once you have Arch Linux up and running on the Pi, I recommend changing the default passwords (alarm/alarm, root/root) and then doing a system update to get the latest packages from base. Simply connect the Pi to the Internet through its ethernet port, then run "pacman -Syyu" as root.
Configuring the network
The 3 interfaces we worry about are eth0, usb0 and br0. The first two basically work right out of the box:/etc/systemd/network/eth0.network exists from the default installation, so the ethernet port is already set up for us.
When you activate USB Tethering from Android while plugged in to most modern Linux distros, it shows up as a network device (in this case, usb0) without any extra configuration.
br0 (the bridge interface) needs to be configured. First, we establish a netctl profile for it. Put the following text into a file called /etc/netctl/br0
Description="PiTether USB/Ethernet connection"Next, create a service file for systemd that calls netctl for the br0 interface. Put these contents in /etc/systemd/system/netctl@br0.service
Interface=br0
Connection=bridge
BindsToInterfaces=(eth0 usb0)
IP=dhcp
SkipForwardingDelay=yes
.include /usr/lib/systemd/system/netctl@.serviceRun the following command as root to enable the interface during start-up:
[Unit]
Description=PiTether USB/Ethernet connection
BindsTo=sys-subsystem-net-devices-eth0.device
BindsTo=sys-subsystem-net-devices-usb0.device
After=sys-subsystem-net-devices-eth0.device
After=sys-subsystem-net-devices-usb0.device
netctl enable br0
Reboot the Pi to make sure everything works as planned. To test:
- Plug in your phone and activate USB Tethering.
- Plug a device into the ethernet port of the Raspberry Pi
- Request a DHCP Lease (happens automatically on most devices)
- Try to browse the web or connect to something over the Internet (ping, ssh, etc)
You can probably do this by sliding the write-protect tab on the SD card (for Pi A and B only) however, I opted to mark both filesystems "ro" in /etc/fstab. Apparently, root (/) is optional in fstab, but I added it by copying the /boot line and slightly altering the device and mountpoint fields. My /etc/fstab looks like this:
#You can give it one more reboot and test after that if you want. If you ever want to change anything in the filesystem, you can temporarily remount it read-write again by using the command "mount -o remount,rw /" while logged in as root. You can use that to remove ",ro" from the fstab options or to occasionally update packages.
# /etc/fstab: static file system information
#
# file system dir type options dump pass
/dev/mmcblk0p0 / ext4 defaults,ro 0 0
/dev/mmcblk0p1 /boot vfat defaults,ro 0 0