How to use batman-adv to create a Mesh network
This repository contains the setup and configuration guide for a Mesh Network over WiFi on Raspberry Pis. Follow the steps below to get started.
Make sure you have the following prerequisites:
-
Raspberry Pi 3B+ (Minimum 2)
-
Ubuntu 22.04
-
Batman-adv
sudo apt-get update && sudo apt-get upgrade -ycurl -O https://downloads.open-mesh.org/batman/releases/batman-adv-2023.3/batman-adv-2023.3.tar.gz
tar -xvzf batman-adv-2023.3.tar.gzsudo apt install make
sudo apt-get install gcccd batman-adv-2023.3/
sudo make allsudo make installsudo apt install batctl
sudo apt install iw
sudo apt install net-tools
sudo apt install wireless-toolssudo service wpa_supplicant stopsudo systemctl mask wpa_supplicant.serviceOutput: Created symlink /etc/systemd/system/wpa_supplicant.service → /dev/null.
sudo ip link set <if> down #e.g. <if> = wlan0
sudo iw <if> set type ibss #ibss means ad-hoc mode
sudo ifconfig <if> mtu 1468
sudo iwconfig <if> channel 3
sudo ip link set <if> up
sudo iw <if> ibss join <ssid> 2432 # e.g. <ssid> = my-mesh-networksudo modprobe batman-adv
lsmod | grep "batman_adv"sudo batctl if add <if># e.g. <if> = wlan0
sudo ip link set up dev <if>
sudo ip link set up dev bat0
sudo ifconfig bat0 172.27.0.1/16 # Can be any other valid IP.sudo iwconfigsudo batctl o #Shows originators
sudo batctl n #Shows neighbor mesh nodesip link add name br0 type bridge
ip link set dev br0 up
ip link set dev bat0 master br0
ip link set dev eth0 master br0In this example, the blue wifi-client on node2 should be able to talk to the red ethernet client on node3. Even when they both don't have any knowledge about batman-adv or the medium (ethernet vs. wifi) of the remote client.
After configuring the mesh network step by step, it would be easier to have a script that execute all steps in one command. Therefore, a script is provided to create the mesh network using a single command. First make the script executable using this command:
chmod +x /path/to/mesh-network-startup.shLater, launch the script:
sudo bash /path/to/mesh-network-startup.sh