Babel und dnsmasq in unsere firmware

Aus Freifunk Franken
Version vom 7. Mai 2016, 09:01 Uhr von ChristianD (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „Um aus einem Router ein Gateway zu machen, muss in die Firmware Olsr und dnsmasq mit eingebaut werden. Dieses Patch baut diese 2 Programme plain mit ein, es m…“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu:Navigation, Suche

Um aus einem Router ein Gateway zu machen, muss in die Firmware Olsr und dnsmasq mit eingebaut werden. Dieses Patch baut diese 2 Programme plain mit ein, es müssen danach noch diverse Konfigurationen und Routingparameter gesetzt werden. Es kann sich dazu ganz grob an die Anleitung zum Gateway aufsetzen gehalten werden.

Achtung! Man sollte sich bei solchen Experiementen immer gut überlegen wie man den Router noch erreichen kann, man kann sich relativ leicht selbst komplett aussperren. Nach diesem Patch baut der Router z.b. kein fastd Batman mehr zu einem Gateway auf, er mesht aber noch frei mit anderen Routern und spannt auch noch ein WLAN auf.

From d0ae5dc119e091b25d35d494d1514eb7aa48a521 Mon Sep 17 00:00:00 2001
From: Christian Dresel <fff@chrisi01.de>
Date: Sat, 7 May 2016 08:54:08 +0200
Subject: [PATCH] Add Olsr and dnsmasq

        modified:   bsp/ar71xx/.config
        modified:   buildscript
        deleted:    src/packages/fff/fff-fastd/files/usr/lib/micron.d/fff-fastd
        modified:   src/packages/fff/fff-fastd/files/usr/sbin/fastdstart
---
 bsp/ar71xx/.config                                 |  4 +-
 buildscript                                        |  8 +-
 .../fff/fff-fastd/files/usr/lib/micron.d/fff-fastd |  1 -
 .../fff/fff-fastd/files/usr/sbin/fastdstart        | 98 +---------------------
 4 files changed, 11 insertions(+), 100 deletions(-)
 delete mode 100644 src/packages/fff/fff-fastd/files/usr/lib/micron.d/fff-fastd

diff --git a/bsp/ar71xx/.config b/bsp/ar71xx/.config
index f7b0097..fdad7d6 100644
--- a/bsp/ar71xx/.config
+++ b/bsp/ar71xx/.config
@@ -17,7 +17,6 @@ CONFIG_CLEAN_IPKG=y
 # CONFIG_FASTD_ENABLE_METHOD_COMPOSED_GMAC is not set
 # CONFIG_FASTD_ENABLE_METHOD_GENERIC_GMAC is not set
 # CONFIG_PACKAGE_ALFRED_VIS is not set
-# CONFIG_PACKAGE_dnsmasq is not set
 # CONFIG_PACKAGE_firewall is not set
 CONFIG_PACKAGE_gpioctl-sysfs=y
 CONFIG_PACKAGE_kmod-ifb=y
@@ -29,6 +28,9 @@ CONFIG_PACKAGE_kmod-ledtrig-netdev=y
 CONFIG_PACKAGE_kmod-sched-connmark=y
 CONFIG_PACKAGE_libugpio=y
 # CONFIG_PACKAGE_odhcpd is not set
+CONFIG_PACKAGE_olsrd=y
+CONFIG_PACKAGE_olsrd-mod-dyn-gw-plain=y
+CONFIG_PACKAGE_olsrd-mod-txtinfo=y
 # CONFIG_PACKAGE_opkg is not set
 # CONFIG_PACKAGE_ppp is not set
 CONFIG_PACKAGE_qos-scripts=y
diff --git a/buildscript b/buildscript
index 7e16687..1563be6 100755
--- a/buildscript
+++ b/buildscript
@@ -26,6 +26,11 @@ OPENWRT=(openwrt
          $PACKAGEREV)
 OPENWRT_PKGS="gpioctl-sysfs libugpio fastd haserl"

+OLSRD=(olsrd
+      https://github.com/OLSR/olsrd
+      d48b0bc3d50b9b79545efca09fff39ee060794b9)
+OLSRD_PKGS="olsrd"
+
 ## Be careful: FFF uses COMPAT_VERSION 14 at the moment.
 ## See http://www.open-mesh.org/projects/batman-adv/wiki/Compatversion
 BATMAN_ADV=(batman_adv
@@ -42,7 +47,7 @@ ROUTING_PKGS="alfred"
 FFF=(fff)
 FFF_PKGS="-a"

-FEEDS=(OPENWRT ROUTING BATMAN_ADV FFF)
+FEEDS=(OPENWRT ROUTING BATMAN_ADV OLSRD FFF)

 checkout_git(){
     local DIRECTORY=$1
@@ -61,6 +66,7 @@ checkout_git(){
         else
             echo "wrong remote or not an git repo at all -> deleting whole directory"
             /bin/rm -rf "$DIRECTORY"
+
             #needs to be without -C!!!
             git clone "$REPO_URL" "$DIRECTORY"
             $MYGIT checkout "$COMMITID"
diff --git a/src/packages/fff/fff-fastd/files/usr/lib/micron.d/fff-fastd b/src/packages/fff/fff-fastd/files/usr/lib/micron.d/fff-fastd
deleted file mode 100644
index b0022e8..0000000
--- a/src/packages/fff/fff-fastd/files/usr/lib/micron.d/fff-fastd
+++ /dev/null
@@ -1 +0,0 @@
-*/5 * * * * sleep $(/usr/bin/random 0 29); sh /usr/sbin/fastdstart
diff --git a/src/packages/fff/fff-fastd/files/usr/sbin/fastdstart b/src/packages/fff/fff-fastd/files/usr/sbin/fastdstart
index 611a3f8..e9975e5 100755
--- a/src/packages/fff/fff-fastd/files/usr/sbin/fastdstart
+++ b/src/packages/fff/fff-fastd/files/usr/sbin/fastdstart
@@ -1,97 +1 @@
-#!/bin/sh
-
-SERVER="no"
-#SERVERNAME="--servername--"
-
-. /etc/community.cfg
-
-project="$VPN_PROJECT"
-
-test_ipv4_host1="keyserver.freifunk-franken.de" # Freifunk-Franken keyserver
-test_ipv4_host2="8.8.8.8"        # Google DNS
-test_ipv6_host1="heise.de"       # heise Zeitschriftenverlag
-
-if [ "$SERVER" = "no" ]; then
-       test -f /tmp/started || exit
-fi
-
-# Only do something with fastd when the router has internet connection
-if ping -w5 -c3 "$test_ipv4_host1" &>/dev/null ||
-   ping -w5 -c3 "$test_ipv4_host2" &>/dev/null ||
-   ping6 -w5 -c3 "$test_ipv6_host1" &>/dev/null; then
-       mac=$(awk '{ mac=toupper($1); gsub(":", "", mac); print mac }' /sys/class/net/br-mesh/address 2>/dev/null)
-       if [ "$SERVER" = "no" ]; then
-               hostname=$(cat /proc/sys/kernel/hostname)
-
-               if [ "$hostname" = "OpenWrt" ]; then
-                       hostname=""
-               fi
-
-               if [ "$hostname" = "" ]; then
-                       hostname=$mac
-               fi
-       else
-               hostname=$SERVERNAME
-       fi
-
-       if [ ! -d /etc/fastd ]; then
-               mkdir /etc/fastd
-       fi
-
-       if [ ! -d /etc/fastd/$project ]; then
-               mkdir /etc/fastd/$project
-
-               mkdir /tmp/fastd_${project}_peers
-               ln -s /tmp/fastd_${project}_peers /etc/fastd/$project/peers
-               echo "#!/bin/sh" > /etc/fastd/$project/up.sh
-               echo "ip link set up dev ${project}VPN" >> /etc/fastd/$project/up.sh
-               echo "echo enable > /sys/devices/virtual/net/${project}VPN/batman_adv/no_rebroadcast" >> /etc/fastd/$project/up.sh
-               echo "batctl if add ${project}VPN" >> /etc/fastd/$project/up.sh
-               chmod +x /etc/fastd/$project/up.sh
-
-               secret=$(fastd --generate-key 2>&1 | grep -i secret | awk '{ print $2 }')
-               echo "include peers from \"/etc/fastd/$project/peers\";" >> /etc/fastd/${project}/${project}.conf
-               echo "log to syslog level warn;" >> /etc/fastd/${project}/${project}.conf
-               echo "method \"null\";" >> /etc/fastd/${project}/${project}.conf
-#              http://lists.nord-west.net/pipermail/freifunk-ol-dev/2013-July/000322.html
-#              echo "bind 0.0.0.0:10000;" >> /etc/fastd/${project}/${project}.conf
-               echo "interface \"${project}VPN\";" >> /etc/fastd/${project}/${project}.conf
-               echo "mtu 1426;" >> /etc/fastd/${project}/${project}.conf
-               echo "secret \"$secret\";" >> /etc/fastd/${project}/${project}.conf
-               echo "on up \"/etc/fastd/${project}/up.sh\";" >> /etc/fastd/${project}/${project}.conf
-               echo "secure handshakes no;" >> /etc/fastd/${project}/${project}.conf
-       fi
-
-       if [ ! -d /tmp/fastd_${project}_peers ]; then
-               mkdir /tmp/fastd_${project}_peers
-       fi
-
-       pubkey=$(fastd -c /etc/fastd/$project/$project.conf --show-key --machine-readable)
-#      port=666
-       lat=$(uci get system.@system[0].latitude)
-       long=$(uci get system.@system[0].longitude)
-
-#      fire up
-       if [ "$(/sbin/ifconfig -a | grep -i ethernet | grep $project)" = "" ]; then
-               /bin/rm /var/run/fastd.$project.pid
-               fastd -c /etc/fastd/$project/$project.conf -d --pid-file /var/run/fastd.$project.pid
-       fi
-
-#      register
-       wget -T15 "http://keyserver.freifunk-franken.de/${project}/geo.php?mac=$mac&name=$hostname&port=$port&key=$pubkey&lat=$lat&long=$long" -O /tmp/fastd_${project}_output
-
-       filenames=$(awk '/^####/ { gsub(/^####/, "", $0); gsub(/.conf/, "", $0); print $0; }' /tmp/fastd_${project}_output)
-       for file in $filenames; do
-               awk "{ if(a) print }; /^####$file.conf$/{a=1}; /^$/{a=0};" /tmp/fastd_${project}_output | sed 's/ float;/;/g' > /etc/fastd/$project/peers/$file
-               echo 'float yes;' >> /etc/fastd/$project/peers/$file
-       done
-
-       #reload
-       kill -HUP $(cat /var/run/fastd.$project.pid)
-else
-       echo "Der Router kann keine Verbindung zum Fastdserver aufbauen"
-       echo "$0 macht nichts!"
-fi
-
-exit 0
-# vim: noexpandtab
+echo "nothing to do...."
--
2.1.4

Folgendes muss grundsätzlich danach noch getan werden damit er als Gateway verwendet werden kann:

  • Irgendeine Art von Verbindung in unser L3 Netz. Ich habe dazu fastd im tun Modus verwendet