Opennet Firmware
 Alle Dateien Funktionen Variablen Gruppen Seiten
init/on-openvpn
gehe zur Dokumentation dieser Datei
1 #!/bin/sh
2 
3 
4 . "${IPKG_INSTROOT:-}/usr/lib/opennet/on-helper.sh"
5 
6 
7 configure_tunnel_network() {
8  local uci_prefix=network.on_vpn
9 
10  # Abbruch falls das Netzwerk schon vorhanden ist
11  [ -n "$(uci_get "$uci_prefix")" ] && return
12 
13  # add new network to configuration (to be recognized by olsrd)
14  uci set "${uci_prefix}=interface"
15  uci set "${uci_prefix}.proto=none"
16  uci set "${uci_prefix}.ifname=tun0"
17 
18  apply_changes network
19 }
20 
21 
22 configure_tunnel_firewall() {
23  local uci_prefix
24  uci_prefix=$(find_first_uci_section firewall zone "name=$ZONE_TUNNEL")
25 
26  # Abbruch falls die Zone bereits vorhanden ist
27  [ -n "$(uci_get "$uci_prefix")" ] && return
28 
29  # Zone fuer ausgehenden Verkehr definieren
30  uci_prefix=firewall.$(uci add firewall zone)
31  uci set "${uci_prefix}.name=$ZONE_TUNNEL"
32  uci add_list "${uci_prefix}.network=$NETWORK_TUNNEL"
33  uci set "${uci_prefix}.forward=REJECT"
34  uci set "${uci_prefix}.input=REJECT"
35  uci set "${uci_prefix}.output=ACCEPT"
36  uci set "${uci_prefix}.masq=1"
37 
38  # Weiterleitung aus dem lokalen Netzwerk heraus erlauben
39  uci_prefix=firewall.$(uci add firewall forwarding)
40  uci set "${uci_prefix}.src=$ZONE_LOCAL"
41  uci set "${uci_prefix}.dest=$ZONE_TUNNEL"
42 
43  apply_changes firewall
44 }
45 
46 
47 configure_tunnel_network
48 configure_tunnel_firewall