Eigenen Rechner in das Freifunk-Netz: Unterschied zwischen den Versionen

Aus Freifunk Kiel
Zur Navigation springen Zur Suche springen
(Anleitung ergäänzt, weie man die neueste benötigte batman-adv installiert)
(added hamburg connection option)
Zeile 56: Zeile 56:
 
'''<pre style="color:#222233">
 
'''<pre style="color:#222233">
 
#!/bin/bash
 
#!/bin/bash
 +
 +
# this script connects as a node in a B.A.T.M.A.N. network.
 +
# call this script with --help for help
 +
 
IFACE=wlan0
 
IFACE=wlan0
 
ESSID=02:ca:ff:ee:ba:be
 
ESSID=02:ca:ff:ee:ba:be
 
CHANNEL=11
 
CHANNEL=11
FREQUENCY=2462
 
 
CELLID=02:ca:ff:ee:ba:be
 
CELLID=02:ca:ff:ee:ba:be
 
NODELINK=http://freifunk.in-kiel.de/ffmap/nodes.html
 
NODELINK=http://freifunk.in-kiel.de/ffmap/nodes.html
 +
# initiating nameserver in your freifunk:
 +
NAMESERVER=fda1:384a:74de:4242::1
 +
  
 
if [ "$1" = "hh" ]; then
 
if [ "$1" = "hh" ]; then
 
   ESSID=f8:d1:11:87:52:2e
 
   ESSID=f8:d1:11:87:52:2e
 
   CHANNEL=1
 
   CHANNEL=1
  FREQUENCY=2412
 
 
   CELLID=f8:d1:11:87:52:2e
 
   CELLID=f8:d1:11:87:52:2e
 
   NODELINK=http://10.130.10.1/ffhh/nodes.html
 
   NODELINK=http://10.130.10.1/ffhh/nodes.html
 
fi
 
fi
  
 +
channel_map=(XYZZY 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484)
 +
FREQUENCY=${channel_map[$CHANNEL]}
  
 
if [ "$1" = "--help" ]; then
 
if [ "$1" = "--help" ]; then
   echo "[start](default) or [stop]"
+
   echo "[start](default) [stop] or [hh] for connection with the hamburg network"
 
   echo to connect to hamburg call this script with option hh
 
   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 edit the options in the top section of this script to connect to another network
Zeile 82: Zeile 89:
  
 
NETWORKMANAGER="service network-manager"
 
NETWORKMANAGER="service network-manager"
 +
#NETWORKMANAGER="service wicd"
 
# some distributions have  
 
# some distributions have  
 
#NETWORKMANAGER="/etc/init.d/network-manager"
 
#NETWORKMANAGER="/etc/init.d/network-manager"
Zeile 92: Zeile 100:
 
if [ "$1" = "stop" ]; then
 
if [ "$1" = "stop" ]; then
 
   echo "resuming normal networking..."
 
   echo "resuming normal networking..."
   echo "restart network-manager"
+
   echo "restart $NETWORKMANAGER"
 
   $NETWORKMANAGER restart
 
   $NETWORKMANAGER restart
 
    
 
    
 
   echo "turn network bridge off"
 
   echo "turn network bridge off"
 +
  ifconfig br-freifunk down
 
   brctl delif br-freifunk bat0
 
   brctl delif br-freifunk bat0
 
   brctl delif br-freifunk eth0
 
   brctl delif br-freifunk eth0
 
   brctl delbr br-freifunk
 
   brctl delbr br-freifunk
 
  ifconfig br-freifunk down
 
 
   ifconfig bat0 down -promisc
 
   ifconfig bat0 down -promisc
 
   ifconfig eth0 down -promisc
 
   ifconfig eth0 down -promisc
Zeile 106: Zeile 113:
 
   echo "turn wlan iface off"
 
   echo "turn wlan iface off"
 
   batctl if del $IFACE
 
   batctl if del $IFACE
  sleep 10
+
   echo "it can take a few minutes until $NETWORKMANAGER gets a new route"
   echo "OK"
 
  echo "echo it can take a few minutes until network-manager gets a new route"
 
 
   echo
 
   echo
 
   exit
 
   exit
