Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I set up some iptables rules so it logs and drops the packets that are INVALID (--state INVALID). Reading the logs how can I understand why the packet was considered invalid? For example, the following:

Nov 29 22:59:13 htpc-router kernel: [6550193.790402] ::IPT::DROP:: IN=ppp0 OUT= MAC= SRC=31.13.72.7 DST=136.169.151.82 LEN=40 TOS=0x00 PREC=0x00 TTL=242 ID=5104 DF PROTO=TCP SPT=80 DPT=61597 WINDOW=0 RES=0x00 ACK RST URGP=0
share|improve this question

1 Answer 1

up vote 11 down vote accepted

Packets can be in various states when using stateful packet inspection.

  • New: The packet is not part of any known flow or socket and the TCP flags have the SYN bit on.
  • Established: The packet matches a flow or socket tracked by CONNTRACK and has any TCP flags. After the initial TCP handshake is completed the SYN bit must be off for a packet to be in state established.
  • Related: The packet does not match any known flow or socket, but the packet is expected because there is an existing socket that predicates it (examples of this are data on port 20 when there is an existing FTP session on port 21, or UDP data for an existing SIP connection on TCP port 5060). This requires an associated ALG, or
  • Invalid: If none of the previous states apply the packet is in state INVALID. This could be caused by various types of stealth network probes, or it could mean that you're running out of CONNTRACK entries (which you should also see stated in your logs). Or it may simply be entirely benign.

In your case, the packet that you cite shows that the TCP flags ACK and RST, and that the source port is 80. What that means is that the web server at 31.13.72.7 (which happens to be Facebook) sent a reset packet to you. It's entirely impossible to say why without seeing the packets that came before it (if any). But most likely it is sending you a reset for the same reason your computer thinks it's invalid.

share|improve this answer
    
So there's no way to ask a kernel (or iptables) to append a kind of a "signature" to a packet that would hold the reason of it being an invalid? –  mbaitoff Dec 3 '12 at 9:21
    
By definition, no. Invalid means that it doesn't match to any known states. In other words, that's the kernel saying "I don't know why I received this packet". –  bahamat Dec 3 '12 at 9:28
    
For debugging specific INVALID packets, looking at them in Wireshark from a dump might work... I have seen packets with SACK fields (actually the normal sequence numbers are changed by the firewall and the ones in SACK option isn't, resulting in SACK values being invalid) that was broken by a firewall being dropped as invalid... –  Gert van den Berg Dec 31 '12 at 9:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.