WRT54GL (Tomato) drops active connections with TCP RST

Discussion in 'Networking Issues' started by Rumpsteak, Jan 18, 2012.

  1. Rumpsteak

    Rumpsteak Networkin' Nut Member

    I have a WRT54GL with Tomato 1.25 set up at another site. I've been noticing for a while that TCP connections drop occasionally. This is especially disturbing since I have ssh tunnels open through the router, some with an sshfs running inside them.

    I initially believed to be a timout problem, but I recently noticed it occurs also to very active connections, as e.g. during a backup a synchronization I performed recently.

    Using wireshark on my client, I could see that the router suddenly sends a TCP RST packet during a conversation, immediately terminating the connection. The connection can stay open and work fine for anything from 15 minutes to 12 hours before receiving the RST packet.

    I next ran tcpdump on the router to find out more. At least it shows that the RST packets really originate from the router not from anything in between. It also appears that the server application (e.g. ssh daemon on the router itself, or other server application inside the network) doesn't know that the connection has been closed since they keep trying to retransmit the packets, but those packets never reach the client since the RST packet has already been sent.

    I don't know all the reasons that could cause a RST packet to be sent, but I speculate that it is the response to attempting to access a connection that the router sees as closed. So, it appears that the router for some reason has decided to drop the connection in an abrupt way.

    Some notes:
    - If several connections are opened, they will not be dropped simultaneously
    but independently.
    - It appears to be independent on the connection throughput. It happens
    both on extremely active and extremely inactive connections.
    - It is not SSH protocol/application specific. The same behavior is
    observed on e.g. pptp (port 1723) and I guess it would occur on any TCP port.
    - I use port 443 for ssh to get through the proxy at work.

    I suspect the problem might have something to do with conntrack since even my ssh connections to the server itself go through DNAT according to iptables ( ->

    Has anyone observed this behavior or have an idea? Any help is highly appreciated!

    /etc/iptables (Ext IP address replaced with
    :OUTPUT ACCEPT [0:0]

    :OUTPUT ACCEPT [0:0]
    -A PREROUTING -i vlan1 -d -j DROP
    -A PREROUTING -p icmp -d -j DNAT --to-destination

    -A PREROUTING -p tcp -m tcp -d --dport 443 -j DNAT --to-destination

    -A PREROUTING -p tcp -d --dport 10080 -j DNAT --to-destination
    -A POSTROUTING -p tcp --dport 80 -s -d -j SNAT --to-source

    -A PREROUTING -p tcp -d --dport 5006 -j DNAT --to-destination
    -A POSTROUTING -p tcp --dport 5006 -s -d -j SNAT --to-source

    -A PREROUTING -p tcp -d --dport 5001 -j DNAT --to-destination
    -A POSTROUTING -p tcp --dport 5001 -s -d -j SNAT --to-source

    -A PREROUTING -p tcp -d --dport 1723 -j DNAT --to-destination
    -A POSTROUTING -p tcp --dport 1723 -s -d -j SNAT --to-source
    -A PREROUTING -p udp -d --dport 1723 -j DNAT --to-destination
    -A POSTROUTING -p udp --dport 1723 -s -d -j SNAT --to-source
    :upnp - [0:0]
    -A PREROUTING -d -j upnp

    :INPUT DROP [0:0]
    :OUTPUT ACCEPT [0:0]
    -A INPUT -i br0 -d -j DROP
    -A INPUT -m state --state INVALID -j DROP
    -A INPUT -i br0 -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -A INPUT -p tcp -m tcp -d --dport 22 -j ACCEPT
    :FORWARD DROP [0:0]
    -A FORWARD -i br0 -o br0 -j ACCEPT
    -A FORWARD -m state --state INVALID -j DROP
    -A FORWARD -p tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1461: -j TCPMSS --set-mss 1460
    :wanin - [0:0]
    :wanout - [0:0]
    -A FORWARD -i vlan1 -j wanin
    -A FORWARD -o vlan1 -j wanout
    -A FORWARD -i br0 -j ACCEPT
    :upnp - [0:0]
    -A FORWARD -i vlan1 -j upnp
    -A wanin -p tcp -m tcp -d --dport 80 -j ACCEPT
    -A wanin -p tcp -m tcp -d --dport 5006 -j ACCEPT
    -A wanin -p tcp -m tcp -d --dport 5001 -j ACCEPT
    -A wanin -p tcp -m tcp -d --dport 1723 -j ACCEPT
    -A wanin -p udp -m udp -d --dport 1723 -j ACCEPT
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice