Score:0

Linux Kernel IP Forward activated, firewalld is bypassed?

za flag

On a Linux Centos7, I have some traffic that is routed with static routes from one interface to another.

I did notice that with firewalld activated, both interfaces added in a zone, and nothing allowed in this zone, all the traffic is still routed without any restriction.

I tried to configure ip_forward=0 : then the traffic was not routed anymore. Then I added FORWARD rules in firewalld direct.xml : the traffic was routed and filtered.

My questions are :

  • Does ip_forward kernel setting "bypass" firewalld?
  • Why is it explained on various forums that ip_forward is mandatory to route traffic from one interface to another, if using an iptable FORWARD works with this setting disabled?

I found very few explanations on the relations between firewalld and kernel ip_forward, and I would like to understand what I'm missing here

EDIT : masquerade is enabled on the firewalld zone


EDIT2 : I did other tests, and it looks like this is not about ip_filter setting, but the masquerade. I was tricked by the fact that "firewall-cmd --reload" force ip_forward to 1.

Here is how to reproduce my case:

Fresh Centos7 OS. Configuration of two interfaces eth1 and eth2 with ip adresses X and Y

-----------------> @X CENTOS @Y -----------------> @Z  -------
    dst_IP = A                      dst_IP = A
    src_IP = B                      dst_IP = B

edit /etc/firewalld/zones/TEST.xml, add the two interfaces, activate masquerade.

add a route as following :

Destination     Gateway     GenMask
A               Z           255.255.255.255

Then activate ip forward an deactivate rp_filter :

sysctl net.ipv4.ip_forward=1
sysctl net.ipv4.conf.eth1.rp_filter=2
sysctl net.ipv4.conf.eth2.rp_filter=2

In this setup, paquets are transferred to @Z, but there is no rule in firewalld configured to accept them, and I don't understand why

A.B avatar
cl flag
A.B
I'm not convinced by your statement. Can you give a reproducible example?
za flag
I will tomorrow. I forgot to precise that masquerade is enabled on the firewalld zone
za flag
I added some precisions and how to reproduce the case
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.