Unexpected (ct)state matching behaviour
Hi!
I'm running a netfilter firewall on a KVM hosting system which also is the router for the IP networks. Like this:
,--------------------------.
| |
internet <-- eth0 -| |
| - br0 192.168.42.1/24 |
`--------------------------´Most VMs ar connected to th bridge.
The bridge-nf-hooks are disabled via sysctl:
net.bridge.bridge-nf-call-arptables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-ip6tables = 0
What I'm now doing is filtering the traffic to the service VMs with the following ruleset:
Where 192.168.42.53 being a DNS, .25 being a MX and .70 being a monitoring (Nagios, ..) machine. (All machines have public IPs, but I mapped them to this network here.)
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
0 0 ACCEPT all -- * eth0 192.168.42.0/24 0.0.0.0/0
0 0 ACCEPT tcp -- * * 192.168.42.70 0.0.0.0/0 tcp dpt:4949
0 0 ACCEPT tcp -- * * 192.168.42.70 0.0.0.0/0 tcp dpt:5666
0 0 ACCEPT tcp -- * * 192.168.42.70 0.0.0.0/0 tcp dpt:22
0 0 services all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 limit: avg 2/sec burst 5 LOG flags 0 level 4 prefix `forward reject: '
0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-admin-prohibitedChain services (1 references)
pkts bytes target prot opt in out source destination
0 0 ACCEPT udp -- * * 0.0.0.0/0 192.168.42.53 udp dpt:53
0 0 ACCEPT tcp -- * * 0.0.0.0/0 192.168.42.53 tcp dpt:53
0 0 ACCEPT tcp -- * * 0.0.0.0/0 192.168.42.25 tcp dpt:25
0 0 ACCEPT tcp -- * * 0.0.0.0/0 192.168.42.25 tcp dpt:26
0 0 ACCEPT tcp -- * * 0.0.0.0/0 192.168.42.25 tcp dpt:80
0 0 ACCEPT tcp -- * * 0.0.0.0/0 192.168.42.25 tcp dpt:143[...]
This works great in general but since the Nagios is checking the services I get some rejected packets and I have no idea why:
First, some DNS answers to queries from the MX get rejected:
forward reject: IN=br0 OUT=br0 SRC=192.168.42.53 DST=192.168.42.25 LEN=238 TOS=0x00 PREC=0x00 TTL=63 ID=64971 PROTO=UDP SPT=53 DPT=37743 LEN=218 forward reject: IN=br0 OUT=br0 SRC=192.168.42.53 DST=192.168.42.25 LEN=238 TOS=0x00 PREC=0x00 TTL=63 ID=64972 PROTO=UDP SPT=53 DPT=37743 LEN=218 forward reject: IN=br0 OUT=br0 SRC=192.168.42.53 DST=192.168.42.25 LEN=238 TOS=0x00 PREC=0x00 TTL=63 ID=64973 PROTO=UDP SPT=53 DPT=37743 LEN=218 forward reject: IN=br0 OUT=br0 SRC=192.168.42.53 DST=192.168.42.25 LEN=238 TOS=0x00 PREC=0x00 TTL=63 ID=64974 PROTO=UDP SPT=53 DPT=57656 LEN=218
And some Nagios test fail.
forward reject: IN=br0 OUT=br0 SRC=192.168.42.53 DST=192.168.42.70 LEN=60 TOS=0x00 PREC=0x00 TTL=63 ID=0 DF PROTO=TCP SPT=4949 DPT=45244 WINDOW=5792 RES=0x00 ACK SYN URGP=0 forward reject: IN=br0 OUT=br0 SRC=192.168.42.25 DST=192.168.42.70 LEN=60 TOS=0x00 PREC=0x00 TTL=63 ID=0 DF PROTO=TCP SPT=143 DPT=54878 WINDOW=5792 RES=0x00 ACK SYN URGP=0 forward reject: IN=br0 OUT=br0 SRC=192.168.42.53 DST=192.168.42.70 LEN=60 TOS=0x00 PREC=0x00 TTL=63 ID=0 DF PROTO=TCP SPT=4949 DPT=36041 WINDOW=5792 RES=0x00 ACK SYN URGP=0 forward reject: IN=br0 OUT=br0 SRC=192.168.42.25 DST=192.168.42.70 LEN=60 TOS=0x00 PREC=0x00 TTL=63 ID=0 DF PROTO=TCP SPT=143 DPT=47685 WINDOW=5792 RES=0x00 ACK SYN URGP=0 forward reject: IN=br0 OUT=br0 SRC=192.168.42.53 DST=192.168.42.70 LEN=60 TOS=0x00 PREC=0x00 TTL=63 ID=0 DF PROTO=TCP SPT=4949 DPT=57860 WINDOW=5792 RES=0x00 ACK SYN URGP=0 forward reject: IN=br0 OUT=br0 SRC=192.168.42.25 DST=192.168.42.70 LEN=60 TOS=0x00 PREC=0x00 TTL=63 ID=0 DF PROTO=TCP SPT=143 DPT=45284 WINDOW=5792 RES=0x00 ACK SYN URGP=0
The really confusing thing is that this only happens sometimes while the rest of the day everything works as expected. No other services running in different VMs on the same hosts show any problems.
Any ideas what might go wrong here?
Thanks
Ciao
Max
Signature · 2 lines
Fortschritt bedeutet, einen Schritt so zu machen, daß man den nächsten auch noch machen kann.
Quoted 5 lines · Maximilian Wilhelm
The bridge-nf-hooks are disabled via sysctl:
net.bridge.bridge-nf-call-arptables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-ip6tables = 0
I suspect that is your problem. Disabling nf-call would seem to not run the NF_IP6_PRI_CONNTRACK hook, and as such not track particular connections/packets delivered over a bridge. (Thus, all those pkts are classified as INVALID.)
Anno domini 2011 Jan Engelhardt scripsit:
(I'm subscribed, no need for CC :))
Quoted 12 lines · Maximilian Wilhelm
Quoted 6 lines
The bridge-nf-hooks are disabled via sysctl:
net.bridge.bridge-nf-call-arptables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-ip6tables = 0I suspect that is your problem. Disabling nf-call would seem to not run the
NF_IP6_PRI_CONNTRACKhook, and as such not track particular connections/packets delivered over a bridge. (Thus, all those pkts are classified as INVALID.)
Well, I should have said that. I had these not deactivted before, but had similar problems, but with the Nagios Remote Plugin Executer only.
forward reject: IN=br0 OUT=br0 PHYSIN=dns01_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.53 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=41662 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=33300 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=33300 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=57854 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=57854 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=dns01_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.53 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=47357 WINDOW=0 RES=0x00 RST URGP=0
Deactivate the hooks clearly fixed that problem, but after a while the other one turned up. Any furher idea? :)
Thanks
Max
Quoted 14 lines · Maximilian Wilhelm
Quoted 3 lines
not run the
NF_IP6_PRI_CONNTRACKhook, and as such not track particular connections/packets delivered over a bridge. (Thus, all those pkts are classified as INVALID.)Well, I should have said that. I had these not deactivted before, but had similar problems, but with the Nagios Remote Plugin Executer only.
forward reject: IN=br0 OUT=br0 PHYSIN=dns01_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.53 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=41662 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=33300 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=33300 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=57854 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=57854 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=dns01_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.53 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=47357 WINDOW=0 RES=0x00 RST URGP=0
Quoted 2 lines
Deactivate the hooks clearly fixed that problem, but after a while the other one turned up. Any furher idea? :)
Suggestion: Maximum number of CTs reached. Check dmesg for overflow warnings.
Anno domini 2011 Jan Engelhardt scripsit:
Quoted 16 lines · Maximilian Wilhelm
Quoted 14 lines
Quoted 4 lines
not run the
NF_IP6_PRI_CONNTRACKhook, and as such not track particular connections/packets delivered over a bridge. (Thus, all those pkts are classified as INVALID.)Well, I should have said that. I had these not deactivted before, but had similar problems, but with the Nagios Remote Plugin Executer only.
forward reject: IN=br0 OUT=br0 PHYSIN=dns01_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.53 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=41662 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=33300 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=33300 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=57854 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=57854 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=dns01_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.53 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=47357 WINDOW=0 RES=0x00 RST URGP=0
Quoted 5 lines
Quoted 2 lines
Deactivate the hooks clearly fixed that problem, but after a while the other one turned up. Any furher idea? :)
Suggestion: Maximum number of CTs reached. Check dmesg for overflow warnings.
The only netfilter related thing which pops up in
zgrep -v '\(local\|forward\) reject' kern.log*
since the last reboot of the machine is:
| nf_conntrack version 0.5.0 (16384 buckets, 65536 max) | CONFIG_NF_CT_ACCT is deprecated and will be removed soon. Please use | nf_conntrack.acct=1 kernel parameter, acct=1 nf_conntrack module option or | sysctl net.netfilter.nf_conntrack_acct=1 to enable it.
wc -l /proc/net/ip_conntrack reports 211 and my Munin graphs indicate that this is the usual value, so I would assue that's not the problem here?
Ciao
Max
Anno domini 2011 Maximilian Wilhelm scripsit:
Quoted 21 lines
Quoted 10 lines
Quoted 5 lines
The bridge-nf-hooks are disabled via sysctl:
net.bridge.bridge-nf-call-arptables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-ip6tables = 0I suspect that is your problem. Disabling nf-call would seem to not run the
NF_IP6_PRI_CONNTRACKhook, and as such not track particular connections/packets delivered over a bridge. (Thus, all those pkts are classified as INVALID.)Well, I should have said that. I had these not deactivted before, but had similar problems, but with the Nagios Remote Plugin Executer only.
forward reject: IN=br0 OUT=br0 PHYSIN=dns01_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.53 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=41662 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=33300 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=33300 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=57854 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=mail_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.25 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=57854 WINDOW=0 RES=0x00 RST URGP=0 forward reject: IN=br0 OUT=br0 PHYSIN=dns01_eth0 PHYSOUT=mon_eth0 SRC=192.168.42.53 DST=192.168.42.70 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=TCP SPT=5666 DPT=47357 WINDOW=0 RES=0x00 RST URGP=0
Quoted 2 lines
Deactivate the hooks clearly fixed that problem, but after a while the other one turned up. Any furher idea? :)
It might be worth adding that each of the VMs has a setup like this:
# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.42.1 0.0.0.0 255.255.255.255 UH 0 0 0 eth0 0.0.0.0 192.168.42.1 0.0.0.0 UG 0 0 0 eth0
to enforce that the packets are being routed and firewalled on the host machine.
Ciao
Max
Signature · 3 lines
"Du kannst die Grundlagen von C. Das einzige, was C++ Dir noch gibt, ist mehr Schmerz! Und ein paar mehr Schrotflinten in die Hand..." -- Matthias Bolte