I've run into a bit of a puzzle and haven't had much luck finding a solution. Right now I am (sadly) connected to the net via Verizon 3G. They filter all incoming traffic so it is impossible for me to open ports to accept connections.
I currently have a Linux virtual machine at linode.com, and the thought crossed my mind to install pptpd
and attempt to do some iptables
port forwarding. I have pptpd
installed and my home machine connects happily. That said, here's some general info:
Server (Debian) WAN IP: x.x.x.x on eth0 - pptpd IP: y.y.y.1 on ppp0 - Client VPN IP: y.y.y.100
To verify I wasn't going insane, I attempted some connections from the server to the open ports on the client, and the client does accept the connections via the VPN IP.
What I want to accomplish is this:
Internet -> WAN IP:Port -> Forward to Client VPN IP:Port
So for instance, if I had port 6000 open on my client, a person could telnet in to x.x.x.x:6000, and the server would catch that and forward it to 192.168.3.100:6000.
I have tried at least 20 different Googled up iptables
configs and none have worked yet. Does anyone have any ideas, or perhaps even a totally different approach I might not be aware of? The goal here is to listen through a horribly firewalled connection, preferably both TCP and UDP traffic.
Thanks for the response. I already had ip_forwarding on, and your rules worked perfectly, although not initially. The issue was (in my iptables noobness) that I didn't realize iptables -F didn't flush the nat entries, and iptables -L wasn't listing them. After figuring out how to properly list them I noticed several conflicting entries from tries before. After flushing and trying your rules, it works perfectly.
One quick question though, in your rules you specify tcp. Would changing this to "all" work for both TCP/UDP traffic?
– Vile Brigandier Nov 15 '12 at 22:24iptables-save
to show my iptables rules - while the output isn't intended for human consumption it's still readable and shows all your iptables rules.) No, unfortunately you can't use "all" there, because--dport
only works with protocols that actually have ports ("all" would include e.g. ICMP, which has no notion of ports). You'll need separate rules for TCP and UDP. – AGWA Nov 15 '12 at 22:42