I am tunneling an outgoing TCP connection over a TUN interface set up by a program I wrote. The TUN interface basically just relays the packets to/from a proxy server, with minimal modifications (source/destination IP/port, TCP checksum).
Running wget on an IP routed thru this TUN interface, the packets appear to be sent and received correctly (see the trace), but somehow the SYN/ACK that comes back from the server does not register with the TCP stack, and the socket remains in a SYN_SENT state in "netstat -t". Spurious retransmits are then generated endlessly (until timeout) in both directions.
Here are the commands I use to set it up:
ip link set dev tun0 up ip addr add 10.0.0.1/24 dev tun0 ip route add 18.104.22.168/32 dev tun0
Here is the wireshark trace pcap here: