Mon Feb 7 08:34:13 EST 2011

Forwarding ports using iptables

# The following if from a config file on the OpenWRT router.  Explain
# the difference: why does the 2nd rule select on -s while the first
# one selects on -d ?


plug () {
  iptables -t nat -A prerouting_rule -i $WAN -p tcp --dport $1 -j DNAT --to $2:$3
  iptables -A forwarding_rule -i $WAN -p tcp --dport $3 -d $2 -j ACCEPT

# RTP=10000:20000
# iptables -t nat -A prerouting_rule -i $WAN -p udp --dport $RTP -j DNAT --to-destination $ZOO
# iptables -A forwarding_rule -i $WAN -s $ZOO -p udp --dport $RTP -j ACCEPT