19

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

1 Answer 1

31

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.
  • 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.

5
  • 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, 2012 at 9:21
  • 2
    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, 2012 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... Dec 31, 2012 at 9:00
  • @mbaitoff You may be able to add rules that LOG incoming packets such as these: serverfault.com/questions/1115779/… Nov 16, 2022 at 18:06
  • @mbaitoff OP is already logging them. That's why they asked the question.
    – bahamat
    Nov 17, 2022 at 19:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .