Eigenen Rechner in das Freifunk-Netz

Aus Freifunk Kiel
Version vom 7. Dezember 2012, 01:34 Uhr von Rubo77 (Diskussion | Beiträge) (→‎Start-Script erstellen: cellid und optionen fuer Hamburg ergaenzt)
Zur Navigation springen Zur Suche springen

So einfach kann man seinen Laptop in das Freifunk-Netz als Knoten mit integrieren (Unter Ubuntu 12.04 getestet):

Installation

sudo apt-get install batctl

Kernelmodul laden:

sudo modprobe batman-adv

Version prüfen:

sudo batctl -v

Nicht alle Batmanversionen sind kompatibel - siehe: http://www.open-mesh.org/projects/batman-adv/wiki/Compatversion

Start-Script erstellen

Um sich mit batman.kiel.freifunk.net auf der Schnittstelle wlan0 mit der bssid 02:ca:ff:ee:ba:be zu verbinden erstelle folgendes script und nenne es z.B. /usr/local/sbin/freifunk-connect:

download script

#!/bin/bash
IFACE=wlan0
ESSID=batman.kiel.freifunk.net
CHANNEL=11
CELLID=02:ca:ff:ee:ba:be
NODELINK=http://freifunk.in-kiel.de/ffmap/nodes.html

if [ "$1" = "hh" ]; then
  ESSID=f8:d1:11:87:52:2e
  CHANNEL=1
  CELLID=f8:d1:11:87:52:2e
  NODELINK=http://10.130.10.1/ffhh/nodes.html
fi

if [ "$1" = "--help" ]; then
  echo "[start](default) or [stop]"
  echo to connect to hamburg call this script with option hh
  echo edit the options in the top section of this script to connect to another network
  echo your network devices:
  lspci|grep -i net
  exit
fi

NETWORKMANAGER="service network-manager"
# some distributions have 
#NETWORKMANAGER="/etc/init.d/network-manager"

if [ "$(whoami &2>/dev/null)" != "root" ] && [ "$(id -un &2>/dev/null)" != "root" ] ; then
  echo "You must be root to run this script!"; exit 1
fi


if [ "$1" = "stop" ]; then
  echo "resuming normal networking..."
  echo "restart network-manager"
  $NETWORKMANAGER restart
  echo "turn wlan iface off"
  batctl if del $IFACE
  sleep 10
  echo "OK"
  echo "echo it can take a few minutes until network-manager gets a new route"
  echo
  exit
elif [ "$1" = "restart" ]; then
  echo "not implemented. call this script first with stop and then with start"
  exit
else # "start"
  echo "stopping network-manager"
  $NETWORKMANAGER stop
  echo "pls wait"
  sleep 10
  echo "turn wlan iface off"
  ifconfig $IFACE down
  echo" set maximal transfer unit from standard 1500 to 1528"
  ifconfig $IFACE mtu 1528
  echo "turn wlan encryption off"
  iwconfig $IFACE enc off
  echo "start ad-hoc mode"
  iwconfig $IFACE mode ad-hoc essid $ESSID ap $CELLID channel $CHANNEL
  #eigentlich sollte man lieber das hier benutzen, geht aber nicht: 
  # iw dev wlan0 ibss join $ESSID 2412 HT40+ fixed-freq $CELLID
  echo "load module into kernel"
  modprobe batman-adv
  echo "adding iface to batman"
  batctl if add $IFACE
  echo "turn wlan iface on"
  ifconfig $IFACE up
  echo "turn batman iface on"
  ifconfig bat0 up
  echo "ESSID $ESSID on $IFACE should be ready"
  
  #sollte man eigentlich machen, geht aber nicht:
  #batctl gw client
  
  echo "internet starting, this may take some minutes due to latency..."
  dhclient bat0
  echo "internet connection IP:"
  ifconfig|grep Bcast
  echo you should have an IP like 10.x.x.x
  echo after a minute your node should popup on the nodeGraph here $NODELINK
  echo
  echo "to resume normal networking call this script with option stop"
  echo
fi

Wenn das script ausgeführt wird, dann ist dein Rechner Teil des Freifunk-Netzwerkes und mescht mit. Er kann so also auch als Brücke zwischen zwei Routern fungieren, die zu weit auseinander liegen.

Siehe auch: Askubuntu

Todo

fastd installieren und eine Werbindung vom eigenen Rechner aus aufbauen: