Port forwarding using firewallD through specific interface

Support for security such as Firewalls and securing linux
Post Reply
wice22
Posts: 9
Joined: 2017/02/19 15:56:06

Port forwarding using firewallD through specific interface

Post by wice22 » 2017/07/23 21:08:28

Hi

I'm looking for a solution to route port forwarding trough a particular interface:
For insane:
having a zone called "inz08"
I have 2 interfaces in that zone:

Code: Select all

ens33
ens38
Created a port forwarding:

Code: Select all

firewalld-cmd --zone=inz08 --add-forward-port=port=2245:proto=tcp:toport=22:toaddr=10.0.0.125
I need to specify the interface ens38 to be a carrier of this redirection

I've gone trough documentation at http://www.firewalld.org/documentation/
But can't find any appropriate syntax to add it, I did try to use

Code: Select all

:interface=ens38 
:iface=ens38 
:dev=ens38
Nothing seems to work,

Please tell me that developers did think about such function and its there :)

mghe
Posts: 766
Joined: 2015/11/24 12:04:43
Location: Katowice, Poland

Re: Port forwarding using firewallD through specific interface

Post by mghe » 2017/07/23 21:15:42

Code: Select all

# firewall-cmd --add-interface=ens38 --zone=inz08 --permanent

wice22
Posts: 9
Joined: 2017/02/19 15:56:06

Re: Port forwarding using firewallD through specific interface

Post by wice22 » 2017/07/23 21:26:01

mghe wrote:

Code: Select all

# firewall-cmd --add-interface=ens38 --zone=inz08 --permanent
Sorry could you please clarify what do you mean by this answer ?

Please note, I on ready mentioned that both interfaces are in that zone inz08

Or I'm missing something ?

mghe
Posts: 766
Joined: 2015/11/24 12:04:43
Location: Katowice, Poland

Re: Port forwarding using firewallD through specific interface

Post by mghe » 2017/07/24 03:14:59

Sorry, I have not noticed it,

In that case probably You have to make 2 zone, separate for both interfaces.

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Port forwarding using firewallD through specific interface

Post by jlehtone » 2017/07/24 10:42:10

Overall, forwarding does not care about interfaces. The outgoing interface is determined by routing, not by netfilter.

There are two points in the netfilter:
1. DNAT rule prerouting that changes the destination of incoming packets
2. Forward rule that allows from source to dnatted destination.

In principle the forward rule could be restrictive to not allow traffic via interfaces that the packets would never go anyway, unless the routes are misconfigured.

Post Reply