/[sysadmin-cookbook]/recepies/iptables/iptables-tcp-proxy.sh
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /recepies/iptables/iptables-tcp-proxy.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 289 - (show annotations)
Thu Feb 9 20:18:26 2012 UTC (12 years, 2 months ago) by dpavlin
File MIME type: application/x-sh
File size: 519 byte(s)
create TCP proxy unsing only iptables
1 #!/bin/sh
2
3 # http://www.debian-administration.org/articles/595
4
5 test -z "$1" -o -z "$2" -o -z "$3" -o -z "$4" && echo "$0 LOCAL_IP LOCAL_PORT REMOTE_IP REMOTE_PORT" && exit 1
6
7 IPTABLES=/sbin/iptables
8
9 echo 'echo 1 > /proc/sys/net/ipv4/ip_forward'
10
11 echo $IPTABLES -t nat -A PREROUTING --dst $1 -p tcp --dport $2 -j DNAT --to-destination $3:$4
12 echo $IPTABLES -t nat -A POSTROUTING --dst $3 -p tcp --dport $4 -j SNAT --to-source $1
13 echo $IPTABLES -t nat -A OUTPUT --dst $1 -p tcp --dport $2 -j DNAT --to-destination $3:$4

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26