Linux Netfilter discussions
 help / color / mirror / Atom feed
* netfilter+libvirt=(smth got broken?)
@ 2013-03-20 12:47 Nikolai Zhubr
  2013-03-20 13:06 ` Nikolai Zhubr
  2013-03-20 13:41 ` Nikolai Zhubr
  0 siblings, 2 replies; 12+ messages in thread
From: Nikolai Zhubr @ 2013-03-20 12:47 UTC (permalink / raw)
  To: libvirt-users, netfilter

Hello,

I'm having problem setting up filtering traffic for a virtual machine 
managed by libvirt. Strange thing is, such a setup has been working fine 
for me on an older version of distro (namely, opensuse 11.3  w/updates, 
kernel 2.6.34, libvirt 0.8.8) but refused to work on shiny new opensuse 
12.4 (kernel 3.7.10, libvirt 1.0.2).

The definition of filter in question is pretty simple:

<filter name='some-filt' chain='ipv4'>
   <rule action='accept' direction='in'>
     <tcp dstportstart='110'/>
   </rule>
   <rule action='drop' direction='inout'>
     <all/>
   </rule>
</filter>

So basically it should allow incoming connections to the specified port 
number and nothing else. After activating this filter on a box in 
question, connections to 110 started to fail (timeout). Examining 
iptables rules manually and comparing them to the rules from my old box 
did not reveal anything suspicious to me. However, through just pure 
guesswork, I managed to ocasionally "fix" the problem by manually 
editing 3 relevant rules as follows:

--A FI-vnet0 -p tcp -m tcp --sport 110 -m conntrack --ctstate 
ESTABLISHED -m conntrack --ctdir ORIGINAL -j RETURN
+-A FI-vnet0 -p tcp -m tcp --sport 110 -m conntrack --ctstate 
ESTABLISHED -m conntrack --ctdir REPLY -j RETURN

--A FO-vnet0 -p tcp -m tcp --dport 110 -m conntrack --ctstate 
NEW,ESTABLISHED -m conntrack --ctdir REPLY -j ACCEPT
+-A FO-vnet0 -p tcp -m tcp --dport 110 -m conntrack --ctstate 
NEW,ESTABLISHED -m conntrack --ctdir ORIGINAL -j ACCEPT

--A HI-vnet0 -p tcp -m tcp --sport 110 -m conntrack --ctstate 
ESTABLISHED -m conntrack --ctdir ORIGINAL -j RETURN
+-A HI-vnet0 -p tcp -m tcp --sport 110 -m conntrack --ctstate 
ESTABLISHED -m conntrack --ctdir REPLY -j RETURN

So essentially, just manually swtiching "--ctdir" values to their 
opposites makes the filter allow connections to port 110. I've also 
verified that the filter still blocks unwanted connections originating 
from port 110 from VM exactly as it should:

(in VM): netcat -v -v -n -p 110 192.168.122.1 22
(UNKNOWN) [192.168.122.1] 22 (?) : Connection timed out
  set 0, rcvd 0

I've then compared /proc/net/nf_conntrack on both (old and new) boxes. 
They look roughly the same, nothing suspicious.

This all looks to me as if "--ctdir" argument somehow magically changed 
its meaning to the opposite, but this just cannot be! I'm out of ideas 
and looking for insights. Any hints appreciated quite a lot.

Thank you.
Nikolai



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-03-27 18:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-20 12:47 netfilter+libvirt=(smth got broken?) Nikolai Zhubr
2013-03-20 13:06 ` Nikolai Zhubr
2013-03-20 13:41 ` Nikolai Zhubr
     [not found]   ` <514A1F0A.4090402@laine.org>
     [not found]     ` <514A1F0A.4090402-k/Ak44NBdeXYtjvyW6yDsg@public.gmane.org>
2013-03-20 23:01       ` Nikolai Zhubr
2013-03-21  2:30   ` Pablo Neira Ayuso
2013-03-21  3:18     ` [libvirt-users] " Eric Blake
2013-03-21  9:55       ` Pablo Neira Ayuso
2013-03-22 10:53         ` Pablo Neira Ayuso
2013-03-22 18:10           ` Laine Stump
2013-03-26 14:18             ` Pablo Neira Ayuso
2013-03-27 18:22               ` Laine Stump
2013-03-21 10:32       ` Nikolai Zhubr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox