* Corrected Freifunk NAT rules
[project/luci.git] / module / admin-core / contrib / init.d / luci_freifunk
index dbb346f..6b18e14 100644 (file)
@@ -29,14 +29,24 @@ start() {
        
        ### Lan to Freifunk     
        [ -n "$lanif" ] && {
+               config_get ipaddr lan ipaddr
+               config_get netmask lan netmask
+               
+               eval "$(ipcalc.sh $ipaddr $netmask)"
+               
                iptables -A forwarding_rule -i "$lanif" -o "$ffif" -j ACCEPT
-               iptables -t nat -A postrouting_rule -i "$lanif" -o "$ffif" -j MASQUERADE
+               iptables -t nat -A postrouting_rule -s "$NETWORK/$PREFIX" -o "$ffif" -j MASQUERADE
        }
        
        ### Freifunk to Wan
        [ "$internet" -gt 0 ] && {
+               config_get ipaddr ff ipaddr
+               config_get netmask ff netmask
+               
+               eval "$(ipcalc.sh $ipaddr $netmask)"            
+               
                iptables -A forwarding_rule -i "$ffif" -o "$wanif" -j ACCEPT
-               iptables -t nat -A postrouting_rule -i "$ffif" -o "$wanif" -j MASQUERADE
+               iptables -t nat -A postrouting_rule -s "$NETWORK/$PREFIX" -o "$wanif" -j MASQUERADE
        }
 }