Mobile Mesh Networks with the Raspberry Pi – Part 3

Route output for the mesh network.In my previous post I outlined how to get wireless networking working on the Pi’s. While no amazing feat, it was an important test to see how well the drivers functioned for the wifi dongle. Now let’s take the next step and set up an ad-hoc, mesh network!

Setting up Wireless Networking (ad-hoc)

Setting up mesh networking on the Pi’s is fairly straight-forward. It helps if you do not have an ethernet connection and are just working to set up the wifi connection first on the target device.

1. Before you unplug the ethernet, install this package # packer -S babeld . Note: If the Pi complains about system architecture, just change it in the PKGBUILD.
2. First we need to undo some of the previous steps used for a managed wireless connection. To make sure your wifi card doesn’t associate on boot, execute # systemctl disable netcfg@PROFILENAME.service && reboot  if you followed the previous tutorial.
3. Now your Pi should be up and running again and the wifi dongle should not be powered up. Power up the wifi dongle: # ip link set wlan0 up .
4. Now let’s configure the network: # iwconfig wlan0 mode ad-hoc channel 11 essid "mesh" .
5. Right now we need to manually assign each Pi a unique ip address: # ip addr add dev wlan0 . As you repeat these steps on each Pi, give the next one a different address, for example, and so forth.
6. And now we fire up babeld: # babeld wlan0 & .
7. If everything goes well, you should be on your way to a mesh network. Execute the following steps on the remaining Pis. The routes will be updated automagically as nodes enter or exit the network. Use # route to display the other nodes.

See Also

Part 1

Part 2

Part 4

