TCP connection timeout problem
Hello all,
I'm the author of "Arno's Iptables Firewall" (maybe you know). Anyway, I've been experiencing a problem for quite some time know. The problem is that it seems that in once in a while a connection is no longer considered ESTABLISHED by netfilter/iptables, causing the packets to bounce of the firewall like this:
Jul 5 18:02:16 rulhm2 kernel: Stealth scan (UNPRIV)?: IN=eth0 OUT= MAC=00:01:02:05:1d:25:00:10:dc:d4:a2:bc:08:00 SRC=x.x.x.x DST=x.x.x.x LEN=41 TOS=0x00 PREC=0x00 TTL=128 ID=26688 DF PROTO=TCP SPT=445 DPT=53205 WINDOW=17053 RES=0x00 ACK URGP=0
In this case it's a connection for used by Samba (port 445). As you can see an TCP packets with the ACK-flag set is bounced of as it's (no longer) catched by my (iptables) ESTABLISHED-rule. This happens for a variety of flag-combinations (like RST, FIN, ACK/FIN etc.). Is there any way I can fix this "nicely", as until know I've always "worked around" this issue with using some general iptables rules which simply drop(ignore) these kind of packets. I'm thinking of some kernel settings (/proc / sysctl) that one might "tweak"....
Thanks for any info anyone can provide....
Signature · 13 lines
Ing. A.C.J. van Amersfoort (Arno) Department Of Electronics (ELD, k1007) Huygens Laboratory Leiden University P.O. Box 9504 Niels Bohrweg 2 2333 CA Leiden The Netherlands ---------------------------------------------------------------- Phone : +31-(0)71-527.1894 Fax: +31-(0)71-527.5819 E-mail: [email protected] ---------------------------------------------------------------- Arno's (Linux firewall) homepage: http://rocky.eld.leidenuniv.nl
Quoted 10 lines · Arno van Amersfoort
I'm the author of "Arno's Iptables Firewall" (maybe you know). Anyway, I've been experiencing a problem for quite some time know. The problem is that it seems that in once in a while a connection is no longer considered ESTABLISHED by netfilter/iptables, causing the packets to bounce of the firewall like this:
Jul 5 18:02:16 rulhm2 kernel: Stealth scan (UNPRIV)?: IN=eth0 OUT=MAC=00:01:02:05:1d:25:00:10:dc:d4:a2:bc:08:00 SRC=x.x.x.x DST=x.x.x.x LEN=41 TOS=0x00 PREC=0x00 TTL=128 ID=26688 DF PROTO=TCP SPT=445 DPT=53205 WINDOW=17053 RES=0x00 ACK URGP=0
Quoted 8 lines
In this case it's a connection for used by Samba (port 445). As you can see an TCP packets with the ACK-flag set is bounced of as it's (no longer) catched by my (iptables) ESTABLISHED-rule. This happens for a variety of flag-combinations (like RST, FIN, ACK/FIN etc.). Is there any way I can fix this "nicely", as until know I've always "worked around" this issue with using some general iptables rules which simply drop(ignore) these kind of packets. I'm thinking of some kernel settings (/proc / sysctl) that one might "tweak"....
Without knowing which kernel version (and pom-ng patches) are you running, one cannot really help.
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary
Here is some additional information:
I'm currently running a vanilla kernel 2.6.15.6, but I already observed it with older kernel versions too.... The system is running Debian 3.1 x86 with iptables 1.2.11, but I don't think this really matters.... If you need additional info, please let me know...
Arno
Quoted 9 lines · Arno van Amersfoort
Hello all,
I'm the author of "Arno's Iptables Firewall" (maybe you know). Anyway, I've been experiencing a problem for quite some time know. The problem is that it seems that in once in a while a connection is no longer considered ESTABLISHED by netfilter/iptables, causing the packets to bounce of the firewall like this:
Jul 5 18:02:16 rulhm2 kernel: Stealth scan (UNPRIV)?: IN=eth0 OUT= MAC=00:01:02:05:1d:25:00:10:dc:d4:a2:bc:08:00 SRC=x.x.x.x DST=x.x.x.x LEN=41 TOS=0x00 PREC=0x00 TTL=128 ID=26688 DF PROTO=TCP SPT=445 DPT=53205 WINDOW=17053 RES=0x00 ACK URGP=0In this case it's a connection for used by Samba (port 445). As you can see an TCP packets with the ACK-flag set is bounced of as it's (no longer) catched by my (iptables) ESTABLISHED-rule. This happens for a variety of flag-combinations (like RST, FIN, ACK/FIN etc.). Is there any way I can fix this "nicely", as until know I've always "worked around" this issue with using some general iptables rules which simply drop(ignore) these kind of packets. I'm thinking of some kernel settings (/proc / sysctl) that one might "tweak"....
Thanks for any info anyone can provide....
Signature · 13 lines
Ing. A.C.J. van Amersfoort (Arno) Department Of Electronics (ELD, k1007) Huygens Laboratory Leiden University P.O. Box 9504 Niels Bohrweg 2 2333 CA Leiden The Netherlands ---------------------------------------------------------------- Phone : +31-(0)71-527.1894 Fax: +31-(0)71-527.5819 E-mail: [email protected] ---------------------------------------------------------------- Arno's (Linux firewall) homepage: http://rocky.eld.leidenuniv.nl
Quoted 4 lines · Arno van Amersfoort
I'm currently running a vanilla kernel 2.6.15.6, but I already observed it with older kernel versions too.... The system is running Debian 3.1 x86 with iptables 1.2.11, but I don't think this really matters.... If you need additional info, please let me know...
There was a SACK related bug in TCP connection tracking which was fixed around 2.6.15 and which exhibited such problems. Either upgrade the kernel on your firewall or disable SACK on all machines behind it. If you can reproduce the problem at will with a machine then disable SACK on it and check wether it solves the problem.
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary
I think I already stumbled into this bug in the past, I recall that this bug was in 2.6.14.
Anyway, I've tried to disable tcp_sack & tcp_dsack but no luck. I also upgraded to 2.6.17.4 but this doesn't help iether :-S I'm also getting packets like this for "open ports" (with ie. -p tcp --dport 22 --syn -j ACCEPT) giving:
Jul 11 04:02:59 rulhm2 kernel: Stealth scan (PRIV)?: IN=eth0 OUT= MAC=00:01:02:05:1d:25:00:01:03:d2:b8:75:08:00 SRC=132.229.96.110 DST=132.229.96.12 LEN=52 TOS=0x00 PREC=0x00 TTL=64 ID=34709 DF PROTO=TCP SPT=39536 DPT=445 WINDOW=5840 RES=0x00 ACK FIN URGP=0
Any other suggestions?
Quoted 24 lines · Jozsef Kadlecsik
Quoted 5 lines · Arno van Amersfoort
I'm currently running a vanilla kernel 2.6.15.6, but I already observed it with older kernel versions too.... The system is running Debian 3.1 x86 with iptables 1.2.11, but I don't think this really matters.... If you need additional info, please let me know...
There was a SACK related bug in TCP connection tracking which was fixed around 2.6.15 and which exhibited such problems. Either upgrade the kernel on your firewall or disable SACK on all machines behind it. If you can reproduce the problem at will with a machine then disable SACK on it and check wether it solves the problem.
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear PhysicsH-1525 Budapest 114, POB. 49, Hungary
Signature · 13 lines
Ing. A.C.J. van Amersfoort (Arno) Department Of Electronics (ELD, k1007) Huygens Laboratory Leiden University P.O. Box 9504 Niels Bohrweg 2 2333 CA Leiden The Netherlands ---------------------------------------------------------------- Phone : +31-(0)71-527.1894 Fax: +31-(0)71-527.5819 E-mail: [email protected] ---------------------------------------------------------------- Arno's (Linux firewall) homepage: http://rocky.eld.leidenuniv.nl
Quoted 11 lines · Arno van Amersfoort
I think I already stumbled into this bug in the past, I recall that this bug was in 2.6.14.
Anyway, I've tried to disabletcp_sack&tcp_dsackbut no luck. I also upgraded to 2.6.17.4 but this doesn't help iether :-S I'm also getting packets like this for "open ports" (with ie. -p tcp --dport 22 --syn -j ACCEPT) giving:Jul 11 04:02:59 rulhm2 kernel: Stealth scan (PRIV)?: IN=eth0 OUT=MAC=00:01:02:05:1d:25:00:01:03:d2:b8:75:08:00 SRC=132.229.96.110 DST=132.229.96.12 LEN=52 TOS=0x00 PREC=0x00 TTL=64 ID=34709 DF PROTO=TCP SPT=39536 DPT=445 WINDOW=5840 RES=0x00 ACK FIN URGP=0
I don't understand how it is related to an open ssh port.
Quoted 1 line
Any other suggestions?
Enable logging invalid packets via /proc/sys/net/ipv4/netfilter/ip_conntrack_log_invalid then record by tcpdump a whole TCP session which triggers the problem. Then send me the capture file and the corresponding kernel log entries.
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary
Quoted 10 lines · Jozsef Kadlecsik
Quoted 7 lines · Arno van Amersfoort
I think I already stumbled into this bug in the past, I recall that this bug was in 2.6.14.
Anyway, I've tried to disabletcp_sack&tcp_dsackbut no luck. I also upgraded to 2.6.17.4 but this doesn't help iether :-S I'm also getting packets like this for "open ports" (with ie. -p tcp --dport 22 --syn -j ACCEPT) giving:
Quoted 8 lines
Quoted 5 lines
Jul 11 04:02:59 rulhm2 kernel: Stealth scan (PRIV)?: IN=eth0 OUT=MAC=00:01:02:05:1d:25:00:01:03:d2:b8:75:08:00 SRC=132.229.96.110 DST=132.229.96.12 LEN=52 TOS=0x00 PREC=0x00 TTL=64 ID=34709 DF PROTO=TCP SPT=39536 DPT=445 WINDOW=5840 RES=0x00 ACK FIN URGP=0
I don't understand how it is related to an open ssh port.
Sorry about that. It should (of course) be -p tcp --dport 445 --syn -j ACCEPT . (I'm running Samba on this machine). But do note that this issue doesn't specifically happen with Samba. I've also seen it happen with http packets...
Quoted 9 lines
Quoted 3 lines
Any other suggestions?
Enable logging invalid packets via
/proc/sys/net/ipv4/netfilter/ip_conntrack_log_invalidthen record by tcpdump a whole TCP session which triggers the problem. Then send me the capture file and the corresponding kernel log entries.
Ok. I will try to do this. And let you know my findings
Quoted 9 lines
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear PhysicsH-1525 Budapest 114, POB. 49, Hungary
Signature · 13 lines
Ing. A.C.J. van Amersfoort (Arno) Department Of Electronics (ELD, k1007) Huygens Laboratory Leiden University P.O. Box 9504 Niels Bohrweg 2 2333 CA Leiden The Netherlands ---------------------------------------------------------------- Phone : +31-(0)71-527.1894 Fax: +31-(0)71-527.5819 E-mail: [email protected] ---------------------------------------------------------------- Arno's (Linux firewall) homepage: http://rocky.eld.leidenuniv.nl
Just did some more investigation. Didn't test with tcpdump yet as this issue is not reproducable easiely :-S Anyway it turns out that the packets shown have state "INVALID" (opposed to ESTABLISHED or NEW). So somehow iptables "thinks" they no longer belong to a connection (somehow)....
Quoted 41 lines · Arno van Amersfoort
Quoted 10 lines · Jozsef Kadlecsik
Quoted 7 lines · Arno van Amersfoort
I think I already stumbled into this bug in the past, I recall that this bug was in 2.6.14.
Anyway, I've tried to disabletcp_sack&tcp_dsackbut no luck. I also upgraded to 2.6.17.4 but this doesn't help iether :-S I'm also getting packets like this for "open ports" (with ie. -p tcp --dport 22 --syn -j ACCEPT) giving:Quoted 7 lines
Quoted 4 lines
Jul 11 04:02:59 rulhm2 kernel: Stealth scan (PRIV)?: IN=eth0 OUT=MAC=00:01:02:05:1d:25:00:01:03:d2:b8:75:08:00 SRC=132.229.96.110 DST=132.229.96.12 LEN=52 TOS=0x00 PREC=0x00 TTL=64 ID=34709 DF PROTO=TCP SPT=39536 DPT=445 WINDOW=5840 RES=0x00 ACK FIN URGP=0
I don't understand how it is related to an open ssh port.
Sorry about that. It should (of course) be -p tcp --dport 445 --syn -j ACCEPT . (I'm running Samba on this machine). But do note that this issue doesn't specifically happen with Samba. I've also seen it happen with http packets...
Quoted 9 lines
Quoted 3 lines
Any other suggestions?
Enable logging invalid packets via
/proc/sys/net/ipv4/netfilter/ip_conntrack_log_invalidthen record by tcpdump a whole TCP session which triggers the problem. Then send me the capture file and the corresponding kernel log entries.Ok. I will try to do this. And let you know my findings
Quoted 9 lines
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear PhysicsH-1525 Budapest 114, POB. 49, Hungary
Signature · 13 lines
Ing. A.C.J. van Amersfoort (Arno) Department Of Electronics (ELD, k1007) Huygens Laboratory Leiden University P.O. Box 9504 Niels Bohrweg 2 2333 CA Leiden The Netherlands ---------------------------------------------------------------- Phone : +31-(0)71-527.1894 Fax: +31-(0)71-527.5819 E-mail: [email protected] ---------------------------------------------------------------- Arno's (Linux firewall) homepage: http://rocky.eld.leidenuniv.nl
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 1 line · Arno van Amersfoort
Just did some more investigation. Didn't test with tcpdump yet as this issue is not reproducable easiely :-S Anyway it turns out that the packets shown have state "INVALID" (opposed to ESTABLISHED or NEW). So somehow iptables "thinks" they no longer belong to a connection (somehow)....
Or that there is some other issue with the packets, such as bad header, improper flags set, truncated packets, etc. This could be a sign as well of a nic flaking out or a bad cable or switch port. Or could be a malicious app is spewing packets that do not fit the coresponding connections paramaters.
Thanks,
Ron DuFresne
Quoted 33 lines
Quoted 31 lines · Arno van Amersfoort
Quoted 10 lines · Jozsef Kadlecsik
Quoted 7 lines · Arno van Amersfoort
I think I already stumbled into this bug in the past, I recall that this bug was in 2.6.14.
Anyway, I've tried to disabletcp_sack&tcp_dsackbut no luck. I also upgraded to 2.6.17.4 but this doesn't help iether :-S I'm also getting packets like this for "open ports" (with ie. -p tcp --dport 22 --syn -j ACCEPT) giving:Quoted 7 lines
Quoted 4 lines
Jul 11 04:02:59 rulhm2 kernel: Stealth scan (PRIV)?: IN=eth0 OUT=MAC=00:01:02:05:1d:25:00:01:03:d2:b8:75:08:00 SRC=132.229.96.110 DST=132.229.96.12 LEN=52 TOS=0x00 PREC=0x00 TTL=64 ID=34709 DF PROTO=TCP SPT=39536 DPT=445 WINDOW=5840 RES=0x00 ACK FIN URGP=0
I don't understand how it is related to an open ssh port.
Sorry about that. It should (of course) be -p tcp --dport 445 --syn -j ACCEPT . (I'm running Samba on this machine). But do note that this issue doesn't specifically happen with Samba. I've also seen it happen with http packets...
Quoted 9 lines
Quoted 3 lines
Any other suggestions?
Enable logging invalid packets via
/proc/sys/net/ipv4/netfilter/ip_conntrack_log_invalidthen record by tcpdump a whole TCP session which triggers the problem. Then send me the capture file and the corresponding kernel log entries.Ok. I will try to do this. And let you know my findings
Quoted 12 lines
Quoted 10 lines
Quoted 9 lines
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear PhysicsH-1525 Budapest 114, POB. 49, Hungary
- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
admin & senior security consultant: sysinfo.com
http://sysinfo.com
Key fingerprint = 9401 4B13 B918 164C 647A E838 B2DF AFCC 94B0 6629
...We waste time looking for the perfect lover
instead of creating the perfect love.
-Tom Robbins <Still Life With Woodpecker>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)
iD8DBQFEtrvGst+vzJSwZikRAsBdAJ4zpaSRk+7nnrIqC1jpjNq3eLz6LgCgoMgr 9TkGWKMZMOdETwS0mLhi8ok=
=qs/A
-----END PGP SIGNATURE-----
Quoted 5 lines · Arno van Amersfoort
Just did some more investigation. Didn't test with tcpdump yet as this issue is not reproducable easiely :-S Anyway it turns out that the packets shown have state "INVALID" (opposed to ESTABLISHED or NEW). So somehow iptables "thinks" they no longer belong to a connection (somehow)....
If you enabled logging invalid packets, then the kernel would produce log lines why those packets were categorized as INVALID.
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · Arno van Amersfoort
Quoted 8 lines · Jozsef Kadlecsik
Quoted 5 lines · Arno van Amersfoort
Just did some more investigation. Didn't test with tcpdump yet as this issue is not reproducable easiely :-S Anyway it turns out that the packets shown have state "INVALID" (opposed to ESTABLISHED or NEW). So somehow iptables "thinks" they no longer belong to a connection (somehow)....
Quoted 5 lines
Quoted 2 lines
If you enabled logging invalid packets, then the kernel would produce log lines why those packets were categorized as INVALID.
I've tried enabling this option but nothing shows up in my kernel log. I'd expect it to appear in loglevel kern.* right ?
That's right. You have got the kernel module ipt_LOG loaded in (and ipt_ULOG doesn't), don't you?
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary
Yep: I have ipt_LOG loaded (actually compiled into the kernel) and not ipt_ULOG. So the only thing I'm getting in my kernel log is:
Jul 17 04:02:07 rulhm2 kernel: INVALID packet: IN=eth0 OUT= MAC=00:01:02:05:1d:25:00:01:03:d2:b8:75:08:00 SRC=132.229.96.110 DST=132.229.96.12 LEN=52 TOS=0x00 PREC=0x00 TTL=64 ID=56700 DF PROTO=TCP SPT=54858 DPT=445 WINDOW=5840 RES=0x00 ACK FIN URGP=0
(But of course this also is shown when /proc/sys/net/ipv4/netfilter/ip_conntrack_log_invalid = 0 )
Quoted 33 lines · Jozsef Kadlecsik
Quoted 11 lines · Arno van Amersfoort
Quoted 9 lines · Jozsef Kadlecsik
Quoted 6 lines · Arno van Amersfoort
Just did some more investigation. Didn't test with tcpdump yet as this issue is not reproducable easiely :-S Anyway it turns out that the packets shown have state "INVALID" (opposed to ESTABLISHED or NEW). So somehow iptables "thinks" they no longer belong to a connection (somehow)....
Quoted 6 lines
Quoted 3 lines
If you enabled logging invalid packets, then the kernel would produce log lines why those packets were categorized as INVALID.
I've tried enabling this option but nothing shows up in my kernel log. I'd expect it to appear in loglevel kern.* right ?
That's right. You have got the kernel module
ipt_LOGloaded in (andipt_ULOGdoesn't), don't you?Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear PhysicsH-1525 Budapest 114, POB. 49, Hungary
Signature · 13 lines
Ing. A.C.J. van Amersfoort (Arno) Department Of Electronics (ELD, k1007) Huygens Laboratory Leiden University P.O. Box 9504 Niels Bohrweg 2 2333 CA Leiden The Netherlands ---------------------------------------------------------------- Phone : +31-(0)71-527.1894 Fax: +31-(0)71-527.5819 E-mail: [email protected] ---------------------------------------------------------------- Arno's (Linux firewall) homepage: http://rocky.eld.leidenuniv.nl
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 10 lines · Arno van Amersfoort
Yep: I have
ipt_LOGloaded (actually compiled into the kernel) and notipt_ULOG. So the only thing I'm getting in my kernel log is:Jul 17 04:02:07 rulhm2 kernel: INVALID packet: IN=eth0 OUT=MAC=00:01:02:05:1d:25:00:01:03:d2:b8:75:08:00 SRC=132.229.96.110 DST=132.229.96.12 LEN=52 TOS=0x00 PREC=0x00 TTL=64 ID=56700 DF PROTO=TCP SPT=54858 DPT=445 WINDOW=5840 RES=0x00 ACK FIN URGP=0
(But of course this also is shown when
/proc/sys/net/ipv4/netfilter/ip_conntrack_log_invalid= 0 )
That line is created by your explicit rule of logging invalid packets. If there were any TCP related problem which would forced conntrack to mark the packet as invalid, you should see kernel log messages with the prefix "ip_ct_tcp: " (when logging invalid packets is enabled). That's really strange. As the packet is not truncated, there isn't really anything which should trigger to mark it as INVALID.
It seems to me only catching such packets by tcpdump can really help.
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary