How to verify TCP keep alive on Linux

ε祈祈猫儿з 提交于 2019-12-11 09:16:12

问题


I want to set tcp keep alive on my linux machine. So what I am doing is running a script

if [ `/sbin/sysctl -n net.ipv4.tcp_keepalive_time` != 200 ] ; then
   /sbin/sysctl -w net.ipv4.tcp_keepalive_time=200;

But I still have issues with connections to amazon's redshift. Can someone please help and show me how I can check if tcp keep alive is actually set or not?


回答1:


To check if keep alive is active open a connection, don't exchange any data and verify with tcpdump or similar that packets gets regularly exchanged on the connection, even if no real data get exchanged.

But maybe you just confuse keep-alive with timeout:

  • Keep alive: detect if the connection is still active, e.g. that data could be exchanged if necessary. This will detect loss of network connectivity etc. Keep alive is done on the TCP layer.
  • Timeout: connections gets closed after some inactivity. This is done at the application layer.

In both cases you will not detect the problem until you try to read or write on the socket.



来源:https://stackoverflow.com/questions/24428598/how-to-verify-tcp-keep-alive-on-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!