Linode Forum
https://forum.linode.com/

port forwarding issue?
https://forum.linode.com/viewtopic.php?f=19&t=3209
Page 1 of 1

Author:  dswartz [ Fri Apr 11, 2008 10:54 am ]
Post subject:  port forwarding issue?

Since verizon blocks port 80 inbound on their broadband connections, I thought I'd use port 80 on my linode and forward it through the openvpn tunnel to my home system. The iptables config was fairly simple (possibly too much so). I used DNAT to push packets arriving on eth0 into tun0, rewriting the destination to the private IP of the webserver at home. I also used SNAT to rewrite the source IP to the linode's tun0 IP so the return packets know where to go. Works fine (at first.) I use a webmail application which periodically refreshes the screen, and I noticed that after awhile (10 minutes or so?) there would be an error page the browser put up "Connection timed out". An attempt to connect to port 80 from an external shell account would hang. After awhile longer, it would just start working again. I don't think it's a conntrack issue, since this also happens for new connection attempts. Any ideas where to look? I can post my iptables rules if needed...

Author:  dswartz [ Mon Apr 21, 2008 3:32 pm ]
Post subject:  no ideas anyone?

This is a real bummer. I caught it doing it just now, so I did a grep for dport=80 on the linode and saw:

tcp 6 114 SYN_SENT src=A.B.C.D dst=P.Q.R.S sport=32899 dport=80 packets=2 bytes=96 [UNREPLIED] src=10.8.0.2 dst=10.8.0.1 sport=80 dport=32899 packets=0 bytes=0 mark=0 secmark=0 use=1

I don't have it in my cut&paste buffer, but on the real server (at the other end of the openvpn tunnel), the matching entry showed up as FIN_WAIT.

Update: I was running a script that connects on port 80 and then disconnects. I tried running two at the same time, and when the freeze happened, both processes were stuck, and doing cat on the conntrack pseudofile, showed two entries in SYN_SENT state. I'm mystified as to why one entry can get stuck, but even more mystified as to why this would prevent any new connections on that port.

Author:  PompeyBlue [ Thu Oct 16, 2008 5:05 pm ]
Post subject:  Re: port forwarding issue?

dswartz wrote:
I used DNAT to push packets arriving on eth0 into tun0,

How did you do that ? I've tried to set up OpenVPN on a server with apache. I want to connect using OpenVPN and then see the webserver.

I think I need to take incoming tun0 packets at route to lo, but I can't work out how to do this. IPTABLES appears to route packets but when I check the apache access_log it still shows incoming IP address as the remote client not as from the local machine.

So what you did above, sounds similar to what I need to do.

Author:  dswartz [ Thu Oct 16, 2008 5:57 pm ]
Post subject:  here you go

Code:
/sbin/iptables -t nat -I PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 10.8.0.2
/sbin/iptables -t nat -I POSTROUTING -o tun0 -p tcp --dport 80 -j SNAT --to-source 10.8.0.1

Author:  SteveG [ Fri Oct 17, 2008 1:54 pm ]
Post subject:  Re: no ideas anyone?

dswartz wrote:
Update: I was running a script that connects on port 80 and then disconnects. I tried running two at the same time, and when the freeze happened, both processes were stuck, and doing cat on the conntrack pseudofile, showed two entries in SYN_SENT state. I'm mystified as to why one entry can get stuck, but even more mystified as to why this would prevent any new connections on that port.


I don't suppose you've hard-coded the source port (32899?) in your script? Or that something else is causing the same source port to be reused? Because that would explain your symptoms. TCP identifies connections based on the source/destination address/port quadruple, and it doesn't like duplicates.

Author:  dswartz [ Fri Oct 17, 2008 2:03 pm ]
Post subject: 

No, it's just a simple DNAT iptables command. And the failure would happen after doing N connects in a row from the remote host. No idea what the problem was...

Page 1 of 1 All times are UTC-04:00
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/