Introduction

The BBB is configured by default to use the dynamic host configuration protocol (DHCP) for the allocation of its wired and wireless IP address. Network routers typically run a DHCP server that allocates a pool of addresses to devices attached to the network. While DHCP works well for most devices on a local network, it can cause difficulties if you wish to make the BBB visible outside a home firewall via port forwarding. This is because DHCP devices may receive a different IP address each time they boot (depending on the router’s lease time).

The following description details the steps required to set your IP address to be static under Debian and Angstrom.

Static IP Address under Debian

[Updated April 2015] To set the IP address to be static under Debian is quite straightforward. You can simply alter the /etc/network/interfaces configuration file to manually specify the address (e.g., 192.168.1.80 in this case), the network mask, and the network gateway. Use an editor, such as nano, to edit the /etc/network/interfaces file and For example, the settings for my network, which has a common configuration, are as follows:
molloyd@beaglebone:~$ uname -a
Linux beaglebone 3.8.13-bone70 #1 SMP Fri Jan 23 02:15:42 UTC 2015 armv7l GNU/Linux
molloyd@beaglebone:~$ cd /etc/network
molloyd@beaglebone:/etc/network$ sudo nano interfaces
[sudo] password for molloyd:

And, edit the interfaces file as follows:
molloyd@beaglebone:/etc/network$ more interfaces

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.80
netmask 255.255.255.0
gateway 192.168.1.1

# Ethernet/RNDIS gadget (g_ether)
iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.0
network 192.168.7.0
gateway 192.168.7.1

The BBB then has a static IP address after reboot. The same procedure applies to other adapter entries, such as the wlan0 wireless Ethernet adapter. Do not pick an address that is within the DHCP pool or assigned to another device, or it will result in IP conflicts on the network. After you reboot the BeagleBone and connect via USB-over-Internet (or directly to the new static IP address) you can view your configuration as follows:
molloyd@beaglebone:~$ ifconfig
eth0 Link encap:Ethernet HWaddr d0:5f:b8:fe:39:93
inet addr:192.168.1.80 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::d25f:b8ff:fefe:3993/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:672 errors:0 dropped:0 overruns:0 frame:0
TX packets:130 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:107438 (104.9 KiB) TX bytes:15588 (15.2 KiB)
Interrupt:40

Static IP Address Under Angstrom

The current configuration in this part is Angstrom on Beaglebone Black with:
$ uname -a:
Linux beaglebone 3.8.11 #1 SMP Wed May 8 07:34:27 CEST 2013 armv7l GNU/Linux

On my network I have configured the router so that it gives out DHCP addresses in the range 100-255, so below 100 is available to be fixed. So, just be careful that you choose a static address that does not clash with an existing device on your network.

My current setup is available through ifconfig as:
root@beaglebone:/etc/network# ifconfig
eth0 Link encap:Ethernet HWaddr C8:A0:30:AB:32:3A
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::caa0:30ff:feab:323a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1855 errors:0 dropped:0 overruns:0 frame:0
TX packets:424 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:232957 (227.4 KiB) TX bytes:55698 (54.3 KiB)
Interrupt:56

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:234 errors:0 dropped:0 overruns:0 frame:0
TX packets:234 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:19082 (18.6 KiB) TX bytes:19082 (18.6 KiB)

usb0 Link encap:Ethernet HWaddr A2:CB:A9:A8:0B:F4
inet addr:192.168.7.2 Bcast:192.168.7.3 Mask:255.255.255.252
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

loopback is the way for a device to refer to itself using localhost or the ip address 127.0.0.1. The adapter usb0 describes the network adapter that is referred to in the “Getting started with the Beaglebone” guide where you can connect to your Beaglebone via USB with the fixed address: 192.168.7.2.

Using Connman

We want to change eth0 to use a static address. The Angstrom distribution on the Beaglebone Black uses connman which claims that it:

provides a daemon for managing internet connections within embedded devices running the Linux operating system. The Connection Manager is designed to be slim and to use as few resources as possible, so it can be easily integrated. It is a fully modular system that can be extended, through plug-ins, to support all kinds of wired or wireless technologies. Also, configuration methods, like DHCP and domain name resolving, are implemented using plug-ins. The plug-in approach allows for easy adaption and modification for various use cases.

