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?

Parents
  • 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.

Reply
  • 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.

Children
  • I have a similar setup. But instead of using eth0 i am using wlan0. So in all commands I replaced eth0 to wlan0.

    But my ping6 from bt0 to wlan0 is failing. 

    Any suggestion what can be the issue and where can be the mistake?

    Thanks in advance for your help. 

    Here are the details of the steps:

    platform: Raspberry Pi 3 Model B+ and Raspbian Stretch


    My Setup is exactly like this:


    Bluetooth Node <-- BT --> Raspberry Pi <-- Wifi --> 4G Wireless Router --> Internet

    RPI Wifi gets 2405:204:1290:3eb1:ab2c:9c70:7c27:xxxx/64 address from 4G Wireless Router.

    My etc/radvd.conf

    interface bt0
    {
    AdvSendAdvert on;
    AdvSourceLLAddress on;
    prefix 2002::/64
    {
    AdvOnLink off;
    AdvAutonomous on;
    AdvRouterAddr on;
    }; # End of prefix definition
    };

    I added a static IPv6 address to bt0
    #Ip address add 2002::1/64 dev bt0

    My “ip -6 addr show” gives:
    # ip -6 addr show
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN qlen 1000
    inet6 ::1/128 scope host
    valid_lft forever preferred_lft forever
    3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
    inet6 2405:204:1290:3eb1:ab2c:9c70:7c27:xxxx/64 scope global mngtmpaddr noprefixroute
    valid_lft forever preferred_lft forever
    inet6 fe80::9ed1:3e80:de2a:e601/64 scope link
    valid_lft forever preferred_lft forever
    4: bt0: <MULTICAST,UP,LOWER_UP> mtu 1280 state UNKNOWN qlen 1000
    inet6 2002::1/64 scope global
    valid_lft forever preferred_lft forever
    inet6 fe80::b827:ebff:fe3d:4f70/64 scope link
    valid_lft forever preferred_lft forever

    Other commands I have run:
    #echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
    #ip route add 2002::/64 dev bt0
    #ip6tables -A FORWARD -i bt0 -o wlan0 -j ACCEPT
    #ip6tables -A FORWARD -i wlan0 -o bt0 -j ACCEPT
    #ip6tables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
    #service radvd restart

    #My “ip -6 route show” gives:
    2002::/64 dev bt0 proto kernel metric 256 pref medium
    2002::/64 dev bt0 metric 1024 pref medium
    2405:204:1290:3eb1::/64 dev wlan0 proto kernel metric 303 mtu 1500 pref medium
    fe80::/64 dev wlan0 proto kernel metric 256 pref medium
    fe80::/64 dev bt0 proto kernel metric 256 pref medium
    default via fe80::8bf:4ace:e70a:xxxx dev wlan0 metric 303 mtu 1500 pref medium

    My ping6 from bt0 to wlan0 global address returns:
    #ping6 -I bt0 2405:204:1290:3eb1:ab2c:9c70:7c27:xxxx
    connect: Network is unreachable
    My ping6 from bt0 to wlan0 Link Local address returns:
    #ping6 -I bt0 fe80::9ed1:3e80:de2a:e601
    PING fe80::9ed1:3e80:de2a:e601(fe80::9ed1:3e80:de2a:e601) from fe80::b827:ebff:fe3d:4f70%bt0 bt0: 56 data bytes
    ^C
    --- fe80::9ed1:3e80:de2a:e601 ping statistics ---
    2 packets transmitted, 0 received, 100% packet loss, time 1071ms

Related