title: Is there a way for Linux to log the reason of sending out a TCP RST packet?
body: <p>Running this version of kernel <code>4.11.8-1.el6.elrepo.x86_64</code> and want to know why the TCP stack sends some RST packets,  i.e. is there a Linux counterpart of the BSD <code>net.inet.tcp.log_debug=1</code>?</p>
  
  <p>Following is one of the cases where the reason is wanted. A RST is sent immediately after the finally arrived ACK of the handshake.  It can be seen that SYN got lost for several times and the last ACK did not arrive in more that 1s.  But it is still not clear why the RST is sent.  Disabling syn cookie does not help.</p>
  
  <pre><code>15:27:41.166799 IP CLIENT.16537 &gt; SERVER.80: Flags [S], seq 1397492268, win 29200, options [mss 1440,sackOK,TS val 1230199 ecr 0,nop,wscale 6], length 0
  15:27:41.166820 IP SERVER.80 &gt; CLIENT.16537: Flags [S.], seq 1773519351, ack 1397492269, win 29200, options [mss 1460,nop,nop,sackOK,nop,wscale 9], length 0
  15:27:42.069572 IP CLIENT.16537 &gt; SERVER.80: Flags [S], seq 1397492268, win 29200, options [mss 1460,sackOK,TS val 1230299 ecr 0,nop,wscale 6], length 0
  15:27:42.069590 IP SERVER.80 &gt; CLIENT.16537: Flags [S.], seq 1773519351, ack 1397492269, win 29200, options [mss 1460,nop,nop,sackOK,nop,wscale 9], length 0
  15:27:43.123141 IP SERVER.80 &gt; CLIENT.16537: Flags [S.], seq 1773519351, ack 1397492269, win 29200, options [mss 1460,nop,nop,sackOK,nop,wscale 9], length 0
  15:27:44.067228 IP CLIENT.16537 &gt; SERVER.80: Flags [S], seq 1397492268, win 29200, options [mss 1460,sackOK,TS val 1230499 ecr 0,nop,wscale
   6], length 0
  15:27:44.067240 IP SERVER.80 &gt; CLIENT.16537: Flags [S.], seq 1773519351, ack 1397492269, win 29200, options [mss 1460,nop,nop,sackOK,nop,wscale 9], length 0
  15:27:46.547072 IP CLIENT.16537 &gt; SERVER.80: Flags [.], ack 1, win 457, length 0
  15:27:46.547094 IP SERVER.80 &gt; CLIENT.16537: Flags [R], seq 1773519352, win 0, length 0
  15:27:46.548177 IP CLIENT.16537 &gt; SERVER.80: Flags [.], ack 1, win 457, options [nop,nop,sack 1 {0:1}], length 0
  15:27:46.548186 IP SERVER.80 &gt; ClIENT.16537: Flags [R], seq 1773519352, win 0, length 0
  </code></pre>
  
  <p>Thanks for helping.</p>