This guide will take you from a fresh OpenWRT installation up to a fully functional B.A.T.M.A.N. node.

Installing OpenWRT

To install OpenWRT, you must flash your router with a recent version. The flashing instructions are out of the scope of this guide, but we assume that you're installing trunk, which, at time of writing provides version 2012.1.0 (at svn r33362 provides batman version 2012.3.0). The stable version of OpenWRT, "backfire", provides an older version and is not recommended.

Set a Password

telnet 192.168.1.1
passwd
exit

Know your network interfaces and what you want to do with them

Connect a cable from the LAN to your PC. Set your PC to get an IP address automatically. Get into the router with its default IP address.

ssh root@192.168.1.1

Depending on the device, you may have one or many ethernet ports, configured either for WAN (internet port) or LAN (local network port(s)) or VLAN (one virtual port: for example on a linksys router, the 4 lan ports are configured as a VLAN), and a wireless interface.

To get to know your interfaces and how they are called type

ifconfig

The output on a linksys wrtsl54gs (4 lan ports, one wan port and one wireless interface) looks like this

br-lan Link encap:Ethernet  HWaddr 00:0C:41:14:E0:8F  
       inet addr:172.16.11.1  Bcast:172.16.255.255  Mask:255.255.0.0
       UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
       RX packets:1441 errors:0 dropped:10 overruns:0 frame:0
       TX packets:2375 errors:0 dropped:0 overruns:0 carrier:0
       collisions:0 txqueuelen:0 
       RX bytes:188140 (183.7 KiB)  TX bytes:162059 (158.2 KiB)


eth0   Link encap:Ethernet  HWaddr 00:0C:41:14:E0:8F  
       UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
       RX packets:176730 errors:0 dropped:39 overruns:0 frame:0
       TX packets:177867 errors:0 dropped:0 overruns:0 carrier:0
       collisions:0 txqueuelen:1000 
       RX bytes:12202170 (11.6 MiB)  TX bytes:11512610 (10.9 MiB)
       Interrupt:4 

eth1   Link encap:Ethernet  HWaddr 00:0C:41:14:E0:90  
       inet addr:192.168.1.111  Bcast:192.168.69.255  Mask:255.255.255.0
       UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
       RX packets:26818 errors:0 dropped:0 overruns:0 frame:0
       TX packets:26335 errors:0 dropped:0 overruns:0 carrier:0
       collisions:0 txqueuelen:1000 
       RX bytes:6060674 (5.7 MiB)  TX bytes:4681282 (4.4 MiB)
       Interrupt:5 

lo     Link encap:Local Loopback  
       inet addr:127.0.0.1  Mask:255.0.0.0
       UP LOOPBACK RUNNING  MTU:16436  Metric:1
       RX packets:842 errors:0 dropped:0 overruns:0 frame:0
       TX packets:842 errors:0 dropped:0 overruns:0 carrier:0
       collisions:0 txqueuelen:0 
       RX bytes:99165 (96.8 KiB)  TX bytes:99165 (96.8 KiB) 

wlan0  Link encap:Ethernet  HWaddr 00:10:18:90:20:DB  
       UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
       RX packets:17858 errors:0 dropped:876 overruns:0 frame:0
       TX packets:16124 errors:0 dropped:0 overruns:0 carrier:0
       collisions:0 txqueuelen:32 
       RX bytes:2029972 (1.9 MiB)  TX bytes:3249399 (3.0 MiB)

eth1 is the WAN interface, eth0 are the 4 lan ports, wlan0 is the wireless interface and br-lan is the lan bridge. By default, OpenWRT will create a network bridge called 'lan', and it includes one of the wired ethernet ports. To see what interfaces compose the lan bridge, type the following

root@Openwrt:/# brctl show
bridge name     bridge id           STP enabled     interfaces
br-lan          8000.000c4114e08f   no              eth0
                                                    wlan0

From this information and depending on what you intend to do, you have to determine:

  • which interface(s) will be on the mesh (later referred to as mesh interfaces)
  • which interface(s) will be on the LAN (to serve local users) (later referred to as LAN interfaces)

For example, a simple relay on a roof will have the wlan0 interface on the mesh and its eth0 interface as LAN. A relay on the roof connected to an access point may want to have both wlan0 and eth0 on the mesh and if available an eth1 on the LAN. The access point will have its eth0 interface on the mesh and its wlan0 will be a LAN interface to server wireless clients.

(!) For an access point with access to the internet "WAN" and "LAN" are tricky concepts because both lead outside the local network, one to the mesh, the other to the internet. Interfaces should be thought more in terms of what they do and where they lead to. For instance, the firewall may need to be modified if the WAN port is connected to your home network, so that you can access the router by ssh or web interface through that interface (incoming connections are rejected by default on that port for security reason, but you do not want that if the only connections to that port will come from your home network). Need a link to a guide on security

