Gateway mit Openwrt: Unterschied zwischen den Versionen

Aus Freifunk Franken
Wechseln zu:Navigation, Suche
 
(36 dazwischenliegende Versionen von 3 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
= Gateway mit OpenWrt einrichten =
Eine Anleitung, ein dezentrales/lokales Gateway mit OpenWrt einzurichten.


Eine Anleitung, ein dezentrales/lokales Gateway mit OpenWrt einzurichten.
Hier am Beispiel eines TP-Link Archer C2600.


Hier am Beispiel eines TP-Link c2600.
Der Router wird dezentrales Gateway.


Der Router wird dezentrales Gateway  
Wir können viel aus der Anleitung [[Freifunk-Gateway aufsetzen]] ableiten. Dort findet man auch genauere Erklärungen zu den einzelnen Themen.
Bevor man hier los legt, sollte klar sein, was ein Gateway im Freifunknetz tut. Wir bauen die Funktionalität unter OpenWrt nach.


Wir können viel aus der Anleitung [[Freifunk-Gateway aufsetzen]] ableiten.
Sehr hilfreich ist es auch, wenn man sich mit dem uci-System und den Dateien in /etc/config von OpenWrt auskennt. -> OpenWrt Doku!


== Grundinstallation ==
== Grundinstallation ==


* Als erstes ein aktuelles OpenWrt flashen.
* Als erstes ein aktuelles OpenWrt flashen.
* Am Webinterface anmelden und ein Rootpasswort vergeben. Ev. ssh an allen Devices erlauben, macht es leichter drauf zu kommen, während wir konfigurieren. Man kann auch gleich seinen ssh-key hinterlegen.
* Am Webinterface anmelden und ein Rootpasswort vergeben. Eventuell ssh an allen Devices erlauben, macht es leichter drauf zu kommen, während wir konfigurieren. Man kann auch gleich seinen ssh-key hinterlegen.
* Hostname festlegen, Zeitzone  
* Hostname festlegen und Zeitzone setzen.


Jetzt sollte man sich via ssh am Router einloggen können.
Jetzt sollte man sich via ssh am Router einloggen können.
Zeile 27: Zeile 28:
=== Routingtabelle deklarieren ===
=== Routingtabelle deklarieren ===


Tabellennummer und Name in /etc/iproute2/rt_tables eintragen:
Tabellennummer und Name in /etc/iproute2/rt_tables eintragen.


  10    fff
  10    fff


== Vorbereitung zur Installation der Pakete ==
=== Vorbereitung zur Installation der Pakete ===


Es können nur Pakete via Internet installiert werden, wenn zuvor die Paketquellen, die in /etc/opkg definiert sind, aktualisiert werden.
Es können nur Pakete via Internet installiert werden, wenn zuvor die Paketquellen, die in /etc/opkg definiert sind, aktualisiert werden.
Zeile 37: Zeile 38:
  opkg update
  opkg update


== Konfiguration ==
= Konfiguration =


* Ip Adressen Reservieren. Siehe Gatewayanleutung [[Freifunk-Gateway_aufsetzen#Konfigurieren_des_Freifunk-Gateways]]
* IP-Adressen reservieren. Siehe Gatewayanleitung: [[Freifunk-Gateway_aufsetzen#Konfigurieren_des_Freifunk-Gateways]]
* Netzwerktools installieren
* Netzwerktools installieren.


  opkg install ip-bridge ip-full iptables ip6tables
  opkg install ip-bridge ip-full iptables ip6tables
Zeile 48: Zeile 49:
=== Netzwerkinterfaces ===
=== Netzwerkinterfaces ===


Die Konfiguration der Interfaces, das Routing und des Switches erfolgt in /etc/config/network und die wifi-interfaces in /etc/config/wireless
Die Konfiguration der Interfaces, das Routing und des Switches erfolgt in /etc/config/network und die Wifi-Interfaces in /etc/config/wireless


Hier ein Beispiel mit Freifunk c2600.  
Hier ein Beispiel mit dem TP-Link Archer C2600.  


* Die /etc/config/wireless
* Die /etc/config/wireless
Zeile 66: Zeile 67:


config wifi-iface 'w5ap'
config wifi-iface 'w5ap'
option device 'radio1'
option device 'radio0'
option ifname 'w5ap'
option ifname 'w5ap'
option mode 'ap'
option mode 'ap'
Zeile 84: Zeile 85:
option channel '13'
option channel '13'
option txpower '16'
option txpower '16'


config wifi-iface 'w2ap'
config wifi-iface 'w2ap'
Zeile 94: Zeile 94:
option hidden '0'
option hidden '0'
option network 'mesh'
option network 'mesh'
</pre>
</pre>


* Die /etc/config/network . Hier die Grundkonfiguration
* Die /etc/config/Network; hier die Grundkonfiguration


<pre>
<pre>
Zeile 110: Zeile 108:
option ula_prefix 'fdff:0::/64'
option ula_prefix 'fdff:0::/64'


config interface 'lan'
config interface 'lan'  
#### mit dem Interface hängt man im Home-LAN. In die Bridge kann man dann
#### einfach ein wireless Interface hängen und das Heimnetz ausstrahlen.
option type 'bridge'
option type 'bridge'
option proto 'static'
option proto 'static'
option ipaddr 'local IP'
option ipaddr 'local IP' ### meistens 192.168.xxx.xxx
option netmask '255.255.255.0'
option netmask '255.255.255.0'
option ip6assign '64'
option ip6assign '64'
Zeile 119: Zeile 119:
option dns 'x.x.x.x 9.9.9.9'
option dns 'x.x.x.x 9.9.9.9'
option ifname 'eth1.1'
option ifname 'eth1.1'
# oder einfach DHCP
# config interface 'lan'
#        option proto 'dhcp'


config interface 'mesh'
config interface 'mesh'
Zeile 125: Zeile 129:
option proto 'static'
option proto 'static'
option ipaddr 'your fff IP'
option ipaddr 'your fff IP'
option netmask '255.255.255.192'
option netmask '255.255.255.xxx'
option broadcast '10.83.xx.255'
option broadcast '10.83.xx.255'
list ip6addr 'fd43:5602:29bd:yor fff IP/64'
list ip6addr 'fd43:5602:29bd:your fff IP/64'
list ip6addr 'fe80::1/64'
list ip6addr 'fe80::1/64'
option ip4table 'fff'
option ip6table 'fff'
option ifname 'eth0.2'
option ifname 'eth0.2'


Zeile 136: Zeile 142:
option reqaddress 'try'
option reqaddress 'try'
option reqprefix 'auto'
option reqprefix 'auto'
</pre>
</pre>
* Die Switchkonfiguration  
* Die Switchkonfiguration


<pre>
<pre>
Zeile 152: Zeile 155:
option vlan '1'
option vlan '1'
option vid '1'
option vid '1'
option ports '1 6t' ### Hier den Uplink anstecken
option ports '5 6t' ### Hier den Uplink anstecken


config switch_vlan
config switch_vlan
option device 'switch0'
option device 'switch0'
option vlan '2'
option vlan '2'
option ports '2 3 4 5 0t'  ### auf den Ports faellt das fff-Netz raus
option ports '1 2 3 4 0t'  ### auf den Ports fällt das fff-Netz raus
option vid '2'
option vid '2'
</pre>
</pre>


=== Wireguard ===
==Anbindung ans Freifunknetz==


Wir brauchen eine Anbindung an das Freifunknetz. Dafür eignet sich Wireguard hervorragend. Alternativ geht natürlich auch eine Richtfunkstrecke oder ein Kabel o.ä. Dazu mit Peeringpartner absprechen
Wir brauchen eine Anbindung an das Freifunknetz. Dafür eignet sich WireGuard oder eine Richtfunkstrecke oder ein Kabel o.ä. Dazu mit Peeringpartner absprechen.


* Wireguard installieren
=== WireGuard ===
 
* WireGuard installieren


  opkg install wireguard
  opkg install wireguard


* Die konfiguration erfolgt auch in /etc/config/network
* Die Konfiguration erfolgt auch in /etc/config/Network.
 
Man benötigt einen Peeringpartner im Freifunknetz, zu dem man einen Wireguardtunnel aufbauen kann. Dazu auf der Mailingliste anfragen, oder man kennt schon jemanden persönlich. Da tauscht man dann die Keys aus.


In dieser Beispielkonfiguration gibt es noch einen Wireguardtunnel nach Schweden zu azire-vpn, über den der Internettraffic raus geht.
Man benötigt einen Peeringpartner im Freifunknetz, zu dem man einen WireGuard-Tunnel aufbauen kann. Dazu auf der Mailingliste anfragen, oder man kennt schon jemanden persönlich. Da tauscht man dann die Keys aus.


<pre>
<pre>


config interface 'fff'
config interface 'wgfff'
option proto 'wireguard'
option proto 'wireguard'
option listen_port '31337'
option listen_port '31337'
Zeile 185: Zeile 188:
option private_key 'Der ist auch geheim'
option private_key 'Der ist auch geheim'


config wireguard_fff
config wireguard_wgfff
option ifname 'fff'
option ifname 'wgfff'
option public_key 'cG9uIgQqVf9BCxHtAeaVBxnvyc5iHpoHoh82h9dv63w='
option public_key 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx='
option allowed_ips '0.0.0.0/0 ::/0'
option allowed_ips '0.0.0.0/0 ::/0'
option endpoint_host 'yor peering partner IP'
option endpoint_host 'yor peering partner IP'
Zeile 194: Zeile 197:


</pre>
</pre>
=== Richtfunk===


=== Babel ===
=== Babel ===


Damit das Routing funktioniert brauchen wir noch Babel
Damit das Routing funktioniert brauchen wir noch Babel.


* Installieren
* Installieren
Zeile 216: Zeile 221:
option type 'wired'
option type 'wired'


config interface 'fff'
config interface 'wgfff'
option ifname 'fff'
option ifname 'wgfff'
option type 'wired'
option type 'wired'


Zeile 229: Zeile 234:
option local 'true'
option local 'true'
option ip 'fd43:5602:29bd::/48'
option ip 'fd43:5602:29bd::/48'
config filter
option type 'redistribute'
option local 'true'
option ip '2a0b:f4c0::/32'


config filter
config filter
Zeile 252: Zeile 252:
=== Routing ===
=== Routing ===


Das Routing wird auch in der /etc/config/network eingetragen
Das Routing wird auch in der /etc/config/network eingetragen.


<pre>config rule
<pre>config rule
Zeile 289: Zeile 289:
config route 'fffclient'
config route 'fffclient'
option interface 'mesh'
option interface 'mesh'
option target '10.83.85.0'
option target '10.83.xx.0'
option netmask '255.255.255.192'
option netmask '255.255.255.192'
option table 'fff'
config route6 'fffdefault6'
option interface 'wg0'
option target '::/0'
option gateway '2a03:8600:1001:4000::1'
option table 'fff'
config route6 'fffclient6'
option interface 'mesh'
option target '2a03:8600:1001:5b2a::/64'
option table 'fff'
option table 'fff'


config route6 'ffffd43'
config route6 'ffffd43'
option interface 'mesh'
option interface 'mesh'
option target 'fd43:5602:29bd:27::/64'
option target 'fd43:5602:29bd:xx::/64'
option table 'fff'
option table 'fff'
</pre>
</pre>


* TCP clamping und.
* TCP clamping
Bis die Firewall fertig ist, kommt das erst mal in die /etc/rc.local
Bis die Firewall fertig ist, kommt das erst mal in die /etc/rc.local.


<pre>
<pre>
# clamping
# clamping
iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o fff -j TCPMSS --clamp-mss-to-pmtu
iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o fff -j TCPMSS --clamp-mss-to-pmtu
</pre>
</pre>


== Hood ==
=== dhcp und Nameserver ===
=== dhcp und Nameserver ===


Zeile 326: Zeile 314:
<pre>
<pre>
config dnsmasq
config dnsmasq
option domainneeded '1'
        option domainneeded '0'
option boguspriv '1'
        option boguspriv '0'  
option filterwin2k '0'
        option filterwin2k '0'
option localise_queries '1'
        option localise_queries '0'
option rebind_protection '1'
        option rebind_protection '0'
option rebind_localhost '1'
        option rebind_localhost '1'  
option local '/lan/'
        option domain 'fff.community'
option domain 'lan'
        option expandhosts '0'      
option expandhosts '1'
        option nonegcache '0'  
option nonegcache '0'
        option authoritative '1'
option authoritative '1'
        option readethers '1'  
option readethers '1'
        option leasefile '/tmp/dhcp.leases'
option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.auto'
option resolvfile '/tmp/resolv.conf.auto'
        option nonwildcard '1'                 
option nonwildcard '1'
        option localservice '0'
option localservice '1'
        list server '10.50.252.0'
        list server '/in-addr.arpa/10.50.252.0'
        list server '/ip6.arpa/10.50.252.0'   
                                             
config dhcp 'mesh'                       
        option leasetime '12h'
        option interface 'mesh'
        option start '11'     
        option limit '52'     
        list dhcp_option '6,10.50.252.0'
        option ra 'server'             
        option ra_management '0'       
        option ra_default '0'         
                               
config odhcpd 'odhcpd'         
        option maindhcp '0' 
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'                         
</pre>
 
=== Batman ===
* Kernelmodul und batctl installieren
 
opkg install kmod-batman-adv
opkg install batctl
 
* Batman konfigurieren in /etc/config/batman
<pre>
config mesh 'bat0'
        option gw_mode 'server'
        option bridge_loop_avoidance '0'
        option network_coding '0'
        option aggregated_ogms '1'
        option ap_isolation '0'
        option bonding '0'
        option fragmentation '1'
        option orig_interval '1000'
        option distributed_arp_table '1'
        option hop_penalty '30'
</pre>
 
=== Interfaces, wifi und switch ===
 
* bat0 in die Bridge mesh stecken. (/etc/config/network)
<pre>
config interface 'mesh'
option ifname 'bat0 eth0.1'  # hier bat0 hinzufügen
</pre>
 
* Interfaces ins bat0. (/etc/config/network)
<pre>
config interface 'ethmesh'
option mtu '1528'
option proto 'batadv'
option mesh 'bat0'
option ifname 'eth0.3'
option macaddr 'ec:08:6b:27:02:cd'
 
config interface 'w2mesh'
option mtu '1528'
option proto 'batadv'
option mesh 'bat0'
</pre>
 
* Switch konfigurieren. ethmesh auf eth0.3 kommt auf Port 1 raus.
<pre>
config switch_vlan 'eth0_3'
option device 'switch0'
option vlan '3'
option vid '3'
option ports '0t 1'
 
## vlan 1 ändern
config switch_vlan
option device 'switch0'
option vlan '1'
option vid '1'
option ports '2 3 4 6t' ### hier Port 1 weg nehmen
</pre>
 
* Wifi w2mesh und w2configap hinzufügen (/etc/config/wireless)
<pre>
config wifi-iface 'w2mesh'
option device 'radio1'
option network 'w2mesh'
option ifname 'w2mesh'
option mode 'mesh'
option mesh_id 'mesh.myhood.freifunk.net'
option encryption 'none'
option mesh_fwding '0'
 
config wifi-iface 'w2configap'
option device 'radio1'
option network 'configap2'
option ifname 'w2configap'
option mode 'ap'
option ssid 'config.franken.freifunk.net'
option encryption 'none'
option hidden '1'
</pre>
 
=== Alfred ===
 
* Installieren
 
opkg install alfred
 
* Konfiguration in /etc/config/alfred
 
<pre>config alfred 'alfred'
        option interface 'br-mesh'
        option mode 'master'
        option batmanif 'none'
        option start_vis '0'
        option run_facters '0'
 
</pre>
 
=== Alfred Monitoring Proxy ===
 
Siehe auch Gatewayanleitung [[Freifunk-Gateway_aufsetzen/Alfred]]
 
Wir benötigen das alfred-json von kratz00 (https://github.com/kratz00/alfred-json). Entweder selbst kompilieren (Achtung! Darauf achten, dass man es für die richtige Plattform Kompiliert) Oder auf der ML fragen, ob schon jemand ein passendes Binary oder ipk hat.
 
Für den c2600 gibt es hier: http://159.69.26.184/alfred-json_0.0.1-1_arm_cortex-a15_neon-vfpv4.ipk ein ipk zum installieren.
====alfred-json selbst kompilieren====
Man besorgt sich die OpenWrt Quellen und bereitet alles vor:
https://openwrt.org/docs/guide-developer/quickstart-build-images
 
Das Makefile nach package/utils/alfred-json/Makefile
<pre>
 
include $(TOPDIR)/rules.mk
 
PKG_NAME:=alfred-json
PKG_VERSION:=0.0.1
PKG_RELEASE:=1
PKG_LICENSE:=GPL-2.0
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=e4cacfc791092389f63c36a435d3f1d069f8a13e
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_URL:=https://github.com/kratz00/alfred-json.git
 
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
 
define Package/alfred-json
        SECTION:=utils
        CATEGORY:=Utilities
        TITLE:= A.L.F.R.E.D - JSON Client
        URL:=https://github.com/kratz00/alfred-json
        DEPENDS:=+jansson +zlib
endef
 
define Package/alfred-json/install
        $(INSTALL_DIR) $(1)/bin/
        $(CP) $(PKG_INSTALL_DIR)/usr/bin/alfred-json $(1)/bin/
endef
 
$(eval $(call BuildPackage,alfred-json))
</pre>
 
Jetzt make menuconfig und target auswählen und unter utils findet man alfred-json. Das Package als Modul anwählen <M>
 
make package/utils/alfred-json/{clean,compile}
 
baut das ipkg. Es sollte unter bin/packages/Targetxxxx/alfred-json.xxxx.ipkg zu finden sein und kann mit opkg installiert werden.
 
* Skript anlegen
 
<pre>
cat /usr/sbin/alfred-monitoring-proxy
#!/bin/ash
 
api_url="http://monitoring.freifunk-franken.de/api/alfred"
 
fetch_ids="64"
 
for fetch_id in $fetch_ids
do
    data=$(alfred-json -r "$fetch_id")
    curl -k -v -H "Content-type: application/json; charset=UTF-8" -X POST --data "{\"$fetch_id\": $data}" $api_url
done
 
</pre>
 
* cronjob anlegen
 
crontab -e
*/5 * * * * sleep 70; /usr/sbin/alfred-monitoring-proxy
 
=== Hoodfile und Webserver zum Ausliefern ===
 
* Webserver Konfig ergänzen in /etc/config/uhttpd


config dhcp 'mesh'
<pre>
option leasetime '12h'
config uhttpd 'hood'
option interface 'mesh'
        list listen_http '2342'
option start '11'
        option home '/www/hood'
option limit '52'
        option rfc1918_filter '1'
option ra 'server'
        option network_timeout '30'
list dhcp_option '6,10.50.252.0'
        option tcp_keepalive '1'
option dhcpv6 'disabled'
        option config '_'
option ra_default '0'
</pre>


config dhcp 'lan'
* Das Hoodfile nach /www/hood/keyxchangev2data legen
option interface 'lan'
option ignore '1'


config dhcp 'wan'
Beispiel
option interface 'wan'
<pre>
option ignore '1'
{
  "hood": {
    "ntp_ip": "fd43:5602:29bd:ffff::10",
    "name": "Myhood",
    "mesh_type2": "802.11s",
    "mesh_essid": "mesh.myhood.freifunk.net",
    "mesh_bssid": "",
    "mesh_type5": "802.11s",
    "mode5": "ht20",
    "essid": "freifunk.myhood.net",
    "channel5": "40",
    "upgrade_path": "",
    "timestamp": "1516486388",
    "channel2": "13",
    "protocol": "batman-adv-v15",
    "mesh_id": "mesh.myhood.freifunk.net",
    "mode2": "ht20"
  },
  "network": {
    "ula_prefix": "fd43:5602:29bd:xx:/64"
  },
  "version": 1
}
</pre>
</pre>


== Besonderheit TP c2600 ==
===Nodewatcher===
 
Das Skript kann man sich von der fff-firmware "ausleihen" und ev. etwas anpassen.
 
===gatewayinfo===
 
 
 
===macnocker===
Sollte in einem Netz, das man selbst administriert, nicht nötig sein.
 
= Besonderheit TP-Link Archer C2600 =


Mit dem Standard wifimodul und wifi-Firmware kann der c2600 kein mesh. Falls man nas braucht, muss man diese austauschen. Die funktionierenden sind auch im OpenWrt Repo.
Mit dem Standard Wifimodul und Wifi-Firmware kann der Archer C2600 kein Mesh. Falls man Mesh braucht, muss man diese austauschen. Die funktionierenden sind auch im OpenWrt Repo.


<pre>
<pre>

Aktuelle Version vom 13. März 2019, 14:29 Uhr

Eine Anleitung, ein dezentrales/lokales Gateway mit OpenWrt einzurichten.

Hier am Beispiel eines TP-Link Archer C2600.

Der Router wird dezentrales Gateway.

Wir können viel aus der Anleitung Freifunk-Gateway aufsetzen ableiten. Dort findet man auch genauere Erklärungen zu den einzelnen Themen. Bevor man hier los legt, sollte klar sein, was ein Gateway im Freifunknetz tut. Wir bauen die Funktionalität unter OpenWrt nach.

Sehr hilfreich ist es auch, wenn man sich mit dem uci-System und den Dateien in /etc/config von OpenWrt auskennt. -> OpenWrt Doku!

Grundinstallation

  • Als erstes ein aktuelles OpenWrt flashen.
  • Am Webinterface anmelden und ein Rootpasswort vergeben. Eventuell ssh an allen Devices erlauben, macht es leichter drauf zu kommen, während wir konfigurieren. Man kann auch gleich seinen ssh-key hinterlegen.
  • Hostname festlegen und Zeitzone setzen.

Jetzt sollte man sich via ssh am Router einloggen können.

Firewall

Erst mal ausschalten. Kann Probleme beim Testen und Konfigurieren machen.

/etc/init.d/firewall stop
/etc/init.d/firewall disable


Routingtabelle deklarieren

Tabellennummer und Name in /etc/iproute2/rt_tables eintragen.

10     fff

Vorbereitung zur Installation der Pakete

Es können nur Pakete via Internet installiert werden, wenn zuvor die Paketquellen, die in /etc/opkg definiert sind, aktualisiert werden.

opkg update

Konfiguration

opkg install ip-bridge ip-full iptables ip6tables
auch hilfreich
opkg install tcpdump iperf3

Netzwerkinterfaces

Die Konfiguration der Interfaces, das Routing und des Switches erfolgt in /etc/config/network und die Wifi-Interfaces in /etc/config/wireless

Hier ein Beispiel mit dem TP-Link Archer C2600.

  • Die /etc/config/wireless
config wifi-device 'radio0'
	option type 'mac80211'
	option hwmode '11a'
	option path 'soc/1b500000.pci/pci0000:00/0000:00:00.0/0000:01:00.0'
	option country 'DE'
	option legacy_rates '1'
	option disabled '0'
	option channel '40'
	option htmode 'VHT40'
	option txpower '16'

config wifi-iface 'w5ap'
	option device 'radio0'
	option ifname 'w5ap'
	option mode 'ap'
	option ssid 'freifunk.xxx.net'
	option encryption 'none'
	option hidden '0'
	option network 'mesh'

config wifi-device 'radio1'
	option type 'mac80211'
	option hwmode '11g'
	option path 'soc/1b700000.pci/pci0001:00/0001:00:00.0/0001:01:00.0'
	option htmode 'HT20'
	option country 'DE'
	option legacy_rates '1'
	option disabled '0'
	option channel '13'
	option txpower '16'

config wifi-iface 'w2ap'
	option device 'radio1'
	option ifname 'w2ap'
	option mode 'ap'
	option ssid 'freifunk.xxx.net'
	option encryption 'none'
	option hidden '0'
	option network 'mesh'
  • Die /etc/config/Network; hier die Grundkonfiguration
config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option ula_prefix 'fdff:0::/64'

config interface 'lan'    
#### mit dem Interface hängt man im Home-LAN. In die Bridge kann man dann
#### einfach ein wireless Interface hängen und das Heimnetz ausstrahlen.
	option type 'bridge'
	option proto 'static'
	option ipaddr 'local IP'  ### meistens 192.168.xxx.xxx
	option netmask '255.255.255.0'
	option ip6assign '64'
	option gateway 'local default route'
	option dns 'x.x.x.x 9.9.9.9'
	option ifname 'eth1.1'

# oder einfach DHCP
# config interface 'lan'
#        option proto 'dhcp'

config interface 'mesh'
	option type 'bridge'
	option macaddr 'ec:08:6b:xx:xx:xx'
	option proto 'static'
	option ipaddr 'your fff IP'
	option netmask '255.255.255.xxx'
	option broadcast '10.83.xx.255'
	list ip6addr 'fd43:5602:29bd:your fff IP/64'
	list ip6addr 'fe80::1/64'
	option ip4table 'fff'
	option ip6table 'fff'
	option ifname 'eth0.2'

config interface 'lan6'
	option proto 'dhcpv6'
	option ifname 'eth1.1'
	option reqaddress 'try'
	option reqprefix 'auto'
  • Die Switchkonfiguration
config switch
	option name 'switch0'
	option reset '1'
	option enable_vlan '1'

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option vid '1'
	option ports '5 6t' ### Hier den Uplink anstecken

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option ports '1 2 3 4 0t'  ### auf den Ports fällt das fff-Netz raus
	option vid '2'

Anbindung ans Freifunknetz

Wir brauchen eine Anbindung an das Freifunknetz. Dafür eignet sich WireGuard oder eine Richtfunkstrecke oder ein Kabel o.ä. Dazu mit Peeringpartner absprechen.

WireGuard

  • WireGuard installieren
opkg install wireguard
  • Die Konfiguration erfolgt auch in /etc/config/Network.

Man benötigt einen Peeringpartner im Freifunknetz, zu dem man einen WireGuard-Tunnel aufbauen kann. Dazu auf der Mailingliste anfragen, oder man kennt schon jemanden persönlich. Da tauscht man dann die Keys aus.


config interface 'wgfff'
	option proto 'wireguard'
	option listen_port '31337'
	list addresses '10.83.252.xx/32'
	list addresses 'fe80::babe:xx:xx/64'
	list addresses 'fd43:5602:29bd:ffff::xx'
	option private_key 'Der ist auch geheim'

config wireguard_wgfff
	option ifname 'wgfff'
	option public_key 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx='
	option allowed_ips '0.0.0.0/0 ::/0'
	option endpoint_host 'yor peering partner IP'
	option endpoint_port '31337'
	option persistent_keepalive '60'

Richtfunk

Babel

Damit das Routing funktioniert brauchen wir noch Babel.

  • Installieren
opkg install babeld
  • Konfiguration in /etc/config/babeld
config general
	option export_table '10'
	option import_table '10'
	option first_table_number '100'
	option local_port '33123'


config interface
	option type 'wired'

config interface 'wgfff'
	option ifname 'wgfff'
	option type 'wired'

config filter
	option type 'redistribute'
	option local 'true'
	option ip '10.0.0.0/8'

config filter
	option type 'redistribute'
	option local 'true'
	option ip 'fd43:5602:29bd::/48'

config filter
	option type 'redistribute'
	option local 'true'
	option action 'deny'

config filter
	option type 'redistribute'
	option ip '10.0.0.0/8'

config filter
	option type 'redistribute'
	option ip 'fd43:5602:29bd::/48'

Routing

Das Routing wird auch in der /etc/config/network eingetragen.

config rule
	option in 'mesh'
	option dest '0.0.0.0/0'
	option lookup 'fff'

config rule
	option in 'fff'
	option dest '0.0.0.0/0'
	option lookup 'fff'

config rule
	option dest '10.0.0.0/8'
	option lookup 'fff'

config rule6
	option in 'mesh'
	option dest '::/0'
	option lookup 'fff'

config rule6
	option in 'fff'
	option dest '::/0'
	option lookup 'fff'

config rule6
	option dest 'fc00::/7'
	option lookup 'fff'

config rule6
	option src 'fc00::/7'
	option lookup 'fff'


config route 'fffclient'
	option interface 'mesh'
	option target '10.83.xx.0'
	option netmask '255.255.255.192'
	option table 'fff'

config route6 'ffffd43'
	option interface 'mesh'
	option target 'fd43:5602:29bd:xx::/64'
	option table 'fff'
  • TCP clamping

Bis die Firewall fertig ist, kommt das erst mal in die /etc/rc.local.

# clamping
iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o fff -j TCPMSS --clamp-mss-to-pmtu

Hood

dhcp und Nameserver

  • Konfiguration von dnsmasq in /etc/config/dhcp
config dnsmasq
        option domainneeded '0'
        option boguspriv '0'   
        option filterwin2k '0'
        option localise_queries '0'
        option rebind_protection '0'
        option rebind_localhost '1' 
        option domain 'fff.community'
        option expandhosts '0'       
        option nonegcache '0' 
        option authoritative '1'
        option readethers '1'   
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.auto'
        option nonwildcard '1'                   
        option localservice '0'
        list server '10.50.252.0'
        list server '/in-addr.arpa/10.50.252.0'
        list server '/ip6.arpa/10.50.252.0'    
                                               
config dhcp 'mesh'                         
        option leasetime '12h'
        option interface 'mesh'
        option start '11'      
        option limit '52'      
        list dhcp_option '6,10.50.252.0'
        option ra 'server'              
        option ra_management '0'        
        option ra_default '0'           
                                
config odhcpd 'odhcpd'          
        option maindhcp '0'  
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'                          

Batman

  • Kernelmodul und batctl installieren
opkg install kmod-batman-adv
opkg install batctl
  • Batman konfigurieren in /etc/config/batman
config mesh 'bat0'
        option gw_mode 'server'
        option bridge_loop_avoidance '0'
        option network_coding '0'
        option aggregated_ogms '1'
        option ap_isolation '0'
        option bonding '0'
        option fragmentation '1'
        option orig_interval '1000'
        option distributed_arp_table '1'
        option hop_penalty '30'

Interfaces, wifi und switch

  • bat0 in die Bridge mesh stecken. (/etc/config/network)
config interface 'mesh'
	option ifname 'bat0 eth0.1'  # hier bat0 hinzufügen
  • Interfaces ins bat0. (/etc/config/network)
config interface 'ethmesh'
	option mtu '1528'
	option proto 'batadv'
	option mesh 'bat0'
	option ifname 'eth0.3'
	option macaddr 'ec:08:6b:27:02:cd'

config interface 'w2mesh'
	option mtu '1528'
	option proto 'batadv'
	option mesh 'bat0'
  • Switch konfigurieren. ethmesh auf eth0.3 kommt auf Port 1 raus.
config switch_vlan 'eth0_3'
	option device 'switch0'
	option vlan '3'
	option vid '3'
	option ports '0t 1'

## vlan 1 ändern
config switch_vlan
	option device 'switch0'
	option vlan '1'
	option vid '1'
	option ports '2 3 4 6t'  ### hier Port 1 weg nehmen
  • Wifi w2mesh und w2configap hinzufügen (/etc/config/wireless)
config wifi-iface 'w2mesh'
	option device 'radio1'
	option network 'w2mesh'
	option ifname 'w2mesh'
	option mode 'mesh'
	option mesh_id 'mesh.myhood.freifunk.net'
	option encryption 'none'
	option mesh_fwding '0'

config wifi-iface 'w2configap'
	option device 'radio1'
	option network 'configap2'
	option ifname 'w2configap'
	option mode 'ap'
	option ssid 'config.franken.freifunk.net'
	option encryption 'none'
	option hidden '1'

Alfred

  • Installieren
opkg install alfred
  • Konfiguration in /etc/config/alfred
config alfred 'alfred'
        option interface 'br-mesh'
        option mode 'master'
        option batmanif 'none'
        option start_vis '0'
        option run_facters '0'

Alfred Monitoring Proxy

Siehe auch Gatewayanleitung Freifunk-Gateway_aufsetzen/Alfred

Wir benötigen das alfred-json von kratz00 (https://github.com/kratz00/alfred-json). Entweder selbst kompilieren (Achtung! Darauf achten, dass man es für die richtige Plattform Kompiliert) Oder auf der ML fragen, ob schon jemand ein passendes Binary oder ipk hat.

Für den c2600 gibt es hier: http://159.69.26.184/alfred-json_0.0.1-1_arm_cortex-a15_neon-vfpv4.ipk ein ipk zum installieren.

alfred-json selbst kompilieren

Man besorgt sich die OpenWrt Quellen und bereitet alles vor: https://openwrt.org/docs/guide-developer/quickstart-build-images

Das Makefile nach package/utils/alfred-json/Makefile


include $(TOPDIR)/rules.mk

PKG_NAME:=alfred-json
PKG_VERSION:=0.0.1
PKG_RELEASE:=1
PKG_LICENSE:=GPL-2.0
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=e4cacfc791092389f63c36a435d3f1d069f8a13e
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_URL:=https://github.com/kratz00/alfred-json.git

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk

define Package/alfred-json
        SECTION:=utils
        CATEGORY:=Utilities
        TITLE:= A.L.F.R.E.D - JSON Client
        URL:=https://github.com/kratz00/alfred-json
        DEPENDS:=+jansson +zlib
endef

define Package/alfred-json/install
        $(INSTALL_DIR) $(1)/bin/
        $(CP) $(PKG_INSTALL_DIR)/usr/bin/alfred-json $(1)/bin/
endef

$(eval $(call BuildPackage,alfred-json))

Jetzt make menuconfig und target auswählen und unter utils findet man alfred-json. Das Package als Modul anwählen <M>

make package/utils/alfred-json/{clean,compile}

baut das ipkg. Es sollte unter bin/packages/Targetxxxx/alfred-json.xxxx.ipkg zu finden sein und kann mit opkg installiert werden.

  • Skript anlegen
cat /usr/sbin/alfred-monitoring-proxy 
#!/bin/ash

api_url="http://monitoring.freifunk-franken.de/api/alfred"

fetch_ids="64"

for fetch_id in $fetch_ids
do
    data=$(alfred-json -r "$fetch_id")
    curl -k -v -H "Content-type: application/json; charset=UTF-8" -X POST --data "{\"$fetch_id\": $data}" $api_url
done

  • cronjob anlegen
crontab -e
*/5 * * * * sleep 70; /usr/sbin/alfred-monitoring-proxy

Hoodfile und Webserver zum Ausliefern

  • Webserver Konfig ergänzen in /etc/config/uhttpd
config uhttpd 'hood'
        list listen_http '2342'
        option home '/www/hood'
        option rfc1918_filter '1'
        option network_timeout '30'
        option tcp_keepalive '1'
        option config '_'
  • Das Hoodfile nach /www/hood/keyxchangev2data legen

Beispiel

{
  "hood": {
    "ntp_ip": "fd43:5602:29bd:ffff::10",
    "name": "Myhood",
    "mesh_type2": "802.11s",
    "mesh_essid": "mesh.myhood.freifunk.net",
    "mesh_bssid": "",
    "mesh_type5": "802.11s",
    "mode5": "ht20",
    "essid": "freifunk.myhood.net",
    "channel5": "40",
    "upgrade_path": "",
    "timestamp": "1516486388",
    "channel2": "13",
    "protocol": "batman-adv-v15",
    "mesh_id": "mesh.myhood.freifunk.net",
    "mode2": "ht20"
  },
  "network": {
    "ula_prefix": "fd43:5602:29bd:xx:/64"
  },
  "version": 1
}

Nodewatcher

Das Skript kann man sich von der fff-firmware "ausleihen" und ev. etwas anpassen.

gatewayinfo

macnocker

Sollte in einem Netz, das man selbst administriert, nicht nötig sein.

Besonderheit TP-Link Archer C2600

Mit dem Standard Wifimodul und Wifi-Firmware kann der Archer C2600 kein Mesh. Falls man Mesh braucht, muss man diese austauschen. Die funktionierenden sind auch im OpenWrt Repo.


opkg remove ath10k-firmware-qca4019 
opkg install kmod-ath10k-ct ath10k-firmware-qca99x0-ct