Zeile 115: Zeile 120:
 
   exit
 
   exit
 
else # "start"
 
else # "start"
   echo "stopping network-manager"
+
   echo "stopping $NETWORKMANAGER"
  $NETWORKMANAGER stop
+
   echo "pls wait about 10 seconds"
   echo "pls wait"
+
   while true;do echo -n .;sleep 1;done &
   sleep 10
+
$NETWORKMANAGER stop
 +
    sleep 10 # or do something else here
 +
  kill $!; trap 'kill $!' SIGTERM
 +
  echo
 
   echo "turn wlan iface off"
 
   echo "turn wlan iface off"
 
   ifconfig $IFACE down
 
   ifconfig $IFACE down
Zeile 147: Zeile 155:
 
   #batctl gw client
 
   #batctl gw client
 
    
 
    
   echo "starting bridge to share internet connection over eth0"
+
   echo "optional starting bridge to share internet connection over eth0 (if eth0 exists)"
 
   ifconfig eth0 up promisc
 
   ifconfig eth0 up promisc
 
   
 
   
Zeile 155: Zeile 163:
 
    
 
    
 
   echo "internet starting, this may take some minutes due to latency..."
 
   echo "internet starting, this may take some minutes due to latency..."
   echo "(use"
+
   echo "The message 'Rather than invoking init scripts through /etc/init.d...' can be ignored in the following"
   echo "tail -f /var/log/syslog"
+
  echo "-------------------------------------"
   echo "in another window for debugging)"
+
   echo "tail -f -n 1 /var/log/syslog|grep freifunk"
  echo
+
   tail -f -n 1 /var/log/syslog|grep freifunk &
 
   echo dhclient br-freifunk
 
   echo dhclient br-freifunk
  echo "The error 'Rather than invoking init scripts through /etc/init.d...' can be ignored:"
 
 
   dhclient br-freifunk
 
   dhclient br-freifunk
 
   # without bridge: dhclient bat0
 
   # without bridge: dhclient bat0
 +
  ifconfig|grep '10\.'
 +
  killall tail
 +
  echo "------------------------------------- end of syslog"
 +
if [ "$1" != "hh" ]; then
 
    
 
    
   echo  
+
   echo "Optional: You can add a nameserver $NAMESERVER to /etc/resolv.conf with"
 +
  echo "nameserver $NAMESERVER">>/etc/resolv.conf
 +
fi
 +
 
 
   echo "internet connection IP:"
 
   echo "internet connection IP:"
 
   ifconfig|grep Bcast
 
   ifconfig|grep Bcast

Version vom 31. August 2014, 18:07 Uhr

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

Ausserdem konfiguriert dieses Script den eth0-Ausgang so um, dass man über den Netzwerk-Ausgang an deinem Rechner Internet an weitere Geräte freigeben kann.

Installation

Es werden die Pakete batctl für batman-adv und bridge-utils für brctl

sudo apt-get install batctl bridge-utils

neuere Batman version aus Repo

erstelle die datei `/etc/apt/sources.list.d/batman-adv-universe-factory.net.list` mit dem repository https://projects.universe-factory.net/projects/fastd/wiki für die neueste version:

sudo bash -c 'echo "deb http://repo.universe-factory.net/debian/ sid main">/etc/apt/sources.list.d/batman-adv-universe-factory.net.list'
gpg --recv-keys 0x16EF3F64CB201D9C
gpg --export 0x16EF3F64CB201D9C|sudo apt-key add -
sudo apt-get update
sudo apt-get install batman-adv-dkms

Wenn du den Fehler erhäst

Error! Module version 2013.4.0 for batman-adv.ko
is not newer than what is already found in kernel 3.14.1-031401-generic (2014.1.0).
You may override by specifying --force.


Dann muss dkms mit force aufgerufen werden (bis dies gefixt ist), wenn dies nicht geht, dann muss das Paket von Hand kopiert werden:

sudo cp /var/lib/dkms/batman-adv/kernel-3.14.1-031401-generic-i686/module/batman-adv.ko /lib/modules/3.14.1-031401-generic/kernel/net/batman-adv/batman-adv.ko 


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 Du brauchst mindestens die Version:

