Skip to content

Instantly share code, notes, and snippets.

@boo1ean
Created July 5, 2013 13:15
Show Gist options
  • Save boo1ean/5934467 to your computer and use it in GitHub Desktop.
Save boo1ean/5934467 to your computer and use it in GitHub Desktop.
port forwarding
insert_port_forwarding() { #port, dest_ip, protocol, dest_port
local port=$1
local dest_ip=$2
local protocol=$3
local dest_port=$4
if [ -z $dest_port ]
then
dest_port=$port
fi
iptables -t nat -A PREROUTING -p $protocol -d $LIN_WAN_IP --dport $port -j DNAT --to $dest_ip:$dest_port
iptables -A FORWARD -p tcp -i ${WAN} --dport $dest_port -j FORWARD_ALLOW
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment