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
14 config_get lanip lan ipaddr
15 config_get lanmask lan netmask
17 config_get ffip ff ipaddr
18 config_get ffmask ff netmask
20 [ -n "$ffif" ] || return 0
24 iptables -N luci_freifunk_forwarding
25 iptables -t nat -N luci_freifunk_postrouting
31 config_get_bool internal routing internal
32 [ -n "$wanif" ] && config_get_bool internet routing internet
35 ### Freifunk to Freifunk
36 [ "$internal" -gt 0 ] && {
37 iptables -A luci_freifunk_forwarding -i "$ffif" -o "$ffif" -j ACCEPT
42 eval "$(ipcalc.sh $lanip $lanmask)"
44 iptables -A luci_freifunk_forwarding -i "$lanif" -o "$ffif" -j ACCEPT
45 iptables -t nat -A luci_freifunk_postrouting -s "$NETWORK/$PREFIX" -o "$ffif" -j MASQUERADE
49 [ "$internet" -gt 0 ] && {
50 eval "$(ipcalc.sh $ffip $ffmask)"
52 iptables -A luci_freifunk_forwarding -i "$ffif" -o "$wanif" -j ACCEPT
53 iptables -t nat -A luci_freifunk_postrouting -s "$NETWORK/$PREFIX" -o "$wanif" -j MASQUERADE
56 ### Hook in the chains
57 iptables -A forwarding_rule -j luci_freifunk_forwarding
58 iptables -t nat -A postrouting_rule -j luci_freifunk_postrouting
62 ### Hook out the chains
63 iptables -D forwarding_rule -j luci_freifunk_forwarding
64 iptables -t nat -D postrouting_rule -j luci_freifunk_postrouting
67 iptables -F luci_freifunk_forwarding
68 iptables -t nat -F luci_freifunk_postrouting
71 iptables -X luci_freifunk_forwarding
72 iptables -t nat -X luci_freifunk_postrouting