3 # Konfiguriere uebliche Opennet-Interfaces sowie ein lokales Interface.
5 # Dieses Skript wird nur ein einziges Mal nach einem Upgrade oder der Erstinstallation ausgefuehrt:
6 # http://wiki.openwrt.org/doc/uci#defaults
10 .
"${IPKG_INSTROOT:-}/usr/lib/opennet/on-helper.sh"
13 OPENWRT_DEFAULT_LOCAL_IP=192.168.1.1
16 configure_local_network() {
17 local uci_prefix=
"network.$NETWORK_LOCAL"
18 # wurde die Standard-IP bereits veraendert?
19 [
"$(uci_get "${uci_prefix}.ipaddr
")" !=
"$OPENWRT_DEFAULT_LOCAL_IP" ] &&
return 0
20 uci set
"${uci_prefix}.ipaddr=$(get_on_core_default lan_ipaddr)"
21 uci set
"${uci_prefix}.netmask=$(get_on_core_default lan_netmask)"
25 configure_opennet_zone() {
27 # Forwarding (die letzte Aktion dieses Ablaufs) existiert? Keine Aenderungen ...
28 [ -n
"$(find_first_uci_section "firewall
" "forwarding
" "src=$ZONE_MESH
" "dest=$ZONE_MESH
")" ] &&
return 0
29 uci_prefix=$(find_first_uci_section
"firewall" "zone" "name=$ZONE_MESH")
30 # Zone anlegen, falls leer
31 [ -z
"$uci_prefix" ] && uci_prefix=firewall.$(uci add firewall zone)
32 uci set
"$uci_prefix=zone"
33 uci set
"$uci_prefix.name=$ZONE_MESH"
34 # Opennet-APs bieten ueblicherweise keine privaten Dienste an
35 uci set
"$uci_prefix.input=ACCEPT"
36 # ausgehende Pakete sind OK
37 uci set
"$uci_prefix.output=ACCEPT"
38 # Verkehr aus dem opennet-Netz darf nicht in lokale oder tunnel-Netze
39 uci set
"$uci_prefix.forward=REJECT"
40 # via "masq_src" ersetzen wir die ehemalige "/etc/firewall.opennet" fuer Quell-basiertes Masquerading
41 add_zone_forward
"$ZONE_LOCAL" "$ZONE_MESH"
42 update_opennet_zone_masquerading
43 # intra-Zone-Verkehr muss explizit erlaubt werden
44 add_zone_forward
"$ZONE_MESH" "$ZONE_MESH"
48 configure_olsr_radio() {
49 trap
"error_trap configure_olsr_radio '$*'" $GUARD_TRAPS
51 local iface_logical=$2
54 local uci_wifi=wireless.@wifi-iface[$iface_index]
55 local uci_radio=wireless.$(uci_get
"${uci_wifi}.device")
58 radio_hwmode=$(uci_get
"${uci_radio}.hwmode")
59 bssid=$(get_on_core_default wifi_bssid)
61 uci set
"${uci_wifi}.network=$iface_logical"
62 uci set
"${uci_wifi}.ifname=$iface_phys"
64 uci set
"wireless.radio${iface_index}.country=$(get_on_core_default wifi_country)"
65 uci_delete "wireless.radio${iface_index}.disabled"
67 # typ-spezifische Attribute
68 if echo
"$radio_hwmode" | grep -q
"a"; then
69 # 5 GHz: kein Mesh-Modus verfuegbar
70 uci set
"${uci_wifi}.ssid=$(get_on_core_default wifi_ssid_5ghz)"
71 uci set
"${uci_wifi}.mode=$(get_on_core_default wifi_mode_5ghz)"
72 uci set
"${uci_radio}.channel=$(get_on_core_default wifi_channel_5ghz)"
73 uci set
"${uci_wifi}.isolate=1"
75 # 2,4 GHz: Ad-hoc-Modus
76 uci set
"${uci_wifi}.ssid=$(get_on_core_default wifi_ssid)"
77 uci set
"${uci_wifi}.mode=$(get_on_core_default wifi_mode)"
78 [ -n
"$bssid" ] && uci set
"${uci_wifi}.bssid=$bssid"
79 uci set
"${uci_radio}.channel=$(get_on_core_default wifi_channel)"
85 configure_olsr_single_interface() {
86 trap
"error_trap configure_olsr_single_interface '$*'" $GUARD_TRAPS
87 local iface_logical=$1
89 local iface_netmask=$3
93 uci set
"network.${iface_logical}=interface"
94 uci set
"network.${iface_logical}.proto=static"
95 uci set
"network.${iface_logical}.ifname=$iface_phys"
96 uci set
"network.${iface_logical}.netmask=$iface_netmask"
97 uci set
"network.${iface_logical}.defaultroute=0"
98 uci set
"network.${iface_logical}.peerdns=0"
99 uci set
"network.${iface_logical}.ipaddr=$iface_addr"
101 # disable dhcp on on_wifi
102 uci set
"dhcp.${iface_logical}=dhcp"
103 uci set
"dhcp.${iface_logical}.interface=${iface_logical}"
104 uci set
"dhcp.${iface_logical}.dynamicdhcp=0"
105 uci set
"dhcp.${iface_logical}.ignore=1"
109 configure_olsr_interfaces() {
110 trap
"error_trap configure_olsr_interfaces '$*'" $GUARD_TRAPS
112 # diese Aktion ist bereits abgeschlossen
113 uci -q show
"network" | grep -q
"^network\.on_eth_0\." &&
return 0
118 on_id=$(uci_get on-core.settings.on_id
"$(get_on_core_default on_id_preset)")
119 on_ipschema=$(get_on_core_default on_ipschema)
120 on_netmask=$(get_on_core_default on_netmask)
125 # Suche nach WLAN-Interfaces
126 /sbin/wifi detect > /etc/config/wireless
129 while [ -n
"$(uci_get "wireless.@wifi-iface[${iface_index}]
")" ];
do
130 on_ipaddr=$(get_on_ip
"$on_id" "$on_ipschema" "$iface_index")
131 iface_phys=wlan$iface_index
132 iface_logical=on_wifi_$iface_index
134 configure_olsr_single_interface
"$iface_logical" "$on_ipaddr" "$on_netmask" "$iface_phys"
135 configure_olsr_radio
"$iface_index" "$iface_logical" "$iface_phys"
142 on_ipaddr=$(get_on_ip
"$on_id" "$on_ipschema" "$iface_index")
144 iface_logical=on_eth_0
145 configure_olsr_single_interface
"$iface_logical" "$on_ipaddr" "$on_netmask" "$iface_phys"
150 # jede Funktion sollte selbst pruefen, ob ihre Aktion bereits abgeschlossen ist
151 configure_local_network
152 configure_opennet_zone
153 configure_olsr_interfaces
155 apply_changes network wireless dhcp firewall
uci_delete(uci_path)
Lösche ein UCI-Element.
add_interface_to_zone()
Fuege ein logisches Netzwerk-Interface zu einer Firewall-Zone hinzu.