Go to the directory: /var/lib/connman and you can see that there is a directory ethernet***. You can see that the settings appear in the file settings. In my case the ethernet is: ethernet_c8a030ab323a_cable

root@beaglebone:/var/lib/connman# ls -al
total 16
drwxr-xr-x 3 root root 4096 Jan 1 2000 .
drwxr-xr-x 18 root root 4096 Jan 1 2000 ..
drwx------ 2 root root 4096 Jan 1 2000 ethernet_c8a030ab323a_cable
-rw------- 1 root root 68 Jan 1 2000 settings
root@beaglebone:/var/lib/connman# cd ethernet_c8a030ab323a_cable/
root@beaglebone:/var/lib/connman/ethernet_c8a030ab323a_cable# ls
data settings settings.ODU2WW
root@beaglebone:/var/lib/connman/ethernet_c8a030ab323a_cable# more settings
[ethernet_c8a030ab323a_cable]
Name=Wired
AutoConnect=true
Modified=2000-01-01T01:18:21.869401Z
IPv4.method=dhcp
IPv4.DHCP.LastAddress=192.168.1.100
IPv6.method=auto
IPv6.privacy=disabled

To change the values you should not modify these files – instead, go to the directory: /usr/lib/connman/test and you can see a list of scripts that allow you to make changes to your network configuration. The full list of connman scripts is:
root@beaglebone:/usr/lib/connman/test# ls -al
total 140
drwxr-xr-x 2 root root 4096 Mar 18 12:46 .
drwxr-xr-x 3 root root 4096 Mar 18 12:46 ..
-rwxr-xr-x 1 root root 1118 May 6 15:13 backtrace
-rwxr-xr-x 1 root root 2144 May 6 15:13 connect-vpn
-rwxr-xr-x 1 root root 889 May 6 15:13 disable-tethering
-rwxr-xr-x 1 root root 348 May 6 15:13 disconnect-vpn
-rwxr-xr-x 1 root root 1334 May 6 15:13 enable-tethering
-rwxr-xr-x 1 root root 233 May 6 15:13 get-global-timeservers
-rwxr-xr-x 1 root root 621 May 6 15:13 get-proxy-autoconfig
-rwxr-xr-x 1 root root 1277 May 6 15:13 get-services
-rwxr-xr-x 1 root root 229 May 6 15:13 get-state
-rwxr-xr-x 1 root root 1512 May 6 15:13 list-services
-rwxr-xr-x 1 root root 2120 May 6 15:13 monitor-connman
-rwxr-xr-x 1 root root 2799 May 6 15:13 monitor-services
-rwxr-xr-x 1 root root 571 May 6 15:13 service-move-before
-rwxr-xr-x 1 root root 485 May 6 15:13 set-domains
-rwxr-xr-x 1 root root 386 May 6 15:13 set-global-timeservers
-rwxr-xr-x 1 root root 982 May 6 15:13 set-ipv4-method
-rwxr-xr-x 1 root root 1115 May 6 15:13 set-ipv6-method
-rwxr-xr-x 1 root root 496 May 6 15:13 set-nameservers
-rwxr-xr-x 1 root root 1274 May 6 15:13 set-proxy
-rwxr-xr-x 1 root root 491 May 6 15:13 show-introspection
-rwxr-xr-x 1 root root 5796 May 6 15:13 simple-agent
-rwxr-xr-x 1 root root 390 May 6 15:13 test-clock
-rwxr-xr-x 1 root root 351 May 6 15:13 test-compat
-rwxr-xr-x 1 root root 4702 May 6 15:13 test-connman
-rwxr-xr-x 1 root root 1610 May 6 15:13 test-counter
-rwxr-xr-x 1 root root 2079 May 6 15:13 test-manager
-rwxr-xr-x 1 root root 285 May 6 15:13 test-new-supplicant
-rwxr-xr-x 1 root root 8951 May 6 15:13 test-session
-rwxr-xr-x 1 root root 1333 May 6 15:13 test-supplicant

