Mesh Networking

Kevin Steen's bit o'Web

Home | Articles | Contact

How to create your own mesh network

Want to connect to your neighbours without any wires or going via the Internet? Free Software has advanced to the point where it is now relatively easy. It's not yet point and click (2014) but it's not difficult.

Using the Debian operating system and the B.A.T.M.A.N. mesh-networking software you can get started on your own community network.

What you'll need

Overview

Here's the main steps you'll need to follow:

  1. Install the required software packages
  2. Configure the wireless cards to talk to each other in peer-to-peer (adhoc) mode
  3. Configure the mesh networking software
  4. Reboot and check it's working
  5. Look for cool things you can do with your own network.

Detailed instructions

Install the required software packages

You need to add some software which isn't usually installed. You'll need to have Administrator permissions to do this.

  1. Open a terminal window
  2. Give yourself root access by typing

    su - and press Enter

  3. Install the required packages:

    apt-get install batctl iw bridge-utils pidgin pidgin-otr

  4. Repeat for the 2nd computer
  5. Now you can disconnect from the Internet

Configure the wireless cards to talk to each other in peer-to-peer (ah-hoc) mode

  1. You need to find out the name of the wireless network interface so that you can configure it to come up automatically when the computer starts. Using the same root terminal, type

    iw dev

    You should see something like this

    phy#0
    Interface wlan0
    ifindex 1
    type managed

    The wlan0 is the name you need. Make a note of it.

  2. Next, edit the network configuration file : /etc/network/interfaces

    Make a backup, just in case

    cd /etc/network
    cp interfaces interfaces.good

  3. Use your favourite editor (or nano) to modify the interfaces files

    nano interfaces

    There shouldn't be one on a standard system (which uses NetworkManager) but look for a section starting iface wlan0 inet (if your wireless interface is named wlan0 like mine.) If it is there, modify it, otherwise add these lines to the bottom of the file (replacing wlan0 with your interface name):

    auto wlan0
    allow-hotplug wlan0
    iface wlan0 inet manual
    pre-up ifconfig $IFACE mtu 1532
    up ifconfig $IFACE up
    post-up iw dev $IFACE ibss join mesh 2412 fixed-freq 02:CA:FF:EE:BA:BE
    post-up modprobe batman-adv || true
    post-up batctl if add $IFACE || true
    down ifconfig $IFACE down

    allow-hotplug bat0
    iface bat0 inet manual
    up ifconfig $IFACE up

    Type the $IFACE parts exactly like that - you'll thank me later.

    Save the file, exit your editor and close the terminal window.

Configure the mesh networking software

Now we discover the joy of using B.A.T.M.A.N. - there's no configuration required! The entire mesh appears like a hardware switch to your computer, plugged into the bat0 interface.

Reboot and check it's working

Reboot so that NetworkManager releases control of the wireless interface.

When your system has restarted, you should see the wireless light flickering continuously as it sends out "I'm here" packets once a second to detect other peers in the network.

Now, open a terminal window again, and gain root access with su -, then type in:

batctl o -w

Assuming everything has gone well, you should see something like this:

[B.A.T.M.A.N. adv 2011.4.0, MainIF/MAC wlan0/00:90:4b:aa:bb:cc (bat0)]
Originator last-seen (#/255) Nexthop [outgoingIF]: Potential nexthops ...
No batman nodes in range ...

Once you have repeated all the above steps on the 2nd computer, you should see the "No batman nodes" message replaced with the MAC address of the 2nd computer.

That's it, you've got a functioning mesh network!

Look for cool things you can do with your own network.

Since Debian supports IPv6, the mesh interface bat0 will have automatically been given a link-local IPv6 address. The local-LAN directory software, Avahi, will already be broadcasting your presence to the mesh.

To chat, send files, etc over the mesh, you can use the Pidgin messaging software. (Empathy doesn't work properly on IPv6-only networks at the time of writing, but it may be fixed by the time you read this.)

Start Pidgin from the normal menus, and create a Bonjour account although you may want to change the LastName field to a space or something else - remember that these details will be broadcast across the whole mesh, so think about what information you want your neighbours to know about you! Bonjour is one of the names for the protocol used for LAN-only chat - in Empathy it's called People Nearby and on Mac computers it's iChat.

Security Warning

This simple configuration provides an unencrypted network - everything you send over the mesh is visible to anyone with a wireless card within range of any of the mesh nodes. To secure your information, use applications and protocols which provide a security layer and end-to-end encryption. For example https for website transfers, IMAPS and POP3S for accessing email and OTR for instant messaging. (The OTR plugin for pidgin is already installed, but needs to be activated from the plugins menu.)

Troubleshooting

Sometimes, things just don't work right the first time, so here's some areas to look at to find the problem.

If you spot any errors on this page, or have anything to add, please send me a message via my contact form

Last update: 28 Jul 2014