summaryrefslogtreecommitdiff
path: root/ipmasq/rules/M80pfw.def
blob: 38e212f98577def428167ea64def3f8e59ea1190 (plain)
  1. # You should not edit this file. Instead, create a file with the same
  2. # name as this one, but with a .rul extension instead of .def. The
  3. # .rul file will override this one.
  4. #
  5. # However, any changes you make to this file will be preserved.
  6. #: Masquerade packets from internal networks
  7. if [ -n "$INTERNAL" -a -n "$EXTERNAL" -a -n "$PFW" ]; then
  8. for pool in $PFWPOOLS; do
  9. eval "PROTOS=\"\$PFWPROTO_$pool\""
  10. eval "ORIGPORTS=\"\$PFWORIGPORTS_$pool\""
  11. eval "PFWIP=\"\$PFWIP_$pool\""
  12. eval "PFWPORT=\"\$PFWPORT_$pool\""
  13. for PROTO in $PROTOS; do
  14. for ORIGPORT in $ORIGPORTS; do
  15. ORIGPORT_DASH=$(echo $ORIGPORT | sed 's/:/-/g')
  16. for j in $EXTERNAL; do
  17. ipnm_cache $j
  18. EXTIP=$IPOFIF
  19. case $MASQMETHOD in
  20. ipfwadm)
  21. ipmasqadm portfw -a -P $PROTO -L $EXTIP $ORIGPORT_DASH -R $PFWIP $PFWPORT
  22. ;;
  23. ipchains)
  24. ipmasqadm portfw -a -P $PROTO -L $EXTIP $ORIGPORT_DASH -R $PFWIP $PFWPORT
  25. ;;
  26. netfilter)
  27. $IPTABLES -A PREROUTING -t nat -p $PROTO -d $EXTIP --dport $ORIGPORT -j DNAT --to $PFWIP${PFWPORT:+:$PFWPORT}
  28. ;;
  29. esac
  30. for i in $INTERNAL; do
  31. ipnm_cache $i
  32. case $MASQMETHOD in
  33. netfilter)
  34. $IPTABLES -A FORWARD -i $j -o $i -p $PROTO --dport $ORIGPORT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
  35. # TODO: This should be done only for the interface containing the portforward host
  36. # if [ "$PORTFW_REMAP_LOCAL" = "y" ]; then
  37. # $IPTABLES -A POSTROUTING -t nat -p $PROTO -d $PFWIP ${PFWPORT:+--dport $PFWPORT} -s $IPOFIF/$NMOFIF -j SNAT --to $IPOFIF
  38. # fi
  39. ;;
  40. esac
  41. done
  42. done
  43. done
  44. done
  45. done
  46. fi