Need link to more specific configuration pages for different scenarios

Basic Network Configuration

Turn the radio on:

uci delete wireless.radio0.disabled

Set the name of the router to the same you entered in the node database.

uci set system.@system[0].hostname=ti-noeud

Now set the interface(s) that should be part of the LAN bridge like this uci set network.lan.ifname="" (space-separated)

Configure the router's IP address for your internal network. Here we assume you have an other router with the address 192.168.1.1 so we assign a different address.

# For static ip
uci set network.lan.ipaddr=192.168.1.10
uci set network.lan.gateway=192.168.1.1
uci set network.lan.dns=192.168.1.1

# Or to get dhcp from your home router and reach your router using name ti-noeud
uci set network.lan.proto=dhcp
uci set network.lan.hostname=ti-noeud

Disable DHCP server on LAN, so as to not interfere with home router.

uci set dhcp.lan.ignore=1

Write the changes and reboot to apply them:

uci commit
reboot & exit

Disconnect the PC from the router and now connect both the PC and the mesh router to the home router. Re-connect to the router using its new IP address.

ssh root@192.168.1.10
or
ssh root@ti-noeud

Wireless Configuration

(!) This section applies only to nodes where the wifi interface will be on the mesh. Otherwise, configure the wifi interface as usual.

We have enabled wireless previously (see if you haven't). Now, verify that the wifi interface is listed. If not, you may have flashed the wrong image!

iwconfig

The wifi network should no longer belong in the 'lan' network bridge because that's not allowed in ad-hoc mode. We'll configure it later, so just remove it for now:

uci delete wireless.@wifi-iface[0].network

Configure the wireless radio with Montreal ad-hoc standards:

uci set wireless.radio0.channel=1
uci set wireless.@wifi-iface[0].mode=adhoc
uci set wireless.@wifi-iface[0].ssid=reseaulibre.ca
uci set wireless.@wifi-iface[0].bssid=02:CA:FF:EE:BA:BE

Configure the wireless interface with a higher MTU to allow batman to decorate packets without causing fragmentation:

uci set network.wlan0=interface
uci set network.wlan0.ifname=wlan0
uci set network.wlan0.proto=none
uci set network.wlan0.mtu=1528

Batman Installation

Install B.A.T.M.A.N (the home router provides access to internet)

opkg update
opkg install kmod-batman-adv

(!) If your router has no internet access, or the operation freezes your router, or gives memory errors, you will have to install the kmod-lib-crc16 and kmod-batman-adv modules by hand. See the manual-package-install help.

Le module batman_adv devrait maintenant être chargé:

lsmod | grep batman

You should see: batctl 2012.1.0

batctl -v

Batman Configuration

Configuration de l'interface de batman. We're not assigning an IP address to bat0 because we'll add it to the lan bridge.

uci set network.bat0=interface
uci set network.bat0.ifname=bat0
uci set network.bat0.proto=static
uci set network.bat0.mtu=1500

Configure your node by picking a free slot from the IP Allocation page. Here we assume you're installing a small node, so we use the 172.16.1.X/12 network:

uci set network.bat0.ipaddr=172.16.1.1
uci set network.bat0.netmask=255.240.0.0

Tell batman to use the mesh interfaces: (normally: "wlan0 br-lan")

uci set batman-adv.bat0.interfaces="<space separated mesh interfaces>"

Optionally use our our ?bat-hosts file.

You're done! Commit the changes and reboot to test them.

uci commit
reboot & exit

(!) Note for batman on wired interfaces with vlan (for example a 4 LAN port device)

Some bug in batman-adv makes it not support vlans, so if you simply try to add the eth0 interface to batman, it won't work. The interface needs to be a bridge. For example, you should have an interface that wraps eth0 configured as a bridge and add this interface to batman

uci set network.mesh0=interface
uci set network.mesh0.ifname=eth0
uci set network.mesh0.type=bridge
uci set network.mesh0.proto=none

uci set batman-adv.bat0.interfaces="mesh0 ..."

Testing

After a reboot, check that the configuration worked

root@ti-noeud:/# brctl show
# Should list the LAN interfaces
bridge name     bridge id               STP enabled     interfaces
br-lan          8000.00259c5e4457       no              eth0

root@ti-noeud:/# batctl if
# Should be a line like that for each mesh interface
wlan0: active

Other Readings

For Batman operations and troubleshooting, see the general Batman Configuration page.

This guide being incomplete, you will most likely want to tweak the IP addresses of your router. For this, please read the IP Configuration page. When things are settled and tested, this guide should be updated.