This Post Has 27 Comments

  1. seza says:

    Hi Eric,
    thank you for the write up about using the Raspi for Wireless mesh network,
    as of part 3 you have not evaluated the system yet? does it work? how many nodes are setting up?

    thanks again

    • Eric Erfanian says:

      Indeed, the system does work. I get all the sorts of normal connectivity you would expect on a network (ssh, ping, and so forth). You can see the route info in the screenshot above. There are only two routes printed because the node where the command was executed doesn’t get counted.

      Three nodes are in the mesh. I’ll try to get some more metrics into my next write up.

      Thanks for the questions.

  2. Xandrios says:

    Great post! Thanks!

    I have been looking into setting up a mesh network over the city with a couple of friends. Perhaps 6-8 nodes. Using a raspberry to build nodes could work very well: One or two wifi dongles, and an Ethernet connection for the household providing power to the node. (Allowing them to use internet provided by the network).

    • Eric Erfanian says:

      Sounds like a fun project. I haven’t tried power-over-Ethernet, but it could be a slick way to limit the number of cables you have to run.

      I think the really cool next step would be setting up a distributed file system across the Pis to share things. I tried compiling GlusterFS but it didn’t succeed with 256MB of RAM. Maybe the 512MB version would be more successful, or some other software package.

  3. nw15062 says:

    I tried to follow your steps on Rasbain and found that everything works up to the point of executing babeld the error I receive is :

    “Couldn’t read forwarding knob.: No such file or directory
    kernel_setup failed.”

    Any idea of what might be failing? I am not sure what “forwarding knob” is to even know where to begin.

    • worldgnat says:

      This happens when babeld can’t read /proc/sys/net/ipv6/conf/all/forwarding, which specifies whether forwarding is allowed for ipv6 interfaces. In my case, this happened because the ipv6 kernel module wasn’t loaded, so /proc/sys/net/ipv6 didn’t even exist. Try “modprobe ipv6”; that should fix it.

      • Kush says:


        I am encountering the same error (“Couldn’t read forwarding knob.: No such file or directory
        kernel_setup failed.”) and I could not find the dir “/proc/sys/net/ipv6”

        Also, executing “modprobe ipv6″ did not solve the problem.

        Should I create a new directory named “/proc/sys/net/ipv6/conf/all/forwarding” ?

        Or is there an alternate method to handle this error?

        Also, is this reason why “babeld wlan0” shows as “command not found”?

        Thank you.

        • Eric Erfanian says:

          These instructions are for Arch Linux. I have no idea what packages the Debian based maintainers choose to include or what they may or may not select when they compile the kernel for the pi.

          It could be the case that they have chosen to remove ipv6 components, but I honestly have no idea. This would cause the module to fail to be probed, but it could be any number of things.

          According to, “The proc filesystem is a pseudo-filesystem which provides an interface to kernel data structures. It is commonly mounted at /proc. Most of it is read-only, but some files allow kernel variables to be changed.”

          I think it would be unlikely that manually creating this configuration file would be an effective solution. Even if it were to work, babeld might crash when it tries to take advantage of some other ipv6 code path. Your best bet is to get the ipv6 module compiled and probed.

          If you cannot execute babeld it is either a) not installed or b) not sourced properly. You’d have to execute the direct binary location e.g. /usr/bin/babeld . Given that you have encountered the above knob error it would seem to indicate you can indeed execute babeld. So it is probably something else. Maybe your interface name is different? Interface naming conventions have changed in more recent kernels.

  4. nw15062 says:

    I’m sorry to waste your time i checked the source code and found the error has to do with IPv6 not enabled. I added IPv6 to “/etc/modules” and it went through fine.

    • Eric Erfanian says:

      No worries, glad it’s working for you. Thanks for adding to the knowledge base in the blog post.

  5. m says:

    Hello there, I am a little wet behind the ears with networking in general, but I get the gist of it, I *think*. Basically, one Pi acts as a virtual router, accepting incoming connections from the other Pi’s, which are configured to connect to that ESSID, basically? If so, couldn’t dhcpd be used to handle IP addr allocation?

    I could be totally off base, I have a similar project in mind, 3 Pi system, one which will be running postgres, another writing to it, and another reading/displaying it. I have the last Pi wi-fi dongle on order, and was confused a bit. Do all Pi’s have to have babeld installed/configured, and setup with a different ip? It was my understanding that babeld acts as a router/gateway.

    Thanks for your help.

    • Eric Erfanian says:

      Yes that sounds about right. Read part four if you haven’t where it talks about NAT routing.

      It depends where you want to put the the DHCP server. If your router acts as the dhcp server, you wouldn’t want the pi connected to it to act as one as well because things might get confused.

      If one Pi is acting as a NAT to the others, your router won’t know about the Pis in the mesh because they aren’t visible to it — it’s a subnet. You’d want something like avahi or ahcp to do dhcp for mesh because its volatile.

      All Pis have to have babeld installed and configured with a different ip just like any other network — how you assign those ip’s can differ, however.

      • m says:

        This is a carputer setup, so the availability of actual internet will be handled by something else. I will most often be dealing with a mesh network situation only, no public internet access, just direct access from each node/Pi.

        One question I do have though – I am going to be writing a data driven application that will connect through the mesh to a separate Pi which hosts the database, which will be constantly being written to. Do you see there ever being a problem/correlation between network throughput/performance on the Pi itself when bandwidth is starting to get used up? I plan on running a few things over the mesh network, just curious if you had seen anything related to that.

        Thanks again! You cleared up a few things for me, I have all my Pi’s here to start my project, just waiting on wi-fi dongles to mesh em’ up. 🙂

          • m says:

            Interesting, I see how it all relates when you have an active internet connection and it is bridged correctly.

            My question was more related towards data throughput/CPU usage when data transfers are constrained to only inside the mesh network itself. AKA, would I be able to use full wireless bandwidth between only 2 Pi’s and get way better transfer rates, in your example for say, when downloading the Linux ISO, what would be the CPU usage/network throughput be like when transferring the large file from PiThree to PiTwo? That is my main concern. If so, I may have to have a dedicated Pi as a router itself…

            Thanks for anymore insight, been a great help so far! 🙂

    • Eric Erfanian says:


      All the Pis in the mesh are on the same ESSID. If you’re not worrying about connections to the internet or a larger network, babel is really good about redistributing routes around the network as nodes enter or exit the mesh.

      I gave all the Pis static ips. I’m not sure how avahi or ahcp work to assign addresses in a mesh. I’d be curious to know if you figure it out.

  6. Jason says:

    Thank you for the tutorial, I have it working on a number of Raspberry Pi’s. Now I just need to work out systemd so that it is configured from boot.
    I am also keen to see how to use ahcpd instead of static IP’s.

  7. Sora says:

    After a few tries, I couldn’t use babel on my raspberry Pi (running raspbian wheezy instead of archlinux) with my computer (unbuntu 12.04).

    I’m using a realtek RTL8188CUS wifi dongle on wlan1 (wlan0 being connected to the internet)

    When running in debug mode (# babeld -d 2 wlan1)
    I have the following error: “send: Network is unreachable”

    Could anyone help me on that ?

  8. arif says:

    I have same problem with sora,.
    when running babeld wlan0 ,
    i have following error : “Couldn’t determine channel of interface wlan0 : Link has been severed
    send : Network is unreachable”

    Please help me Mr. Eric

    Thank you very much..

    • Eric Erfanian says:

      Are you using Arch Linux? My conclusion was that he wheezy distro didn’t include the correct kernel modules, but others have reported differently. Your mileage may vary.

  9. arif says:

    I am using arch linux with kernel 3.6.11..
    now, I running babeld -D wlan0, don’t want to do route,
    what are you use arch linux version?

    Thank You Mr..

  10. ptj14 says:

    Also having the same issue as arif and Sora… send: Network is unreachable when running babeld wlan0 & .

    I’m using Arch, and have followed the guide to the letter – the only difference being I had to manually enable ipv6 to avoid errors when starting babeld

  11. arif says:

    thank you Mr..
    I am success to implement babel in raspberry..
    i am using wifi dongle prolink not working, but it must be using wifi dongle edimax.

  12. muhtaromw says:

    Hi eric
    I want to ask question
    when babel is running, can you ping your node with another node?because I cant ping my node
    Im using Arch linux too

  13. overburn says:

    Hi guys. I’m setting up a mesh network with access to the internet.
    The node that connects to the internet, does it through the wlan0 and is acting as a station. Through the wlan1 it has access to the mesh network. I configured this node with an ip addr and started the ahcpd. I configured the ahcpd in this node as the server and in the others I don’t have any kind of config. By default ahcpd starts as a client. The thing is when I start the ahcpd as a client I don’t get any ip… It’s very strange.

    As a routing protocol I’m running babel through its daemon.

    I’m running everything with static IP and I don’t have any configuration regarding gateway in the mesh nodes, but babeld somehow defines the gateway.

    In the other nodes of the mesh I have IPs and

    In DHCP there is a range of IPs, but in ahcp seems there’s no range.

    Any ideas?

    I can post my configurations upon request.

    I debugged for 2 months now this and I’m really aware of most configurations, simply can’t understand what’s going on.


  14. forumr says:

    I’m trying to run babel on my Raspberry pi model B. here are the steps which I made:
    # installation
    sudo apt-get install babeld

    1. running bable deamon on wlan0
    # sudo babeld wlan0

    An error message appeared –> Couldn’t read forwarding knob.: No such file or directory

    after running the ipv6 module with
    # modprobe ipv6

    and then running babled wlan0 again the Pi does nothing till I cancel the process with Ctrl+C

    any suggestions?

Leave A Reply