Hello CheckMates,
I'm struggling with an issue with PBR ... and I hope you will be able to put some light on this one.
Customer wants that some traffic should go different path then via default route ... so it's obvious that this is case for PBR.
But it doesn't work as expected.
I was able to recreate similar environment in my lab and it looks like this:
1) I have a Access Control rule:

So as you can see any traffic FROM debian (10.20.200.222) will be matched.
2) PBR was configured to be Application Aware (it's a shame that this is hidden by default) - so I can create a rule in PBR that will tell gateway that it should match rule 1:

3) Table 1: router forward traffic to different router (in my case 10.99.99.203)
So ... as you can see ... nothing odd, just a normal, simple PBR config.
This 10.99.99.203 router doesn't have network 10.20.200.0/24, but knows who has this network - based on static-route entry:

10.99.99.234 = my gateway, where I created PBR, etc.
Ok, now you know how it is configured ... but I will explain this below (just to be sure, you know everything 😛 ) :
1) traffic (for example ping to 8.8.4.4) from 10.20.200.222 arrives on incoming interface on my router (10.99.99.234)
2) Access Control policy knows that it should be accepted and not send to external interface of this gateway, but to interface where 10.99.99.203 is connected
3) then this traffic arrives on router 10.99.99.203 and is accepted and is send to the internet
4) return traffic from 8.8.4.4 arrives on 10.99.99.203 and because this router doesn't have 10.20.200.0/24 network it will not forward this reply directly to "debian" ... but it will forward this traffic to 10.99.99.234 (via static-route)
5) so ... return traffic from 8.8.4.4 to 10.20.200.222 arrives on my gateway on interface where 10.99.99.203 is connected, and then it should go to "debian"
Simple...
But it doesn't work like that.
Take a look how it works (steps 1-5 from the above description):
ad. 1)
root@debian:~# ping 8.8.4.4
PING 8.8.4.4 (8.8.4.4) 56(84) bytes of data.
ad. 2)
SG (10.99.99.234):
[vs_0][fw_1] eth2:i[44]: 10.20.200.222 -> 8.8.4.4 (ICMP) len=84 id=53134
[vs_0][fw_1] eth2:I[44]: 10.20.200.222 -> 8.8.4.4 (ICMP) len=84 id=53134
[vs_0][fw_1] eth0:o[44]: 10.20.200.222 -> 8.8.4.4 (ICMP) len=84 id=53134
[vs_0][fw_1] eth0:O[44]: 10.20.200.222 -> 8.8.4.4 (ICMP) len=84 id=53134
(traffic leaves 10.99.99.234 and goes to 10.99.99.203)
ad. 3)
router (10.99.99.203) - also Check Point:
[vs_0][fw_2] eth0:i[44]: 10.20.200.222 -> 8.8.4.4 (ICMP) len=84 id=53362
[vs_0][fw_2] eth0:I[44]: 10.20.200.222 -> 8.8.4.4 (ICMP) len=84 id=53362
[vs_0][fw_2] eth1:o[44]: 10.20.200.222 -> 8.8.4.4 (ICMP) len=84 id=53362
[vs_0][fw_2] eth1:O[44]: 203.0.113.203 -> 8.8.4.4 (ICMP) len=84 id=53362
(as you can see there is a NAT)
ad. 4)
[vs_0][fw_2] eth1:i[44]: 8.8.4.4 -> 203.0.113.203 (ICMP) len=84 id=0
[vs_0][fw_2] eth1:I[44]: 8.8.4.4 -> 10.20.200.222 (ICMP) len=84 id=0
[vs_0][fw_2] eth0:o[44]: 8.8.4.4 -> 10.20.200.222 (ICMP) len=84 id=0
[vs_0][fw_2] eth0:O[44]: 8.8.4.4 -> 10.20.200.222 (ICMP) len=84 id=0
(traffic leaves 10.99.99.203 and goes to 10.99.99.234)
ad. 5)
And .. here is my issue:
[vs_0][fw_1] eth0:i[44]: 8.8.4.4 -> 10.20.200.222 (ICMP) len=84 id=0
[vs_0][fw_1] eth0:I[44]: 8.8.4.4 -> 10.20.200.222 (ICMP) len=84 id=0
[vs_0][fw_1] eth0:o[44]: 8.8.4.4 -> 10.20.200.222 (ICMP) len=84 id=0
[vs_0][fw_1] eth0:O[44]: 8.8.4.4 -> 10.20.200.222 (ICMP) len=84 id=0
(traffic enters 10.99.99.234 on eth0 interface ... and stays here ... it is not routed to eth2 interface where this debian host exists)
fw ctl zdebug + drop:
@;137323;[cpu_1];[fw4_2];fw_log_drop_ex: Packet proto=1 8.8.4.4:0 -> 10.20.200.222:19315 dropped by fw_first_packet_state_checks Reason: ICMP reply does not match a previous request;
Do you have any idea what is wrong here ?
In case router 10.99.99.203 would have this network 10.20.200.0/24 there will be no issue at all, because return traffic would go directly from this router to "debian" ... but in this case this return traffic needs to go back to 10.99.99.234.
And By The Way ... another issue:
(this rule was disabled in above example ... that's why I had no NAT)
In case Customer would have Manual NAT rule ... not Automatic one ... PBR is doing NAT... and I have absolutely no idea why ?
For Automatic NAT - it will not do NAT for this PBR.
Take a look how my Manual NAT rule looks like:

So ... normal SNAT rule - any traffic from 10.20.200.0/24 to ExternalZone should be hidden behind Gateway's external IP.
But ... 10.99.99.203 router (this one in PBR rule) ... is behind interface that has InternalZone 🙂
Why this rule matches this traffic ? ... it looks like NAT is matched before routing ... and because of that Gateway decides that 8.8.4.4 is reachable via eth1 (external) interface ... not eth0 (here is this 10.99.99.203).
Anybody ? 🙂
--
Best
m.