batctl debian-2013.4.0-2 [batman-adv: 2013.4.0]


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
`/usr/local/sbin/freifunk-connect`:

download script

Dieses Script ist noch experimentell: Ein Fehler ist, dass es nur einmal funktioniert. Man kann sich dann zwar wieder trennen mit
`freifunk-connect stop`
aber meist funktioniert ein erneutes Verbinden erst nach einem Rechner neustart

#!/bin/bash

# this script connects as a node in a B.A.T.M.A.N. network.
# call this script with --help for help

IFACE=wlan0
ESSID=02:ca:ff:ee:ba:be
CHANNEL=11
CELLID=02:ca:ff:ee:ba:be
NODELINK=http://freifunk.in-kiel.de/ffmap/nodes.html
# initiating nameserver in your freifunk:
NAMESERVER=fda1:384a:74de:4242::1


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

channel_map=(XYZZY 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484)
FREQUENCY=${channel_map[$CHANNEL]}

if [ "$1" = "--help" ]; then
  echo "[start](default) [stop] or [hh] for connection with the hamburg network"
  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"
#NETWORKMANAGER="service wicd"
# 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 $NETWORKMANAGER"
  $NETWORKMANAGER restart
  
  echo "turn network bridge off"
  ifconfig br-freifunk down
  brctl delif br-freifunk bat0
  brctl delif br-freifunk eth0
  brctl delbr br-freifunk
  ifconfig bat0 down -promisc
  ifconfig eth0 down -promisc
 
  echo "turn wlan iface off"
  batctl if del $IFACE
  echo "it can take a few minutes until $NETWORKMANAGER 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 $NETWORKMANAGER"
  echo "pls wait about 10 seconds"
  while true;do echo -n .;sleep 1;done &
	$NETWORKMANAGER stop
    sleep 10 # or do something else here
  kill $!; trap 'kill $!' SIGTERM
  echo
  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"
  # mit HT40 bei 802.11n kann man potentiell auch mit 40MHz breiten kanälen senden, 
  # falls da noch platz ist über oder unter jenem kanal und dann am besten noch HT40- statt HT40+ 
  # das minus oder plus sagt, ob die zusätzlichen 20MHz kanalbreite über oder unter dem gewählten 
  # kanal benutzt werden sollen
  #iw dev wlan0 ibss join $ESSID $FREQUENCY fixed-freq HT40- $CELLID

  # in case the iw doesent work, use:
  iwconfig $IFACE mode ad-hoc essid $ESSID ap $CELLID channel $CHANNEL
  
  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 "optional starting bridge to share internet connection over eth0 (if eth0 exists)"
  ifconfig eth0 up promisc
 
  brctl addbr br-freifunk
  brctl addif br-freifunk bat0
  brctl addif br-freifunk eth0
  
  echo "internet starting, this may take some minutes due to latency..."
  echo "The message 'Rather than invoking init scripts through /etc/init.d...' can be ignored in the following"
  echo "-------------------------------------"
  echo "tail -f -n 1 /var/log/syslog|grep freifunk"
  tail -f -n 1 /var/log/syslog|grep freifunk &
  echo dhclient br-freifunk
  dhclient br-freifunk
  # without bridge: dhclient bat0
  ifconfig|grep '10\.'
  killall tail
  echo "------------------------------------- end of syslog"
if [ "$1" != "hh" ]; then
  
  echo "Optional: You can add a nameserver $NAMESERVER to /etc/resolv.conf with"
  echo "nameserver $NAMESERVER">>/etc/resolv.conf
fi

  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 you can connect another device on eth0 if you like. there will be internet available via cable
  echo "if you use network-manager (ubuntu) you will have to set ipv6 method to \"ignore\""
  echo see http://freifunk.in-kiel.de/wiki/Ubuntu
  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. Außerdem kann man über den Netzwerkanschluss eth0 weitere clients anschließen, die dann über deinen Rechner Internet bekommen (beachte den Hinweis auf IPv6 beim NetworkManager unter Ubuntu)

Alternative im Hamburger Wiki hier

Siehe auch: Askubuntu

Todo

fastd installieren und eine Verbindung vom eigenen Rechner aus aufbauen: