Firewall filter rules do not affect marked routes

Good morning my friends,
I’m new to mikrotik’s world but I really want to solve this problem. This is the situation:
I have a mikrotik CCR1009-7G-1C-1S+ cloud router and two vdsl routers from different providers.
I cannot ppp my provider routers cause in italy they don’t release any user or password, so I have a double nat for each provider.

eth1 is connected to provider 1 vdsl router 192.168.30.1 - eth1 mikrotik address 192.168.30.2
eth2 is connected to provider 2 vdsl router 192.168.130.1 - eth2 mikrotik address 192.168.130.2
eth7 is my local lan 192.168.25.0/25

I have 2 routes one for provider 1
0.0.0.0/0 gateway 192.168.30.1 distance 1
and the second one for provider 2
0.0.0.0/0 gateway 192.168.130.1 distance 2

For eth1 interface everything is working perfect(firewall,filter rules, internet, forwarding etc) problems come when I want to forward ports to eth2

I forwarded port 80 to 192.168.25.6 through eth2 in nat rules and then
what I did is an ip->firewal->mangle mark routing for this specific src addres and added a route to this mark so all traffic for this ip is forced through eth2
and this is working very well.
Problems comes with firewall filter rules, they simply won’t work, I can’t drop or specify traffic filters cause they don’t affect eth2 but only eth1.
I have searched a lot and find some posts about this problem, they talk about the fact that firewall filter rules only affects main routing table, so marked tables are excluded, this can be fixed with the function ip->routes->rules “lookup only in table”.
But I cannot make this to works.. any suggestion?
many thanks

Export your configuration and post it so we can take a look.

thank you for your reply and sorry for my late answer
this is my configuration

# jul/24/2017 18:38:02 by RouterOS 6.36.4
# software id = BXAR-5YJB
#
/interface ethernet
set [ find default-name=ether1 ] name="ether1-fibra telecom"
set [ find default-name=ether2 ] name="ether2-fibra backup"
set [ find default-name=ether7 ] name="ether7-local lan"

/ip address
add address=192.168.25.62/25 interface="ether7-local lan" network=\
    192.168.25.0
add address=192.168.30.2/25 interface="ether1-fibra telecom" network=\
    192.168.30.0
add address=192.168.130.2/24 interface="ether2-fibra backup" network=\
    192.168.130.0

	
/ip firewall filter
add action=drop chain=input in-interface="ether2-fibra backup"
add action=accept chain=forward in-interface="ether1-fibra telecom" protocol=\
    tcp src-port=1723
add action=accept chain=forward in-interface="ether1-fibra telecom" protocol=\
    gre
add action=accept chain=input dst-port=500 protocol=udp
add action=accept chain=input dst-port=4500 protocol=udp
add action=accept chain=input dst-port=1701 protocol=udp
add action=accept chain=input protocol=ipsec-ah
add action=accept chain=input protocol=ipsec-esp
add action=drop chain=input in-interface="ether1-fibra telecom"


/ip firewall mangle
add action=mark-routing chain=prerouting new-routing-mark=fibra-backup \
    passthrough=yes src-address=192.168.25.6
	
	
/ip firewall nat
add action=masquerade chain=srcnat out-interface="ether1-fibra telecom"
add action=masquerade chain=srcnat out-interface="ether2-fibra backup"
add action=masquerade chain=srcnat out-interface=ether6
add action=dst-nat chain=dstnat dst-port=1194 in-interface=\
    "ether1-fibra telecom" protocol=udp to-addresses=192.168.25.7 to-ports=\
    1194
add action=dst-nat chain=dstnat dst-port=1195 in-interface=\
    "ether1-fibra telecom" protocol=udp to-addresses=192.168.25.76 to-ports=\
    1195
add action=dst-nat chain=dstnat dst-port=23 protocol=tcp to-addresses=\
    192.168.25.106 to-ports=23
add action=dst-nat chain=dstnat dst-port=80 in-interface=\
    "ether2-fibra backup" protocol=tcp to-addresses=192.168.25.6 to-ports=80
	
/ip route
add distance=1 gateway=192.168.130.1 routing-mark=fibra-backup
add distance=1 gateway=192.168.30.1
add distance=2 gateway=192.168.130.1

/ip route rule
add action=lookup-only-in-table routing-mark=main table=fibra-backup

with this as I said firewall rules on input interface ether2 fibra backup simply won’t work, you can see that there is a drop rule on top for input interface fibra backup but I can easily access the web server 192.168.25.6:80.

I have already tried

/ip route rule
add action=lookup-only-in-table routing-mark=fibra-backup table=main

with same results

Just a quick look as I have other stuff to do, but your ether2 drop rule is in the input chain. I assume that should be in the forward chain.

/ip firewall filter
add action=drop chain=input in-interface=“ether2-fibra backup”

why this? with ether1 - fibra telecom the drop input chain is working for everything that comes outside of my network. anyway I tried your suggestion and is working but this drop also the traffic from the server to the world.

dstnat happens before filter. That’s why it is working.
A dstnatted connection is kept in the forward chain, not in input.
And then k6cc’s answer is correct.
-Chris

ok thanks for your clarification it was very useful, but with a drop forward rule I cannot access internet anymore for the local server 192.168.25.6 that have traffic forced throuh ether2.

That means that your drop rule is to loose.
add src-address=0.0.0.0.0/0 (every unknown address, i.e. from the outside world)
add connection-state=new,invalid (this will only drop attempts for new or invalid connections - established and related are not affected)
Add another accept rule for “established, related” on top of that rule.

-Chris

ok is working, but I really can’t understand why I have to specify so many parameters. with ether1 is simple, just add the drop rule for everything and then on top the accept rule for external ip that I want to autorize.

As said before - you’re dealing with the forward chain and there’s more paramters to keep track of.
Input is simple - do I want a connection to my router? Yes or no.
Forward: Do I want a connection to (a huge list of clients follows). Do I want reply traffic? To where? From where? Is my client allowed to establish new connection or should it only reply to requests?
Are other clients allowed to do so?

Don’t forget to copy your ether-1 input rule for ether2 as well, in case you just changed the chain from input to forward. If you don’t your router is now wide open to the world on ether2.

-Chris

ok thank you my friend for your useful suggestions