1 #!/bin/sh /etc/rc.common
9 ### Read interface names
10 config_get wanif wan ifname
11 config_get lanif lan ifname
12 config_get ffif ff ifname
13 config_get ffdif ffdhcp ifname
15 config_get lanip lan ipaddr
16 config_get lanmask lan netmask
18 config_get ffip ff ipaddr
19 config_get ffmask ff netmask
21 config_get ffdip ffdhcp ipaddr
22 config_get ffdmask ffdhcp netmask
24 [ -n "$ffif" ] ||
return 0
28 iptables
-N luci_freifunk_forwarding
29 iptables
-t nat
-N luci_freifunk_postrouting
35 config_get_bool internal routing internal
36 [ -n "$wanif" ] && config_get_bool internet routing internet
39 ### Freifunk to Freifunk
40 [ "$internal" -gt 0 ] && {
41 iptables
-A luci_freifunk_forwarding
-i "$ffif" -o "$ffif" -j ACCEPT
44 ### Freifunk DHCP to Freifunk
45 [ "$internal" -gt 0 -a -n "$ffdif" ] && {
46 eval "$(ipcalc.sh $ffdip $ffdmask)"
48 iptables
-t nat
-A luci_freifunk_postrouting
-s "$NETWORK/$PREFIX" -o "$ffif" -j MASQUERADE
53 eval "$(ipcalc.sh $lanip $lanmask)"
55 iptables
-A luci_freifunk_forwarding
-i "$lanif" -o "$ffif" -j ACCEPT
56 iptables
-t nat
-A luci_freifunk_postrouting
-s "$NETWORK/$PREFIX" -o "$ffif" -j MASQUERADE
60 [ "$internet" -gt 0 ] && {
61 eval "$(ipcalc.sh $ffip $ffmask)"
63 iptables
-A luci_freifunk_forwarding
-i "$ffif" -o "$wanif" -j ACCEPT
64 iptables
-t nat
-A luci_freifunk_postrouting
-s "$NETWORK/$PREFIX" -o "$wanif" -j MASQUERADE
67 ### Freifunk DHCP to Wan
68 [ "$internet" -gt 0 -a -n "$ffdif" ] && {
69 eval "$(ipcalc.sh $ffdip $ffdmask)"
71 iptables
-t nat
-A luci_freifunk_postrouting
-s "$NETWORK/$PREFIX" -o "$wanif" -j MASQUERADE
74 ### Hook in the chains
75 iptables
-A forwarding_rule
-j luci_freifunk_forwarding
76 iptables
-t nat
-A postrouting_rule
-j luci_freifunk_postrouting
80 ### Hook out the chains
81 iptables
-D forwarding_rule
-j luci_freifunk_forwarding
82 iptables
-t nat
-D postrouting_rule
-j luci_freifunk_postrouting
85 iptables
-F luci_freifunk_forwarding
86 iptables
-t nat
-F luci_freifunk_postrouting
89 iptables
-X luci_freifunk_forwarding
90 iptables
-t nat
-X luci_freifunk_postrouting