L2TP und Tunneldigger: Unterschied zwischen den Versionen

Aus Freifunk Franken
Wechseln zu:Navigation, Suche
K (Änderungen von Moexe (Diskussion) wurden auf die letzte Version von Rola zurückgesetzt)
Keine Bearbeitungszusammenfassung
Zeile 7: Zeile 7:


Nachteile: *Umstellung von GWs und Firmware
Nachteile: *Umstellung von GWs und Firmware
'''Aktuell (19.3.): Auf allen 4 Gateways in den Hoods Hasberge und Hasberge-Süd läuft der Tunnelbroker'''
Das heisst, ihr könnt komplett auf l2tp umschalten, da alle GWs direkt erreicht werden.
'''To do: Wir brauchen eine Firmware zum testen mit den nötigen Patches und Konfigs''


===Am Router===
===Am Router===


Ich habe euch nen tarball gemacht. Da ist alles drin und läuft mit der
Wir haben noch keine fertige Firmware zum Testen. Vorerst geht auch das:
normalen aktuellen stable.
 


Sicherstellen das am Router die Kernelmodule enthalten sind. Bei meinen wr1043 v0.5.2 war dies nicht der Fall.
Sicherstellen das am Router die Kernelmodule enthalten sind. Bei meinen wr1043 v0.5.2 war dies nicht der Fall.
Zeile 60: Zeile 66:
  sudo apt-get install iproute bridge-utils libnetfilter-conntrack3 python-dev  libevent-dev ebtables python-virtualenv
  sudo apt-get install iproute bridge-utils libnetfilter-conntrack3 python-dev  libevent-dev ebtables python-virtualenv


Kernelmodule beim Booten laden:  (Nötig??)
'''Installation:'''
 
echo "l2tp_core
      l2tp_eth
      l2tp_netlink" >> /etc/modules
 
Installation:


  mkdir /srv/tunneldigger <br />
  mkdir /srv/tunneldigger <br />
Zeile 76: Zeile 76:
  pip install -r tunneldigger/broker/requirements.txt <br />
  pip install -r tunneldigger/broker/requirements.txt <br />


Konfiguration in /srv/tunneldigger/tunneldigger/broker/l2tp_broker-sued.cfg anpassen
'''Konfiguration:'''
(Öffentliche IP des Gateway Ports und Interface, port und idbase, namespace)
 
Die ersten Tests haben gezeigt, dass Batman es nicht mag, wenn Interfaces kommen und gehen. Wir können also die L2-Tunnel nicht direkt an Batman hängen. Schade, dann könnte man no_rebroadcast einschalten.
 
Die Slovenen schreiben:


l2tp_broker-sued.cfg steht für die Hood, könnte also auch l2tp_broker-nbg oder l2tp_broker-wue.cfg heisen. Pro Hood muss ein eigener Broker mit up und down erstellt werden.
''Example hook scripts present in the scripts/ subdirectory are set up to create one bridge device per MTU and attach L2TP interfaces to these bridges. They also configure a default IP address to newly created tunnels, set up ebtables to isolate bridge ports and update the routing policy via ip rule so traffic from these interfaces is routed via the mesh routing table.''
''Each tunnel established with the broker will create its own interface. Because we are using OLSRv1, we cannot dynamically add interfaces to it, so we group tunnel interfaces into bridges.''
''We could put all tunnel interfaces into the same bridge, but this would actually create a performance problem. Different tunnels can have different MTU values -- but there is only one MTU value for the bridge, the minimum of all interfaces that are attached to that bridge. To avoid this problem, we create multiple bridges, one for each MTU value -- this is what the example scripts do.''
''We also configure some ip policy rules to ensure that traffic coming in from the bridges gets routed via our mesh routing table and not the main one (see bridge_functions.sh). Traffic between bridge ports is not forwarded (this is achieved via ebtables), otherwise the routing daemons at the nodes would think that all of them are directly connected -- which would cause them to incorrectly see a very large 1-hop neighbourhood. This file also contains broker-side IP configuration for the bridge which should really be changed.''


'''Wichtig! Port für die entsprechende Hood = fastd-port + 10000. '''
Ähnliche Probleme hatten die mit OLSR.
Also haben wir mal die Config deren Vorschlägen angepasst.
 
Es wird für jede MTU die ankommt eine Bridge aufgemacht und da kommen dann alle Interfaces mit der gleichen MTU rein.
'''Beispiel-config für has und has-sued Hood auf GW von Max (fff-has  78.47.36.148)'''
 
Die l2tp_broker-xxxxx.cfg Dateien in ''/srv/tunneldigger/tunneldigger/broker/''
 
l2tp_broker-has.cfg :


  [broker]
  [broker]
  ; IP address the broker will listen and accept tunnels on
  ; IP address the broker will listen and accept tunnels on
  address=a.b.c.d #öffentliche ip des Servers
  address=78.47.36.148
  ; Ports where the broker will listen on
  ; Ports where the broker will listen on
  port=fastd-port + 10000
  port=20004
  ; Interface with that IP address
  ; Interface with that IP address
  interface=eth0
  interface=eth0
Zeile 93: Zeile 108:
  max_tunnels=1024
  max_tunnels=1024
  ; Tunnel port base
  ; Tunnel port base
  port_base=20000 #(für jede Brokerinstanz eine andere)
  port_base=24000
  ; Tunnel id base
  ; Tunnel id base
  tunnel_id_base=100 #(für jede Brokerinstanz eine andere)
  tunnel_id_base=4000
  ; Namespace (for running multiple brokers); note that you must also
  ; Namespace (for running multiple brokers); note that you must also
  ; configure disjunct ports, and tunnel identifiers in order for
  ; configure disjunct ports, and tunnel identifiers in order for
  ; namespacing to work
  ; namespacing to work
  namespace=has-sued
  namespace=has
  ; check if all kernel module are loaded. Do not check for built-ins.
  ; check if all kernel module are loaded. Do not check for built-ins.
  check_modules=true
  check_modules=true
Zeile 109: Zeile 124:
  verbosity=DEBUG
  verbosity=DEBUG
  ; Should IP addresses be logged or not
  ; Should IP addresses be logged or not
  log_ip_addresses=false
  log_ip_addresses=false  
   
   
  [hooks]
  [hooks]
  ; Arguments to the session.{up,pre-down,down} hooks are as follows:
  ; Arguments to the session.{up,pre-down,down} hooks are as follows:
  ;
  ;
  ;    <tunnel_id> <session_id> <interface> <mtu> <endpoint_ip> <endpoint_port>   <local_port>
  ;    <tunnel_id> <session_id> <interface> <mtu> <endpoint_ip> <endpoint_port> <local_port>
  ;
  ;
  ; Arguments to the session.mtu-changed hook are as follows:
  ; Arguments to the session.mtu-changed hook are as follows:
  ;
  ;
  ;    <tunnel_id> <session_id> <interface> <old_mtu> <new_mtu>
  ;    <tunnel_id> <session_id> <interface> <old_mtu> <new_mtu>
;
; Called after the tunnel interface goes up
session.up=/srv/tunneldigger/tunneldigger/broker/scripts/has.up
; Called just before the tunnel interface goes down
session.pre-down=/srv/tunneldigger/tunneldigger/broker/scripts/has.down
; Called after the tunnel interface goes down
session.down=
; Called after the tunnel MTU gets changed because of PMTU discovery
session.mtu-changed=/srv/tunneldigger/tunneldigger/broker/scripts/mtu_changed- has.sh
l2tp_broker-hassued.cfg :
[broker]
; IP address the broker will listen and accept tunnels on
address=78.47.36.148
; Ports where the broker will listen on
port=20005
; Interface with that IP address
interface=eth0
; Maximum number of tunnels that will be allowed by the broker
max_tunnels=1024
; Tunnel port base
port_base=21000
; Tunnel id base
tunnel_id_base=1000
; Namespace (for running multiple brokers); note that you must also
; configure disjunct ports, and tunnel identifiers in order for
; namespacing to work
namespace=hassued
; check if all kernel module are loaded. Do not check for built-ins.
check_modules=true
[log]
; Log filename
filename=tunneldigger-broker.log
; Verbosity
verbosity=DEBUG
; Should IP addresses be logged or not
log_ip_addresses=false 
[hooks]
; Arguments to the session.{up,pre-down,down} hooks are as follows:
  ;
  ;
;    <tunnel_id> <session_id> <interface> <mtu> <endpoint_ip> <endpoint_port>  <local_port>
;
; Arguments to the session.mtu-changed hook are as follows:
;
;    <tunnel_id> <session_id> <interface> <old_mtu> <new_mtu>
;
   
   
  ; Called after the tunnel interface goes up
  ; Called after the tunnel interface goes up
  session.up=/srv/tunneldigger/tunneldigger/broker/scripts/has-sued.up
  session.up=/srv/tunneldigger/tunneldigger/broker/scripts/has-sued.up
  ; Called just before the tunnel interface goes down
  ; Called just before the tunnel interface goes down
  session.pre-down=
  session.pre-down=/srv/tunneldigger/tunneldigger/broker/scripts/has-sued.down
  ; Called after the tunnel interface goes down
  ; Called after the tunnel interface goes down
  session.down=/srv/tunneldigger/tunneldigger/broker/scripts/has-sued.down
  session.down=
  ; Called after the tunnel MTU gets changed because of PMTU discovery
  ; Called after the tunnel MTU gets changed because of PMTU discovery
  session.mtu-changed=
  session.mtu-changed=/srv/tunneldigger/tunneldigger/broker/scripts/mtu_changed- has-sued.sh
 
 
Skripte in ''scripts/''
 
bridge_functions.sh:
ensure_policy()
{
  ip rule del $*
  ip rule add $*
}
ensure_bridge()
{
  local brname="$1"
  brctl addbr $brname 2>/dev/null
  if <nowiki>[[ "$?" == "0" ]]</nowiki>; then
    # Bridge did not exist before, we have to initialize it
    ip link set dev $brname up
    # Neue Bridge batman hinzufügen
    batctl -m $BATDEV if add $brname
    # Disable forwarding between bridge ports
    ebtables -A FORWARD --logical-in $brname -j DROP
  fi
}




Hook Scripte /srv/tunneldigger/tunneldigger/broker/scripts/has-sued.up
has.up:


  #!/bin/bash
  #!/bin/bash
TUNNEL_ID="$1"
  INTERFACE="$3"
  INTERFACE="$3"
  ip link set dev $INTERFACE up
MTU="$4"
  /usr/sbin/batctl -m <bat interface von has-sued> if add $INTERFACE
BATDEV=bat4
. scripts/bridge_functions.sh
# Set the interface to UP state
ip link set dev $INTERFACE up mtu $MTU
# Add the interface to our bridge
ensure_bridge l2-br-has${MTU}
brctl addif l2-br-has${MTU} $INTERFACE
 
has-sued.up:
 
  #!/bin/bash
TUNNEL_ID="$1"
INTERFACE="$3"
MTU="$4"
BATDEV=bat7
. scripts/bridge_functions.sh
# Set the interface to UP state
ip link set dev $INTERFACE up mtu $MTU
# Add the interface to our bridge
ensure_bridge l2-br-sued${MTU}
brctl addif l2-br-sued${MTU} $INTERFACE




/srv/tunneldigger/tunneldigger/broker/scripts/has-sued.down
mtu_changed-has.sh


  #!/bin/bash
  #!/bin/bash
TUNNEL_ID="$1"
  INTERFACE="$3"
  INTERFACE="$3"
  /usr/sbin/batctl -m <bat interface von has-sued> if del $INTERFACE
  OLD_MTU="$4"
(Das sind nur Beispiele. Hier kann man die neuen Interfaces einstellen, Bridges zuordnen und ....
NEW_MTU="$5"
BATDEV=bat4
. scripts/bridge_functions.sh
# Remove interface from old bridge
brctl delif l2-br-has${OLD_MTU} $INTERFACE
# Change interface MTU
ip link set dev $INTERFACE mtu $NEW_MTU
# Add interface to new bridge
ensure_bridge l2-br-has${NEW_MTU}
brctl addif l2-br-has${NEW_MTU} $INTERFACE


Wenn batctl nicht in /usr/sbin liegt, Pfad anpassen. Bei mir liegt es z.b. in /usr/local/sbin


Wichtig: die up und down scripts müssem durch "chmod +x has-sued.up" bzw "chmod +x hassued.down" ausführbar gemacht werden.
mtu_changed-has-sued.sh


#!/bin/bash
TUNNEL_ID="$1"
INTERFACE="$3"
OLD_MTU="$4"
NEW_MTU="$5"
BATDEV=bat7
. scripts/bridge_functions.sh
# Remove interface from old bridge
brctl delif l2-br-sued${OLD_MTU} $INTERFACE
# Change interface MTU
ip link set dev $INTERFACE mtu $NEW_MTU
# Add interface to new bridge
ensure_bridge l2-br-sued${NEW_MTU}
brctl addif l2-br-sued${NEW_MTU} $INTERFACE




Start einrichten:
has.down


Systemd Start Unit in  /etc/systemd/system/tunneldigger-broker-sued.service
#!/bin/bash
TUNNEL_ID="$1"
INTERFACE="$3"
MTU="$4"
# Remove the interface from our bridge
brctl delif l2-br-has${MTU} $INTERFACE
 
 
has-sued.down
 
#!/bin/bash
TUNNEL_ID="$1"
INTERFACE="$3"
MTU="$4"
# Remove the interface from our bridge
brctl delif l2-br-sued${MTU} $INTERFACE
 
 
'''Start einrichten:'''
 
In ''/etc/systemd/system/'' Units erstellen
 
tunneldigger-broker-has.service:


  [Unit]
  [Unit]
Zeile 163: Zeile 336:
  Type=simple
  Type=simple
  WorkingDirectory=/srv/tunneldigger/tunneldigger
  WorkingDirectory=/srv/tunneldigger/tunneldigger
  ExecStart=/srv/tunneldigger/env_tunneldigger/bin/python -m broker.main /srv/tunneldigger/tunneldigger/broker/l2tp_broker-sued.cfg
  ExecStart=/srv/tunneldigger/env_tunneldigger/bin/python -m broker.main   /srv/tunneldigger/tunneldigger/broker/l2tp_broker-has.cfg
   
   
  KillMode=process
  KillMode=process
Zeile 169: Zeile 342:
   
   
  [Install]
  [Install]
  WantedBy=multi-user.target  
  WantedBy=multi-user.target
 
 
tunneldigger-broker-has.service:


[Unit]
Description=tunneldigger tunnelling network daemon using l2tpv3
After=network.target auditd.service
[Service]
Type=simple
WorkingDirectory=/srv/tunneldigger/tunneldigger
ExecStart=/srv/tunneldigger/env_tunneldigger/bin/python -m broker.main  /srv/tunneldigger/tunneldigger/broker/l2tp_broker-has.cfg
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target


Jetzt noch den Service anmelden, autostart und manuell Start <br />
Jetzt noch den Service anmelden, autostart und manuell Start <br />
  systemctl daemon-reload  <br />
  systemctl daemon-reload  <br />
  systemctl enable tunneldigger-broker-sued.service  <br />
  systemctl enable tunneldigger-broker-sued.service tunneldigger-broker-has.service  <br />
  systemctl start tunneldigger-broker-sued.service   <br />
  systemctl start tunneldigger-broker-sued.service tunneldigger-broker-has.service  <br />


Das kann man jetzt mehrfach machen mit unterschiedlichen Konfigurationen für verschiedene Hoods.
Das kann man jetzt mehrfach machen mit unterschiedlichen Konfigurationen für verschiedene Hoods.


Falls es Probleme beim Start des Brokers geben sollte, kann probiert werden im file l2tp_broker-xxx.cfg alle ";" ,zum auskommentieren, durch "#" zu ersetzen


über "systemctl status tunneldigger-broker-xxx.service" kann man den Status erfragen.
über "systemctl status tunneldigger-broker-xxx.service" kann man den Status erfragen.
===Tunnel aufbauen===
Ihr findet im tarball das kleine Skript l2tunnel zum steuern der Tunnel (s. oben)
Auf dem Router kann man auch mal von Hand mit
tunneldigger -f -u 123 -l <localIP> -b <Gw IP:Port> -i l2tp
den Tunnel aufbauen
Das OpenWrt Packet vom Tunneldigger bringt auch ein Startscript mit und eine Config-Datei: /etc/config/tunneldigger
Hier können die Tunneldevices konfiguriert werden.
config broker
list address '192.168.100.20:10050'
# list address '20.30.40.50:53'
# list address 'x.y.z.w:123'
option uuid 'abcd'
option interface 'l2tp0'
# option limit_bw_down '1024'
option enabled '1'
# option hook_script '/etc/tunneldigger.hook'
config broker
list address '192.168.200.20:20050'
# list address 'x.y.z.w:53'
# list address 'x.y.z.w:123'
option uuid 'efgh'
option interface 'l2tp1'
# option limit_bw_down '1024'
option enabled '1'
# option hook_script '/etc/tunneldigger.hook2'
Jetzt geht es ans Testen:
Wie müssen bei uns die Hook Skripte aussehen?
Wie stabil sind die Tunnel z.B bei Zwangstrennung vom Provider?
Hier scheint die Verbindung verloren zu gehen und der Tunnel bricht zusammen. Quick&Dirty Lösung:
vi /etc/l2trestart.sh
anlegen und mit
#!/bin/sh
/etc/init.d/tunneldigger start
l2tunnel on
füllen. Datei ausführbar machen:
chmod +x /etc/l2trestart.sh
vi /usr/lib/micron.d/default
editieren und folgende Zeile hinzufügen:
*/5 * * * * sh /etc/l2trestart.sh
micrond noch eben neu starten:
/etc/init.d/micrond restart
Laufen fastd und l2tp parallel?
Und natürlich die Sache mit der mtu.
usw.....

Version vom 19. März 2016, 18:18 Uhr

Diese Seite befindet sich noch im Entwurfsstadium.
Hilf mit sie zu verbessern!


Dies sind sie ersten zaghaften Versuche von fastd auf L2TP zu switchen, bzw. beide parallel zu nutzen. Dies soll nur eine kurze Zusammenfassung sein, was schon gemacht wurde. Nicht dass doppelte Arbeit geleistet wird. Doku folgt bei Erfolg

Vorteile: *Weniger CPU Last auf den Gateway Servern

Nachteile: *Umstellung von GWs und Firmware

Aktuell (19.3.): Auf allen 4 Gateways in den Hoods Hasberge und Hasberge-Süd läuft der Tunnelbroker

Das heisst, ihr könnt komplett auf l2tp umschalten, da alle GWs direkt erreicht werden.

'To do: Wir brauchen eine Firmware zum testen mit den nötigen Patches und Konfigs

Am Router

Wir haben noch keine fertige Firmware zum Testen. Vorerst geht auch das:


Sicherstellen das am Router die Kernelmodule enthalten sind. Bei meinen wr1043 v0.5.2 war dies nicht der Fall.

lsmod

sollte u.a. folgende Ausgabe liefern:

...
l2tp_core              12733  4 l2tp_ip6
l2tp_eth                2672  1
l2tp_ip                 4704  0
l2tp_ip6                5760  0
l2tp_netlink            6536  1 l2tp_eth
...

dann ist das Kernelmodul im Router enthalten und es kann nach Anleitung fortgefahren werden.

Folgendes am Router ausführen:

wget -P/ langhammer-mainberg.de/fff/tunneldigger.tar
cd / && tar -xf tunneldigger.tar

Jetzt einmal die Konfig erstellen:

l2tunnel conf

und starten (macht der Router beim nächsten Reboot automatisch)

/etc/init.d/tunneldigger start

man steuert das ganze mit dem Kommando l2tunnel

Viel Spass damit!

Wenn der Router neu startet, läuft fastd und tunneldigger. Alles bleibt beim alten nur dass jetzt beide Tunnel laufen.

Wie man den Tunneldigger in die Firmware einbaut, findest du hier

Am Gateway

So, jetzt brauchen wir noch Gateways mit dem Broker. Aus der Doku auf https://tunneldigger.readthedocs.org/en/latest/server.html haben wir mal die wichtigen Zeilen rausgezogen:

Voraussetzungen Nötige Pakete holen:

sudo apt-get install iproute bridge-utils libnetfilter-conntrack3 python-dev  libevent-dev ebtables python-virtualenv

Installation:

mkdir /srv/tunneldigger 
cd /srv/tunneldigger
virtualenv env_tunneldigger
cd /srv/tunneldigger
git clone https://github.com/wlanslovenija/tunneldigger.git
. env_tunneldigger/bin/activate
pip install -r tunneldigger/broker/requirements.txt

Konfiguration:

Die ersten Tests haben gezeigt, dass Batman es nicht mag, wenn Interfaces kommen und gehen. Wir können also die L2-Tunnel nicht direkt an Batman hängen. Schade, dann könnte man no_rebroadcast einschalten.

Die Slovenen schreiben:

Example hook scripts present in the scripts/ subdirectory are set up to create one bridge device per MTU and attach L2TP interfaces to these bridges. They also configure a default IP address to newly created tunnels, set up ebtables to isolate bridge ports and update the routing policy via ip rule so traffic from these interfaces is routed via the mesh routing table. Each tunnel established with the broker will create its own interface. Because we are using OLSRv1, we cannot dynamically add interfaces to it, so we group tunnel interfaces into bridges. We could put all tunnel interfaces into the same bridge, but this would actually create a performance problem. Different tunnels can have different MTU values -- but there is only one MTU value for the bridge, the minimum of all interfaces that are attached to that bridge. To avoid this problem, we create multiple bridges, one for each MTU value -- this is what the example scripts do. We also configure some ip policy rules to ensure that traffic coming in from the bridges gets routed via our mesh routing table and not the main one (see bridge_functions.sh). Traffic between bridge ports is not forwarded (this is achieved via ebtables), otherwise the routing daemons at the nodes would think that all of them are directly connected -- which would cause them to incorrectly see a very large 1-hop neighbourhood. This file also contains broker-side IP configuration for the bridge which should really be changed.

Ähnliche Probleme hatten die mit OLSR. Also haben wir mal die Config deren Vorschlägen angepasst.

Es wird für jede MTU die ankommt eine Bridge aufgemacht und da kommen dann alle Interfaces mit der gleichen MTU rein.

Beispiel-config für has und has-sued Hood auf GW von Max (fff-has 78.47.36.148)

Die l2tp_broker-xxxxx.cfg Dateien in /srv/tunneldigger/tunneldigger/broker/

l2tp_broker-has.cfg :

[broker]
; IP address the broker will listen and accept tunnels on
address=78.47.36.148
; Ports where the broker will listen on
port=20004
; Interface with that IP address
interface=eth0
; Maximum number of tunnels that will be allowed by the broker
max_tunnels=1024
; Tunnel port base
port_base=24000
; Tunnel id base
tunnel_id_base=4000
; Namespace (for running multiple brokers); note that you must also
; configure disjunct ports, and tunnel identifiers in order for
; namespacing to work
namespace=has
; check if all kernel module are loaded. Do not check for built-ins.
check_modules=true

[log]
; Log filename
filename=tunneldigger-broker.log
; Verbosity
verbosity=DEBUG
; Should IP addresses be logged or not
log_ip_addresses=false 

[hooks]
; Arguments to the session.{up,pre-down,down} hooks are as follows:
;
;    <tunnel_id> <session_id> <interface> <mtu> <endpoint_ip> <endpoint_port>  <local_port>
;
; Arguments to the session.mtu-changed hook are as follows:
;
;    <tunnel_id> <session_id> <interface> <old_mtu> <new_mtu>
; 

; Called after the tunnel interface goes up
session.up=/srv/tunneldigger/tunneldigger/broker/scripts/has.up
; Called just before the tunnel interface goes down
session.pre-down=/srv/tunneldigger/tunneldigger/broker/scripts/has.down
; Called after the tunnel interface goes down
session.down=
; Called after the tunnel MTU gets changed because of PMTU discovery
session.mtu-changed=/srv/tunneldigger/tunneldigger/broker/scripts/mtu_changed- has.sh


l2tp_broker-hassued.cfg :

[broker]
; IP address the broker will listen and accept tunnels on
address=78.47.36.148
; Ports where the broker will listen on
port=20005
; Interface with that IP address
interface=eth0
; Maximum number of tunnels that will be allowed by the broker
max_tunnels=1024
; Tunnel port base
port_base=21000
; Tunnel id base
tunnel_id_base=1000
; Namespace (for running multiple brokers); note that you must also
; configure disjunct ports, and tunnel identifiers in order for
; namespacing to work
namespace=hassued
; check if all kernel module are loaded. Do not check for built-ins.
check_modules=true 

[log]
; Log filename
filename=tunneldigger-broker.log
; Verbosity
verbosity=DEBUG
; Should IP addresses be logged or not
log_ip_addresses=false  


[hooks]
; Arguments to the session.{up,pre-down,down} hooks are as follows:
;
;    <tunnel_id> <session_id> <interface> <mtu> <endpoint_ip> <endpoint_port>  <local_port>
;
; Arguments to the session.mtu-changed hook are as follows:
;
;    <tunnel_id> <session_id> <interface> <old_mtu> <new_mtu>
; 

; Called after the tunnel interface goes up
session.up=/srv/tunneldigger/tunneldigger/broker/scripts/has-sued.up
; Called just before the tunnel interface goes down
session.pre-down=/srv/tunneldigger/tunneldigger/broker/scripts/has-sued.down
; Called after the tunnel interface goes down
session.down=
; Called after the tunnel MTU gets changed because of PMTU discovery
session.mtu-changed=/srv/tunneldigger/tunneldigger/broker/scripts/mtu_changed- has-sued.sh
 

Skripte in scripts/

bridge_functions.sh:

ensure_policy()
{
  ip rule del $*
  ip rule add $*
}

ensure_bridge()
{
  local brname="$1"
  brctl addbr $brname 2>/dev/null 

  if [[ "$?" == "0" ]]; then
    # Bridge did not exist before, we have to initialize it
    ip link set dev $brname up
    # Neue Bridge batman hinzufügen
    batctl -m $BATDEV if add $brname
    # Disable forwarding between bridge ports
    ebtables -A FORWARD --logical-in $brname -j DROP
  fi
}


has.up:

#!/bin/bash
TUNNEL_ID="$1"
INTERFACE="$3"
MTU="$4"
BATDEV=bat4

. scripts/bridge_functions.sh

# Set the interface to UP state
ip link set dev $INTERFACE up mtu $MTU

# Add the interface to our bridge
ensure_bridge l2-br-has${MTU}
brctl addif l2-br-has${MTU} $INTERFACE


has-sued.up:

#!/bin/bash
TUNNEL_ID="$1"
INTERFACE="$3"
MTU="$4"
BATDEV=bat7

. scripts/bridge_functions.sh

# Set the interface to UP state
ip link set dev $INTERFACE up mtu $MTU

# Add the interface to our bridge
ensure_bridge l2-br-sued${MTU}
brctl addif l2-br-sued${MTU} $INTERFACE


mtu_changed-has.sh

#!/bin/bash
TUNNEL_ID="$1"
INTERFACE="$3"
OLD_MTU="$4"
NEW_MTU="$5"
BATDEV=bat4

. scripts/bridge_functions.sh

# Remove interface from old bridge
brctl delif l2-br-has${OLD_MTU} $INTERFACE

# Change interface MTU
ip link set dev $INTERFACE mtu $NEW_MTU

# Add interface to new bridge
ensure_bridge l2-br-has${NEW_MTU}
brctl addif l2-br-has${NEW_MTU} $INTERFACE


mtu_changed-has-sued.sh

#!/bin/bash
TUNNEL_ID="$1"
INTERFACE="$3"
OLD_MTU="$4"
NEW_MTU="$5"
BATDEV=bat7

. scripts/bridge_functions.sh

# Remove interface from old bridge
brctl delif l2-br-sued${OLD_MTU} $INTERFACE

# Change interface MTU
ip link set dev $INTERFACE mtu $NEW_MTU

# Add interface to new bridge
ensure_bridge l2-br-sued${NEW_MTU}
brctl addif l2-br-sued${NEW_MTU} $INTERFACE


has.down

#!/bin/bash
TUNNEL_ID="$1"
INTERFACE="$3"
MTU="$4"

# Remove the interface from our bridge
brctl delif l2-br-has${MTU} $INTERFACE


has-sued.down

#!/bin/bash
TUNNEL_ID="$1"
INTERFACE="$3"
MTU="$4"

# Remove the interface from our bridge
brctl delif l2-br-sued${MTU} $INTERFACE


Start einrichten:

In /etc/systemd/system/ Units erstellen

tunneldigger-broker-has.service:

[Unit]
Description=tunneldigger tunnelling network daemon using l2tpv3
After=network.target auditd.service

[Service]
Type=simple
WorkingDirectory=/srv/tunneldigger/tunneldigger
ExecStart=/srv/tunneldigger/env_tunneldigger/bin/python -m broker.main   /srv/tunneldigger/tunneldigger/broker/l2tp_broker-has.cfg

KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target


tunneldigger-broker-has.service:

[Unit]
Description=tunneldigger tunnelling network daemon using l2tpv3
After=network.target auditd.service

[Service]
Type=simple
WorkingDirectory=/srv/tunneldigger/tunneldigger
ExecStart=/srv/tunneldigger/env_tunneldigger/bin/python -m broker.main  /srv/tunneldigger/tunneldigger/broker/l2tp_broker-has.cfg

KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target


Jetzt noch den Service anmelden, autostart und manuell Start

systemctl daemon-reload  
systemctl enable tunneldigger-broker-sued.service tunneldigger-broker-has.service
systemctl start tunneldigger-broker-sued.service tunneldigger-broker-has.service

Das kann man jetzt mehrfach machen mit unterschiedlichen Konfigurationen für verschiedene Hoods.


über "systemctl status tunneldigger-broker-xxx.service" kann man den Status erfragen.