You are viewing outdated content for BUG. If you have a BUG Y.T. edition or 2.0 series device, please visit our updated wiki: http://wiki.buglabs.net
Start Guide Linux
From BUG Wiki
Note: These instructions assume that your Linux computer's default network interface is eth0. If that is not the case, replace all of the eth0 entries listed below to the appropriate interface (eth1, eth2, etc.).
Install and configure ifplugd
- Install ifplugd
- Configure ifplugd
- Answer as follows:
sudo apt-get install ifplugd
sudo dpkg-reconfigure ifplugd
static interfaces to be watched by ifplugd: eth0 hotplugged interfaces to be watched by ifplugd: usb0 arguments to ifplugd: -q -f -u0 -d10 -w -I suspend behaviour: stop
Editing /etc/network/interfaces
Edit your /etc/network/interfaces file, informing it of the IP networking settings it should use for the usb0 network interface by adding the following:
auto usb0 iface usb0 inet static address 10.10.10.1 netmask 255.255.255.0
Configuring iptables
In most cases, you'll want to give your BUG access to the internet. To configure your usb0 interface to forward requests to your eth0 network device, you'll need to define some rules in iptables. Via the terminal, type the commands below. In the case that you do not want your BUG to have internet access by default, skip the step below.
First, become root via the "su" command or by typing "sudo -i", then perform the following:
iptables -P FORWARD ACCEPT iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE iptables-save > /etc/iptables.rules
Note: These commands must be run by a user who is effectively "root", and have been shown not to work properly by simply prepending them with "sudo" like some other commands in this guide.
Configure ifupdown actions
If you want your BUG to have internet access, on the host pc edit /etc/ifplugd/action.d/ifupdown as root or via sudo, to look like this:
#!/bin/sh set -e case "$1" in usb*) ifconfig usb0 10.10.10.1 netmask 255.255.255.0 echo 1 > /proc/sys/net/ipv4/ip_forward iptables-restore < /etc/iptables.rules ;; esac case "$2" in up) /sbin/ifup $1 ;; down) /sbin/ifdown $1 ;; esac
If you do not want your BUG to have internet access by default, on the host pc edit /etc/ifplugd/action.d/ifupdown as root or via sudo, to look like this:
#!/bin/sh set -e case "$1" in usb*) ifconfig usb0 10.10.10.1 netmask 255.255.255.0 ;; esac case "$2" in up) /sbin/ifup $1 ;; down) /sbin/ifdown $1 ;; esac
Test
Now, plug your BUG into your Linux PC with a USB cable, and try to ping it:
ping 10.10.10.10
If that works, you've gotten IP/USB working! Now, let's login to the BUG and try to ping out to the internet:
ssh root@10.10.10.10 (enter user/password) ping 4.2.2.2
Configuring a Virtual Linux Host for IP/USB under Parallels on OS X
Running a Linux virtual host under Parallels (and also possibly VMWare Fusion) on OS X may require a kernel boot parameter irqpoll in order for the system to properly recognize the USB plug/unplug events. To set this, edit your boot loader (our example assumes GRUB), adding irqpoll to the kernel line.
Example stanza from /boot/grub/menu.lst
title Ubuntu 7.10, kernel 2.6.22-14-generic root (hd0,0) kernel /boot/vmlinuz-2.6.22-14-generic root=UUID=096f4754-354a-4641-83c8-cddd8b4937d7 ro quiet splash irqpoll initrd /boot/initrd.img-2.6.22-14-generic quiet
Note: Only add the irqpoll parameter. Do NOT change your root=UUID=(whatever) or any other options!
