summaryrefslogtreecommitdiff
path: root/ipmasq/rules/M80pfw.def
blob: b3792ac33389814ed3a06d372fc8a980dfd6fae6 (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_IN" -a -n "$PFW" ]; then
  8. if [ -n "$EXTERNAL_IN" -a -n "$PFW" ]; then
  9. for pool in $PFWPOOLS; do
  10. eval "PROTOS=\"\$PFWPROTO_$pool\""
  11. eval "ORIGPORTS=\"\$PFWORIGPORTS_$pool\""
  12. eval "PFWIP=\"\$PFWIP_$pool\""
  13. eval "PFWPORT=\"\$PFWPORT_$pool\""
  14. for PROTO in $PROTOS; do
  15. for ORIGPORT in $ORIGPORTS; do
  16. ORIGPORT_DASH=$(echo $ORIGPORT | sed 's/:/-/g')
  17. for j in $EXTERNAL_IN; do
  18. ipnm_cache $j
  19. EXTIP=$IPOFIF
  20. case $MASQMETHOD in
  21. ipfwadm)
  22. ipmasqadm portfw -a -P $PROTO -L $EXTIP $ORIGPORT_DASH -R $PFWIP $PFWPORT
  23. ;;
  24. ipchains)
  25. ipmasqadm portfw -a -P $PROTO -L $EXTIP $ORIGPORT_DASH -R $PFWIP $PFWPORT
  26. ;;
  27. netfilter)
  28. $IPTABLES -A PREROUTING -t nat -p $PROTO -d $EXTIP --dport $ORIGPORT -j DNAT --to $PFWIP${PFWPORT:+:$PFWPORT}
  29. ;;
  30. esac
  31. for i in $INTERNAL; do
  32. ipnm_cache $i
  33. case $MASQMETHOD in
  34. netfilter)
  35. $IPTABLES -A FORWARD -i $j -o $i -p $PROTO --dport $ORIGPORT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
  36. # TODO: This should be done only for the interface containing the portforward host
  37. # if [ "$PORTFW_REMAP_LOCAL" = "y" ]; then
  38. # $IPTABLES -A POSTROUTING -t nat -p $PROTO -d $PFWIP ${PFWPORT:+--dport $PFWPORT} -s $IPOFIF/$NMOFIF -j SNAT --to $IPOFIF
  39. # fi
  40. ;;
  41. esac
  42. done
  43. done
  44. done
  45. done
  46. done
  47. fi