This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Making IPv6 device available on the internet

Hei

I've gotten the ipv6_coap_server example to run on the nRF51-dongle. I got the bt0 interface after connecting to the device and I am able to ping the device.

My LAN has native IPv6 delivered from my ISP. The gateway router (broadband router) is getting its IPv6 with DHCP-PD and is allocated a /60 range, but is using stateless address configuration on the LAN. My desktop is getting a globally routable IPv6 address and can I can connect to and from the desktop from remote machines.

If I run radvd on my desktop I can give the device a global address, but as far as I know it shouldn't be necessary as my LAN already has a router.

I have tried to bridge the two interfaces with brctl but that fails when adding the bt0 interface.

My setup looks like this:

(nrf51)  <-- BT --> (BT dongle) <- USB -> Linux Host <- ethernet -> DSL router

What do I need to do to get the device to be available on the internet too?

  • Hello Christoph S, and everyone. Does this(brctl addbr br0 ,brctl addif br0 eth0 bt0) means that the Nrf51-DK can be routable from other WAN networks ? Thanks

  • Hello guys,

    I am also encounterin that problem. I was also not able to setup a bridge via brctl-command because I am also receiving Invalid argument-Error.

    The nRF51 has received a IPv6 Address from the Raspberry Pi via radvd. The device can send DNS-Queries to the Internet and I was also able to receive DNS-Responses on the Raspberry Pi. For some reason the Pi refuses to forward the answers to the nRF. Its also interesting, that NAT doesn't work properly - I can see that IP-Frames are sent and also received with the IPv6 Address from the nRF, not the IPv6 Address from the Pi as intended.

    Could you guys please help me with tracking down the error? Maybe some command I forgot, some switch I have to trigger? The project I am trying to get to work is the Cloud -> CoAP Example. I also tried it with the nRF52 but it still didn't work.

    Init-Script:

    #!/bin/sh
    # Moutn debugfs file system
    mount -t debugfs none /sys/kernel/debug
    
    # Load 6LoWPAN module
    sudo modprobe bluetooth_6lowpan
    # Enable 6LoWPAN
    sudo echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable
    # Set IPv6 forwarding
    sudo echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
    
    # Run Router-Advertisement Daemon (radvd)
    sudo service radvd restart
    
    # Look for available HCI devices
    # hciconfig
    
    # Reset HCI device
    hciconfig hci0 reset
    
    # Read BLE-Address from nRF51
    # hcitool lescan
    
    # Connect to the device
    sudo echo "connect 00:XX:XX:XX:C1:A9 1" > /sys/kernel/debug/bluetooth/6lowpan_control
    
    # Add the IP prefix to the Bluetooth Interface bt0
    sudo ifconfig bt0 add 2002::1/64
    # Restart radvd service
    service radvd restart
    #####################
    # Firewalll rules
    #####################
    # Delete all former rules (flush)
    ip6tables -F INPUT
    ip6tables -F OUTPUT
    ip6tables -F FORWARD
    ip6tables -F
    ip6tables -X
    
    # Set the default policy to accept
    ip6tables -P INPUT ACCEPT
    ip6tables -P OUTPUT ACCEPT
    ip6tables -P FORWARD ACCEPT
    
    # Enabling IPv6 forwarding disables route-advertisement reception
    # A static gateway will need to be assigned.
    echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
    
    # Forward all traffic from Bluetooth-Interface to Ethernet-Interface
    sudo ip6tables -A FORWARD -i bt0 -o eth0 -j ACCEPT
    # Forward all traffic from Ethernet-interface to Bluetooth-Interface
    sudo ip6tables -A FORWARD -i eth0 -o bt0 -m state --state RELATED,ESTABLISHED -j ACCEPT
    # Use Network Address Translation (NAT) for all traffic to the internet
    ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    

    etc/radvd.conf

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

    ifconfig

        pi@raspberrypi:~ $ ifconfig
    bt0       Link encap:UNSPEC  HWaddr 00-XX-XX-XX-XX-XX-XX-XX-00-00-00-00-00-00-00-00
              inet6 addr: fe80::21a:7dff:xxxx:xxxx/64 Scope:Link
              UP POINTOPOINT RUNNING MULTICAST  MTU:1280  Metric:1
              RX packets:63 errors:0 dropped:0 overruns:0 frame:0
              TX packets:191 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1
              RX bytes:4725 (4.6 KiB)  TX bytes:10502 (10.2 KiB)
    
    eth0      Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
              inet addr:192.168.0.16  Bcast:192.168.0.255  Mask:255.255.255.0
              inet6 addr: fd00:bc14:1b9:6082:2f6:xxxx:xxxx:xxxx/64 Scope:Global
              inet6 addr: 2a02:8108:1a40:23f4:7330:xxxx:xxxx:xxxx/64 Scope:Global
              inet6 addr: fe80::2964:4ac:xxxx:xxxx/64 Scope:Link
              inet6 addr: 2a02:8108:xxxx:xxxx::2/128 Scope:Global
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:38800 errors:0 dropped:2 overruns:0 frame:0
              TX packets:44508 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:4279815 (4.0 MiB)  TX bytes:39169823 (37.3 MiB)
    
    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:167005 errors:0 dropped:0 overruns:0 frame:0
              TX packets:167005 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1
              RX bytes:423921129 (404.2 MiB)  TX bytes:423921129 (404.2 MiB)
    
    wlan0     Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
              inet6 addr: xxxx::xxxx:xxxx:xxxx:xxxx/64 Scope:Link
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:1553 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)
    
  • Okay for everyone that is encountering the same problem: The solution is quite simple

    As hirotaka mentioned, you have to setup a Route from the raspberry pi to your nRF-Device. Outgoing packets from the nRF are using the standard gateway to reach the internet - but packets from the internet to the nRF cannot reach your device.

    To build up a route you just have to put up this command:

    sudo route -A inet6 add 2002::/64 dev bt0
    

    While 2002::/64 is the prefix from radvd and bt0 is the bluetooth interface.

  • To safe others time, here is the answer if your provides does NOT support ipv6 on your local box (which seems to be the unstated assumption for all answers and the IOT SDK documentation).

    First, run

    http://test-ipv6.com/

    To determine if you have full ipv6 support. If not, keep reading. If you're in a NAT'ed environment (192.X, 10.X etc.) give up. But if your bridge (pi3 in my case) has a DNS-resolvable IP, then follow the description above except for the ip6table commands and then:

    Create a 6to4 connection from the pi3 (w/ eth0 IP A.B.C.D, make sure to use the corresponding hex values in the 3rd cmd below):

    ip tunnel add 6to4 mode sit remote any local A.B.C.D

    ip link set 6to4 up

    ip addr add 2001:xAB:xCD::1/16 dev 6to4

    ip -6 route add default via ::192.88.99.1 dev 6to4

    (This assumes the commands above. If you followed the SDK documentation, which uses 2001:db8::1 for bt0, you'd have to use 2002:... in the ip addr cmd above instead. They need to be 2 different prefixes.)

    Then create an ipv6 NAT:

    /sbin/ip6tables -t nat -A POSTROUTING -o 6to4 -j MASQUERADE

    /sbin/ip6tables -A FORWARD -i 6to4 -o bt0 -m state --state RELATED,ESTABLISHED -j ACCEPT

    /sbin/ip6tables -A FORWARD -i bt0 -o 6to4 -j ACCEPT

    and viola! I strongly suggest to add this to the SDK documentation to save others days of tinkering w/ broken kernels (6lowpan is briddle), misleading answers on posts etc.

    On a related note, why even go ipv6 at all? Most IOT devices will be behind a NAT, using ipv4 would have been much easier (since ipv6 may never see full support by ISPs)? But that's more of a philosophical RFC question.

  • Hi,

    I'm trying to follow these steps however when running:

    ip addr add 2002:xAB:xCD::1/16 dev 6to4 (I followed the SDK documentation)

    I keep getting the error: Error: ??? prefix is expected rather than "2002:192168:106145::1/16".

    What should be the format of xAB and xBC? Could you provide an example?

    Thanks in advance

Related