1

I'm setting up a server running Debian Jessie with some applications like iptables firewall, fail2ban, openvpn, apache, ...

The iptables firewall is configured in the way, that it logs every packet that is dropped. A small excerpt from the iptables configuration:

...
-A INPUT -m comment --comment "003 accept related established rules IPv4" -m state --state RELATED,ESTABLISHED -j ACCEPT
...
-A INPUT -p tcp -m multiport --dports 1194 -m comment --comment "303 allow incoming OpenVPN" -m state --state NEW -j ACCEPT
...
-A INPUT -m comment --comment "900 IPv4 log dropped input chain" -j LOG --log-prefix "[IPTABLES INPUT IPv4] DROP " --log-level 6
-A INPUT -m comment --comment "910 IPv4 deny all other input requests" -j DROP

OpenVPN (which uses port 1194) works well. I can connect, use the connection and work for hours, up to the point when I need to transfer larger amount of data. At this point some lines like the following appear in the log:

Mar 02 20:39:27 rs3 kernel: [IPTABLES INPUT IPv4] DROP IN=eth0 OUT= MAC=ae:12:7b:9b:5d:e4:00:15:c7:c9:45:80:08:00 SRC=<MyIPAddress> DST=<ServerIPAddress> LEN=40 TOS=0x00 PREC=0x00 TTL=55 ID=20713 DF PROTO=TCP SPT=61941 DPT=1194 WINDOW=3040 RES=0x00 ACK URGP=0
Mar 02 20:39:27 rs3 kernel: [IPTABLES INPUT IPv4] DROP IN=eth0 OUT= MAC=ae:12:7b:9b:5d:e4:00:15:c7:c9:45:80:08:00 SRC=<MyIPAddress> DST=<ServerIPAddress> LEN=40 TOS=0x00 PREC=0x00 TTL=55 ID=20718 DF PROTO=TCP SPT=61941 DPT=1194 WINDOW=3040 RES=0x00 ACK URGP=0 
Mar 02 20:39:27 rs3 kernel: [IPTABLES INPUT IPv4] DROP IN=eth0 OUT= MAC=ae:12:7b:9b:5d:e4:00:15:c7:c9:45:80:08:00 SRC=<MyIPAddress> DST=<ServerIPAddress> LEN=40 TOS=0x00 PREC=0x00 TTL=55 ID=20719 DF PROTO=TCP SPT=61941 DPT=1194 WINDOW=3040 RES=0x00 ACK URGP=0 

[These logs are picked up from fail2ban and the server closes the connection to my local computer.]

Q: Why are those packets dropped (and logged)? That means: Why are those packets not processed by the 'RELATED,ESTABLISHED' rule?

What I did so far: read documentation, thought about the problem ;-), checked the rules again and again, googled the Internet - but without any result.

Edit: maybe this is important: the DROP list that was created by fail2ban has about 500 entries.

Edit: I want to know the reason (this is why I'm using 'Why' in my question). I'm not interested in workarounds.

Edit: This behavior is not limited to OpenVPN, using other protocols (e.g. ssh) has the same problem.

Edit: To give you an impression, have a look at the wireshark screenshot: the highlighted packet was droped / logged - all other packets from the screenshot not.

Here is the appropriate log:

Mar 03 10:16:23 rs3 kernel: [IPTABLES INPUT IPv4] DROP IN=eth0 OUT= MAC=ae:12:7b:9b:5d:e4:00:15:c7:c9:45:80:08:00 SRC=<MyIPAddress>.117 DST=<ServerIPAddress>.116 LEN=40 TOS=0x00 PREC=0x00 TTL=55 ID=11550 DF PROTO=TCP SPT=63526 DPT=1194 WINDOW=32038 RES=0x00 ACK URGP=0 

I used the IP ID (11550) to find the packet in wireshark. And this is the only IP packet with this ID.

Wireshark Details of Logged packet

Edit: The server IP is a fixed IP. My dynamically assigned IP address was not changed during the the test. Connections are initiated by the LocalComputer towards the Server. The setup is as follows:

=================      ===================      ===============
| LocalComputer | ---- | NAT Router .117 | ---- | Server .116 |
=================      ===================      ===============
   Private IP            Dynam. Assigned            Fixed IP
                       but fixed during test

2 Answers 2

1

Because you've got those iptables log entries, and they haven't matched your RELATED,ESTABLISHED rules, the connection tracker is reporting seeing them as the start of new sessions unrelated to anything earlier. Typically (but not always) this can happen when the session has spent longer idle than the connection tracker timeout. Other NAT devices between your endpoints might have timed out and generated new port numbers, or your other endpoint might have had its IP address changed (possible on some ISPs' DHCP-based networks) so it's not necessarily the endpoint connection tracker that is at fault.

There are three options that spring to mind,

  1. Enable ping keepalive within the OpenVPN configuration. As a minimum, try ping 10. If you prefer, and depending on how your client/server is set up you may prefer keepalive 10 60. See the man page for really gory details. (This won't solve the problem if the IP address/port pair for an endpoint changes.)

  2. Disable the fail2ban configuration that matches OpenVPN traffic on 1194/tcp.

  3. Ensure that you avoid printing a log message from iptables for OpenVPN traffic on 1194/tcp, so fail2ban has nothing on which to trigger.

3
  • Thank you for your answer - but IMHO your analyze is wrong: as I said, this logging only happens if there is a lot of traffic. Also your answer does not really answer my question (it might be a bit misleading, but of course I'm interested in WHY those packets do not match the appropriate rule). Point 2 and 3 are workarounds I'm not interested in. Mar 3, 2015 at 9:59
  • @Andreas can you confirm that neither endpoint's IP address nor external port changes during the conversation? Are you sure that 624 caused the drop/log and not the duplicate ACK 629?
    – roaima
    Mar 3, 2015 at 13:09
  • Thank you for your help! Yes, I can confirm, that neither endpoint's IP address nor the port changed. Yes, I'm sure that packet 624 caused the dropping. Please have a look at the question again - I added the log line and a description about the network setup. Mar 3, 2015 at 13:37
0

The connection tracker does not only track, if packets are from the same connection, but also checks for some timings (like late ACK or SEQ too late).

It is possible to switch on connection tracker logging with:

echo 255 >/proc/sys/net/netfilter/nf_conntrack_log_invalid

This showed me, that all dropped and logged packages are of the type:

nf_ct_tcp: ACK is under the lower bound (possible overly delayed ACK) ...

There is a discussion where I found these hints.

I am currently not aware why this happens, but this might be another question...

You must log in to answer this question.

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