summaryrefslogtreecommitdiffhomepage
path: root/modules/freifunk/root
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-05-08 16:04:18 +0000
committerSteven Barth <steven@midlink.org>2008-05-08 16:04:18 +0000
commit214bfdc19887c3df373d1323afd9738eee4f64ca (patch)
tree1b3660fd9a8db552d50c9ef9d11b9dee35bf8fac /modules/freifunk/root
parentaa9ccf77c6648515ba58c37b9345cdbd561028db (diff)
* Fixed #2030
Diffstat (limited to 'modules/freifunk/root')
-rw-r--r--modules/freifunk/root/etc/config/freifunk25
-rw-r--r--modules/freifunk/root/etc/init.d/luci_freifunk91
2 files changed, 116 insertions, 0 deletions
diff --git a/modules/freifunk/root/etc/config/freifunk b/modules/freifunk/root/etc/config/freifunk
new file mode 100644
index 000000000..01b83f2c7
--- /dev/null
+++ b/modules/freifunk/root/etc/config/freifunk
@@ -0,0 +1,25 @@
+config public contact
+ option nickname
+ option name
+ option mail
+ option phone
+ option location
+ option geo
+ option note
+
+config public community
+ option name "Freifunk Halle"
+ option homepage http://halle.freifunk.net
+ option essid halle.freifunk.net
+ option bssid 02:CA:FF:EE:BA:BE
+ option realm netz.freifunk-halle.net
+ option channel 1
+ option net 104.0.0.0
+ option mask 255.0.0.0
+ option dhcp 10.0.0.0
+ option dhcpmask 255.255.255.0
+ option dns "88.198.178.18 141.54.1.1 212.204.49.83 208.67.220.220 208.67.222.222"
+
+config settings routing
+ option internal 0
+ option internet 0
diff --git a/modules/freifunk/root/etc/init.d/luci_freifunk b/modules/freifunk/root/etc/init.d/luci_freifunk
new file mode 100644
index 000000000..38779cb8b
--- /dev/null
+++ b/modules/freifunk/root/etc/init.d/luci_freifunk
@@ -0,0 +1,91 @@
+#!/bin/sh /etc/rc.common
+START=70
+
+start() {
+ include /lib/network
+ scan_interfaces
+
+
+ ### Read interface names
+ config_get wanif wan ifname
+ config_get lanif lan ifname
+ config_get ffif ff ifname
+ config_get ffdif ffdhcp ifname
+
+ config_get lanip lan ipaddr
+ config_get lanmask lan netmask
+
+ config_get ffip ff ipaddr
+ config_get ffmask ff netmask
+
+ config_get ffdip ffdhcp ipaddr
+ config_get ffdmask ffdhcp netmask
+
+ [ -n "$ffif" ] || return 0
+
+
+ ### Creating chains
+ iptables -N luci_freifunk_forwarding
+ iptables -t nat -N luci_freifunk_postrouting
+
+
+ ### Read from config
+ config_load freifunk
+
+ config_get_bool internal routing internal
+ [ -n "$wanif" ] && config_get_bool internet routing internet
+
+
+ ### Freifunk to Freifunk
+ [ "$internal" -gt 0 ] && {
+ iptables -A luci_freifunk_forwarding -i "$ffif" -o "$ffif" -j ACCEPT
+ }
+
+ ### Freifunk DHCP to Freifunk
+ [ "$internal" -gt 0 -a -n "$ffdif" ] && {
+ eval "$(ipcalc.sh $ffdip $ffdmask)"
+
+ iptables -t nat -A luci_freifunk_postrouting -s "$NETWORK/$PREFIX" -o "$ffif" -j MASQUERADE
+ }
+
+ ### Lan to Freifunk
+ [ -n "$lanif" ] && {
+ eval "$(ipcalc.sh $lanip $lanmask)"
+
+ iptables -A luci_freifunk_forwarding -i "$lanif" -o "$ffif" -j ACCEPT
+ iptables -t nat -A luci_freifunk_postrouting -s "$NETWORK/$PREFIX" -o "$ffif" -j MASQUERADE
+ }
+
+ ### Freifunk to Wan
+ [ "$internet" -gt 0 ] && {
+ eval "$(ipcalc.sh $ffip $ffmask)"
+
+ iptables -A luci_freifunk_forwarding -i "$ffif" -o "$wanif" -j ACCEPT
+ iptables -t nat -A luci_freifunk_postrouting -s "$NETWORK/$PREFIX" -o "$wanif" -j MASQUERADE
+ }
+
+ ### Freifunk DHCP to Wan
+ [ "$internet" -gt 0 -a -n "$ffdif" ] && {
+ eval "$(ipcalc.sh $ffdip $ffdmask)"
+
+ iptables -t nat -A luci_freifunk_postrouting -s "$NETWORK/$PREFIX" -o "$wanif" -j MASQUERADE
+ }
+
+ ### Hook in the chains
+ iptables -A forwarding_rule -j luci_freifunk_forwarding
+ iptables -t nat -A postrouting_rule -j luci_freifunk_postrouting
+}
+
+stop() {
+ ### Hook out the chains
+ iptables -D forwarding_rule -j luci_freifunk_forwarding
+ iptables -t nat -D postrouting_rule -j luci_freifunk_postrouting
+
+ ### Clear the chains
+ iptables -F luci_freifunk_forwarding
+ iptables -t nat -F luci_freifunk_postrouting
+
+ ### Delete chains
+ iptables -X luci_freifunk_forwarding
+ iptables -t nat -X luci_freifunk_postrouting
+}