Beagleboard XM / Angstrom Next Steps: Assigning a Static IP

A few weeks ago I wrote about configuring a Beagleboard XM to run Angstrom Linux.

At the time I was somewhat dubious about whether Angstrom would prove to be a stable platform. So far, so good. My Beagleboard XM has been faithfully working 24/7, receiving Tweet-A-Watt data via XBee and posting power usage updates to Twitter.

Over that time, I’ve made a few tweaks to the initial configuration and have begun to give the new dog some new responsibilities.

The first of the tweaks is to have it use a static IP address rather than using one assigned by the router’s DHCP service.

This tweak is necessary because the XM’s Ethernet port is not a dedicated piece of hardware with a “burnt-in” Ethernet MAC address. Instead, it makes use of the same USB hub chipset’s ability to handle Ethernet communications. (The chipset is an SMSC LAN9514). Saving and restoring the MAC address is the responsibility of the software, and the Linux driver used for this chipset doesn’t support this feature currently.

The end result is that the DHCP server thinks the Beagleboard XM is a new PC every time it is rebooted, and assigns it a new IP address. This is a major nuisance if you are using the XM as a headless server. After each reboot you have to hunt down the XM over the network by checking the DHCP logs, or by physically connecting to its serial port.

One solution to the problem is to manually assign a MAC address by changing the XM’s boot parameters, as described in Max Galemin’s blog post here.

Another solution is to manually assign the IP address, instead. This is somewhat easier to configure, and it allows you to choose an easy-to-remember address. One downside to this approach is that Wake-On-Lan support won’t work, since you need to configure a MAC address for the “magic packet”. I went with a static IP, but if you can’t let sleeping dogs lie (nyuck nyuck nyuck) then go with the static MAC instead.

The process of configuring a static IP address is the same in Angstrom as in most Linux distros. The only catch is that the device name is /dev/usb0, rather than the /dev/eth0 used on most PCs.

1. Switch to root, backup /etc/network/interfaces, then edit it:

user@beagleboard ~  su -
Password:
root@beagleboard:~# cd /etc/network
root@beagleboard:/etc/network# mkdir back122610
root@beagleboard:/etc/network# cp interfaces back122610/

2. You’ll need to know the IP address of your gateway and your DNS server. If you aren’t sure, you can see what the XM is currently using (as assigned by the DHCP server) by running a couple of commands:

root@beagleboard:/etc/network# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 usb0
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 usb0
		  
root@beagleboard:/etc/network# cat /etc/resolv.conf	
search lan
nameserver 111.222.333.444	

Your gateway address is displayeded in the 2nd row of output from netstat -nr (192.168.1.1 in the above example). Your DNS is displayed in the 2nd line of /etc/resolv.conf (111.222.333.444).

3. Edit the interfaces file (e.g. vi interfaces). Comment out the line that says “iface usb0 inet dhcp” and replace it with the following lines, specifying your own IP addresses. In the following example, I’m assigning the XM address 192.168.1.2. The gateway (my router) is address 192.168.1.1. Since my router is configured as a DNS server, my DNS server address is also 192.168.1.1.

# Ethernet/RNDIS gadget (g_ether) or LAN9514
auto usb0
# iface usb0 inet dhcp
iface usb0 inet static
      address 192.168.1.2
      netmask 255.255.255.0
      network 192.168.1.0
      broadcast 192.168.1.255
      gateway 192.168.1.1
      dns-nameservers 192.168.1.1

4. If you are connected from a remote PC, reboot. Otherwise, if you are connected to the Beagleboard’s serial console or with a keyboard and LCD, you can just start and stop the network interface:

root@beagleboard:/etc/network# shutdown -r now

…or…

root@beagleboard:/etc/network# ifdown usb0
root@beagleboard:/etc/network# ifup usb0
This entry was posted in Gadgets and tagged , . Bookmark the permalink.

4 Responses to Beagleboard XM / Angstrom Next Steps: Assigning a Static IP

  1. Richard Poirier says:

    Hi Dan,

    The shutdown -r now command doesn’t work since there’s no NAND flash on the XM board and a reboot wipes the memory… Or is there something I’m doing wrong?

    • Dan says:

      Hi,

      Do you mean that rebooting causes the static IP address to be lost? It shouldn’t if you configure the IP address in the /etc/networks/interfaces file, since that file is saved to the microSD card.

      I’m using an Angstrom Linux build, configured on an SD card as described in an earlier blog post. Other Linux builds might work differently, though I think the /etc/networks/interfaces file is the standard. I’m not certain about the Linux build on the microSD card that comes prepackaged with the XM – I overwrote mine.

      Dan.

  2. Pingback: BeagleBoard XM and Ubuntu 11.04 – The Big Dog Still Has a Burr in its Paw | GigaMegaBlog

  3. Pingback: Der K(r)ampf mit NFS :) | Das Bücherregal