Here we can use the get-services script to give you a list of the current services:
root@beaglebone:/usr/lib/connman/test# ./get-services
[ /net/connman/service/ethernet_c8a030ab323a_cable ]
IPv6.Configuration = { Method=auto Privacy=disabled }
AutoConnect = true
Name = Wired
Nameservers = [ 192.168.1.1 ]
Provider = { }
Favorite = true
Domains.Configuration = [ ]
Timeservers.Configuration = dbus.Array([], signature=dbus.Signature('s'), variant_level=1)
State = online
Proxy = { Method=direct }
Nameservers.Configuration = [ ]
IPv4 = { Netmask=255.255.255.0 Gateway=192.168.1.1 Method=dhcp Address=192.168.1.100 }
Timeservers = dbus.Array([dbus.String(u'192.168.1.1')], signature=dbus.Signature('s'), variant_level=1)
IPv6 = { }
Domains = [ home.gateway ]
Ethernet = { Interface=eth0 MTU=1500 Method=auto Address=C8:A0:30:AB:32:3A }
Security = [ ]
Proxy.Configuration = { }
Type = ethernet
Immutable = false
IPv4.Configuration = { Method=dhcp }

Importantly, you can see the name of your ethernet service at the top. In my case it is: ethernet_c8a030ab323a_cable. You will need this below for the following two steps.

Step 1 – Setting the Nameservers

The first thing we need to do is set the nameserver(s) manually, as once you go through step 2, removing dhcp support, this setting will likely be lost. If you wish to use the nameserver that you currently have as above (192.168.1.1 in my case), simply call the script set-nameservers (note: 8.8.8.8 is the Google Public DNS – always a useful backup DNS if your local DNS fails):
root@beaglebone:/usr/lib/connman/test# ./set-nameservers
Usage: ./set-nameservers [nameserver*]
root@beaglebone:/usr/lib/connman/test# ./set-nameservers ethernet_c8a030ab323a_cable 192.168.1.1 8.8.8.8
Setting nameserver to ['192.168.1.1', '8.8.8.8']
root@beaglebone:/usr/lib/connman/test#

Step 2- Changing the Network Settings

We want to change our adapter settings to use a static IP address, so using the set-ipv4-method script you can see the usage as:
root@beaglebone:/usr/lib/connman/test# ./set-ipv4-method
Usage: ./set-ipv4-method <service> [off|dhcp|manual <address> [netmask] [gateway]]

So, for my network I want to use the ip address 192.168.1.80 with a netmask of 255.255.255.0 and a gateway of 192.168.1.1, so my call will be:
./set-ipv4-method ethernet_c8a030ab323a_cable manual 192.168.1.80 255.255.255.0 192.168.1.1

The output will be:
root@beaglebone:/usr/lib/connman/test# ./set-ipv4-method ethernet_c8a030ab323a_cable manual 192.168.1.80
255.255.255.0 192.168.1.1

Setting method manual for ethernet_c8a030ab323a_cable

And the ssh client connection should likely freeze as the IP address of your Beaglebone should have changed. To kill your shh client session type ~. (i.e. tilda followed by a full stop) in your frozen shell window and this should terminate the ssh client session. Give the Beaglebone a few seconds to reboot and then from your desktop client you should be able to:
molloyd@molloyd-VirtualBox:~/Desktop$ ssh 192.168.1.80 -l root
The authenticity of host '192.168.1.80 (192.168.1.80)' can't be established.
RSA key fingerprint is b6:b0:e7:16:87:86:9e:e9:cc:23:a7:c5:99:03:9c:58.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.80' (RSA) to the list of known hosts.
root@192.168.1.80's password:
root@beaglebone:~#

Test that your nameservers setting is working correctly:
root@beaglebone:/usr/lib/connman/test# ping derekmolloy.ie
PING derekmolloy.ie (79.140.142.22) 56(84) bytes of data.
64 bytes from lb1.reg365.net (79.140.142.22): icmp_req=1 ttl=56 time=18.3 ms
64 bytes from lb1.reg365.net (79.140.142.22): icmp_req=2 ttl=56 time=18.0 ms

etc.
And you are done.