nRF5 IoT SDK  v0.9.0
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Distributing a global IPv6 prefix

Exposing Bluetooth devices outside the link-local network requires distributing a global IPv6 prefix to the connected devices. On Linux, you can use the Router Advertisement Daemon for this purpose. RADVD can periodically or on solicitation send a Router Advertisement message.

Stateless auto-configuration

To communicate outside of the local network, global IPv6 addresses must be configured. There are two possibilities how to obtain these addresses: stateful auto-configuration (using DHCPv6) and stateless auto-configuration. Both methods rely on a router that sends information about the used method. This user guide describes how to use stateless auto-configuration.

Figure 1 illustrates how an IPv6 global address is constructed using stateless auto-configuration.

prefix_stateless.png
Figure 1. Prefix dissemination using stateless auto-configuration.

Router Advertisement Daemon

IPv6 stateless auto-configuration requires the use of Router Advertisement (RA) messages. A Linux application that makes the system act as a router and supports sending RA messages is RADVD (Router Advertisement Daemon). RADVD also listens to Router Solicitation (RS) messages and automatically responds to them with RA.

If you followed the instructions for Installing a 6LoWPAN enabled Linux kernel and required modules, RADVD is already installed. Otherwise, install it:

sudo apt-get install radvd

The RADVD configuration file is located in /etc/radvd.conf. See the following configuration for an example on how to disseminate the prefix 2001:db8::/64 over the bt0 interface.

interface bt0
{
AdvSendAdvert on;
prefix 2001:db8::/64
{
AdvOnLink off;
AdvAutonomous on;
AdvRouterAddr on;
};
};

Description of flags:

  • AdvOnLink - This value is part of the Router Advertisement Message and determines if devices with the advertised prefix are on or off link. If the value is not set (off), all devices should send packets to the router that advertised the prefix, which is required according to the specification.
  • AdvAutonomous - This value is part of the Router Advertisement Message as well and determines if the device that receives the RA should construct the global address using this prefix.
  • AdvSendAdvert - Setting this value on forces the router to periodically send RA messages.

Run RADVD as follows:

# Set IPv6 forwarding (must be present).
sudo echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
# Run radvd daemon.
sudo service radvd restart
# Observe if new IPv6 prefix is disseminating over bt0 interface.

Alternative methods

In some Linux kernel versions, the prefix cannot be assigned automatically to the btX interface as described above. Instead, you can use the following command:

sudo ifconfig btX add 2001:db8::1/64

Alternatively, you can set the interface parameter accept_ra to 2. For example:

sudo echo 2 > /proc/sys/net/ipv6/conf/bt0/accept_ra

However, Linux does not add a route to this prefix automatically.