SSH Connections Lost After 1 minute idle
I have a fedora firewall/router using iptables to forward incoming SSH packets to an internal server and it works great....however, only if the user does not remain idle for 1 minute. If they idle for 1 minute, the connection "freezes" in the sense that it drops the connection but its not a proper "connectoin closed" from the server as if it is a timelimit, but rather just a connectoin loss like you've unplugged your cable in the middle of a connection.
If the user is connecting from within the network, they can remain idle for an unlimited amount of time without being disconnected. It is only ones connecting from outside hte network going through the iptables firewall that have this idle problem.
I am only allowing TCP and UDP for SSH to be forwarded.
Do I need any ICMP or any other special connection timeout rules on the iptables side to fix this problem?
Any help appreciated!
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
Quoted 6 lines · Real Cucumber
I have a fedora firewall/router using iptables to forward incoming SSH packets to an internal server and it works great....however, only if the user does not remain idle for 1 minute. If they idle for 1 minute, the connection "freezes"
Quoted 8 lines
If the user is connecting from within the network, they can remain idle for an unlimited amount of time without being disconnected. It is only ones connecting from outside hte network going through the iptables firewall that have this idle problem.
I am only allowing TCP and UDP for SSH to be forwarded.
I assume you mean TCP for SSH and TCP/UDP for DNS? (You don't need UDP for
SSH...)
Quoted 2 lines
Do I need any ICMP or any other special connection timeout rules on the iptables side to fix this problem?
You should not completely block ICMP, although I regard that as a side issue and not necessarily the cause of your problem.
It sounds like an ARP cache timeout problem to me.
Try the following test:
1. Connect from an external client to the internal SSH server.
2. Log in on the console of the SSH server (ie: not using the SSH connection) and start a ping to the firewall (I don't care whether it gets replies or not).
3. Type some command on the SSH client and check you get a response.
4. Wait >1 minute and then type another command on the SSH client and check you still get a response.
5. Cancel the ping test from the SSH server to the firewall.
6. Wait >1 minute and then type another command on the SSH client and see if the connection has died.
If the above confirms that during a ping, the connection is maintained, and in the absence of a ping, the connection dies, then it strongly suggests that the firewall is losing the MAC address of the SSH server after a period of no activity (or perhaps the SSH server loses the MAC address of the Firewall - check both arp caches with "arp -an" on each machine to find out).
It might help to post your ruleset so we can comment on anything we see that might cause this problem.
Regards,
Antony.
Signature · 6 lines
Microsoft may sell more software than any other company, but McDonald's sell
more burgers than any other company, and I think the other similarities are
obvious...
Please reply to the list;
please don't CC me.Why should ICMP not be completely blocked? The machine is used strictly as a port forwarding firewall/router.
Also it does appear to be arp related. On the fireawll the arp -a does not keep the connecting host in its cache for long. If I connect I see it, but after a few minutes it disappears. Is there anyway to fix that?
Quoted 68 lines · --- Antony Stone
Quoted 2 lines · Real Cucumber
I have a fedora firewall/router using iptables to forward incoming SSH packets to an internal server
and
Quoted 1 line
it works great....however, only if the user does
not
Quoted 1 line
remain idle for 1 minute. If they idle for 1
minute,
Quoted 4 lines
the connection "freezes"
If the user is connecting from within the network, they can remain idle for an unlimited amount of
time
Quoted 2 lines
without being disconnected. It is only ones connecting from outside hte network going through
the
Quoted 4 lines
iptables firewall that have this idle problem.
I am only allowing TCP and UDP for SSH to be forwarded.
I assume you mean TCP for SSH and TCP/UDP for DNS? (You don't need UDP for
SSH...)Quoted 2 lines
Do I need any ICMP or any other special connection timeout rules on the iptables side to fix this
problem?
You should not completely block ICMP, although I
regard that as a side issue
and not necessarily the cause of your problem.It sounds like an ARP cache timeout problem to me.
Try the following test:
1. Connect from an external client to the internal SSH server.
2. Log in on the console of the SSH server (ie: not using the SSH connection)
and start a ping to the firewall (I don't care whether it gets replies or
not).
3. Type some command on the SSH client and check you get a response.
4. Wait >1 minute and then type another command on the SSH client and check
you still get a response.
5. Cancel the ping test from the SSH server to the firewall.
6. Wait >1 minute and then type another command on the SSH client and see if
the connection has died.If the above confirms that during a ping, the connection is maintained, and in
the absence of a ping, the connection dies, then it strongly suggests that
the firewall is losing the MAC address of the SSH server after a period of no
activity (or perhaps the SSH server loses the MAC address of the Firewall -
check both arp caches with "arp -an" on each machine to find out).
Quoted 22 lines
It might help to post your ruleset so we can comment on anything we see that
might cause this problem.Regards,
Antony.
Signature · 10 lines
Microsoft may sell more software than any other company, but McDonald's sell more burgers than any other company, and I think the other similarities are obvious... Please reply to the list; please don't CC me.
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo
Quoted 2 lines · Real Cucumber
Why should ICMP not be completely blocked? The machine is used strictly as a port forwarding firewall/router.
Because blocking all ICMP will break networking. Look up the RFCs explaining
what ICMP is for if you do not understand this.
Quoted 5 lines
Also it does appear to be arp related. On the fireawll the arp -a does not keep the connecting host in its cache for long. If I connect I see it, but after a few minutes it disappears. Is there anyway to fix that?
I am not certain of the exact solution to your problem. It could be:
1. Hardware problem (NIC)
2. Due to your blocking ICMP (although I can't explain a complete reason why)
3. A strange network setup (you haven't described your physical network layout)
4. Something else ?
If you are having a problem with the arp cache on the firewall keeping the MAC address of the SSH server, can you check to see whether it successfuly retains the MAC addresses of other machines on your network?
A packet sniffer (eg: ethereal) between the firewall and the SSH server may show whether ARP requests are not being sent, or ARP reponses are not being returned.
Regards,
Antony.
Signature · 5 lines
Never automate fully anything that does not have a manual override capability.
Never design anything that cannot work under degraded conditions in emergency.
Please reply to the list;
please don't CC me.Quoted 7 lines · Antony Stone
Quoted 2 lines · Real Cucumber
Why should ICMP not be completely blocked? The machine is used strictly as a port forwarding firewall/router.
Because blocking all ICMP will break networking. Look up the RFCs explaining
what ICMP is for if you do not understand this.
I would like to second this vigorously, although I would phrase it
differently: blocking ICMP makes networks fragile. Fragile networks break easily when anything out of the ordinary happens.
--
Dick St.Peters, [email protected]
Quoted 11 lines · Dick St.Peters
Quoted 6 lines · Antony Stone
Quoted 2 lines · Real Cucumber
Why should ICMP not be completely blocked? The machine is used strictly as a port forwarding firewall/router.
Because blocking all ICMP will break networking. Look up the RFCs
explaining what ICMP is for if you do not understand this.I would like to second this vigorously, although I would phrase it
differently: blocking ICMP makes networks fragile. Fragile networks break easily when anything out of the ordinary happens.
Thank you. That is a very good way of expressing it.
I said "blocking all ICMP will break networking". That is not true... until
something starts to go wrong.
Saying that "blocking ICMP makes networks fragile, and fragile networks break easily" is much better, I think.
Although it appears that this *may* not be the problem in this particular case, I think that anything in the mailing list archive which encourages people not to block ICMP without being aware of the likely consequences is a very good thing.
Regards,
Antony.
Signature · 6 lines
Anyone that's normal doesn't really achieve much.
- Mark Blair, Australian rocket engineer
Please reply to the list;
please don't CC me.Basically I've created a port forwarding firewall with two network interfaces, that's sole purpose is to forward incoming SSH packets on one interface (WAN) through the other interface (LAN) to a local SSH server.
I've done this using IPtables and the mangle table.
It works great, except for the fact that connections are dropped if left idle for 1 minute.
I have tried allowing all ICMP for INPUT,OUTPUT,FORWARD as well as creating static ARP entries on the firewall, and nothing has helped.
If anyone knows what else may cause 1 minute idle connection timeouts , please let me know.
This connection timeout issue does not occur for LAN clients connecting to the SSH server. They can remain idle for an indefinate period of time.
Quoted 20 lines · --- "Dick St.Peters
Quoted 1 line · Antony Stone
On Tuesday 13 July 2004 9:57 pm, Real Cucumber
Quoted 2 lines · wrote:
Quoted 2 lines
Why should ICMP not be completely blocked? The
machine
Quoted 1 line
Quoted 1 line
is used strictly as a port forwarding
firewall/router.
Quoted 2 lines
Because blocking all ICMP will break networking.
Look up the RFCs explaining
Quoted 1 line
what ICMP is for if you do not understand this.
I would like to second this vigorously, although I would phrase it
differently: blocking ICMP makes networks fragile. Fragile networks
break easily when anything out of the ordinary happens.
Quoted 4 lines
--
Dick St.Peters, [email protected]
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
Quoted 7 lines · Real Cucumber
Basically I've created a port forwarding firewall with two network interfaces, that's sole purpose is to forward incoming SSH packets on one interface (WAN) through the other interface (LAN) to a local SSH server.
I've done this using IPtables and the mangle table.
Please explain how you have used the mangle table to achieve this.
The use of the mangle table is for a few fairly restricted and generally esoteric purposes, and I cannot see that your situation falls into these categories.
Regards,
Antony.
Signature · 5 lines
What makes you think I know what I'm talking about?
I just have more O'Reilly books than most people.
Please reply to the list;
please don't CC me.I'm using it for port remapping/forwarding of inbound tcp packets on port XXXX forwarded to internal server and remapped to internal port XXXX as follows:
--------
iptables -t nat -A PREROUTING -p tcp --dport
$WAN_SSH_PORT -i $WAN_INTERFACE -j DNAT --to
$INTERNAL_SERVER_IP:$INTERNAL_SERVER_SSH_PORT
----------
Quoted 23 lines · --- Antony Stone
Quoted 1 line · Real Cucumber
Basically I've created a port forwarding firewall
with
Quoted 2 lines
two network interfaces, that's sole purpose is to
forward incoming SSH packets on one interface(WAN)
Quoted 4 lines
through the other interface (LAN) to a local SSH
server.I've done this using IPtables and the mangle
table.
Please explain how you have used the mangle table to achieve this.
The use of the mangle table is for a few fairly
restricted and generally
esoteric purposes, and I cannot see that your
situation falls into these
categories.
Quoted 15 lines
Regards,
Antony.
Signature · 7 lines
What makes you think I know what I'm talking about? I just have more O'Reilly books than most people. Please reply to the list; please don't CC me.
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
Quoted 10 lines · Real Cucumber
Quoted 4 lines
Quoted 1 line
I've done this using IPtables and the mangle table.
Please explain how you have used the mangle table to achieve this.
--------
iptables -t nat -A PREROUTING -p tcp --dport
$WAN_SSH_PORT -i $WAN_INTERFACE -j DNAT --to
$INTERNAL_SERVER_IP:$INTERNAL_SERVER_SSH_PORT
----------
Oh good - you mean the nat table, not the mangle table.
That makes good sense, then.
Regards,
Antony.
Signature · 11 lines
"I don't mind that he got rich, but I do mind that he peddles himself as the
ultimate hacker and God's own gift to technology when his track record
suggests that he wouldn't know a decent design idea or a well-written hunk of
code if it bit him in the face. He's made his billions selling elaborately
sugar-coated crap that runs like a pig on [sedatives], crashes at the drop of
an electron, and has set the computing world back by at least a decade."
- Eric S Raymond, about Bill Gates
Please reply to the list;
please don't CC me.Quoted 4 lines · Real Cucumber
I have a fedora firewall/router using iptables to forward incoming SSH packets to an internal server and it works great....however, only if the user does not remain idle for 1 minute.
If you're going to use SSH through a stateful firewall, you should disable out-of-band keep-alives and enable in-connection keep-alives.
I use this in sshd_config:
# In older versions of OpenSSH, it's KeepAlive, not TCPKeepAlive TCPKeepAlive no
ClientAliveInterval 30
ClientAliveCountMax 120
See the sshd_config(5) manual page for implications.
Ciao,
Sheldon.