How to reveal the security policy that denied/permitted packets?
Hi folks!!
My Fortigate fw 40F OS 6.4.10 running in NGFW mode Policy-based.
OBJECT:
Display packets being denied/permitted by the Fortigate firewall policy; and reveal which policy denied or permitted the packets.
Fortigate fw running in Policy-based mode does not support the GUI policy lookup option.
What has been performed to reveal this data:
I have specifically enabled 2 test policies Internet-22 and Internet-69 to block packets from reaching Google DNS (test subject) via port 22 or 69.
OPTION-1:
If I use the diag sniffer packet any ‘host 192.168.0.101 and tcp port 22’ 1 0 l, I see the packets but cannot determine if any Fortigate fw policy is blocking the packets and
communications still fail. Note: I understand Google is not allowing tcp communications on port 22, this is just a test case.
OPTION-2
If I use the diag debug capture option it appears packets are being allowed to reach google as
shown by id=20085 trace_id=92 func=fw_forward_handler line=811 msg="Allowed by Policy-1: SNAT".
OPTION-3
?
I must be doing something wrong or just don’t understand how to read the output, can anyone provide guidance?
Thank you.
Jimmy
Test-lab # diagnose sniffer packet any 'host 192.168.0.101 and tcp port 22' 1 0 l
interfaces=[any]
filters=[host 192.168.0.101 and tcp port 22]
2023-07-23 19:42:05.006311 192.168.0.101.7245 -> 8.8.8.8.22: syn 1681993287
2023-07-23 19:42:06.019218 192.168.0.101.7245 -> 8.8.8.8.22: syn 1681993287
2023-07-23 19:42:08.023414 192.168.0.101.7245 -> 8.8.8.8.22: syn 1681993287
2023-07-23 19:42:12.024036 192.168.0.101.7245 -> 8.8.8.8.22: syn 1681993287
2023-07-23 19:42:20.038212 192.168.0.101.7245 -> 8.8.8.8.22: syn 1681993287



diag debug reset
diag debug flow filter clear
diag debug flow filter daddr 8.8.8.8
diag debug flow filter port 22
diag debug flow show function-name enable
diag debug flow trace start 30
diag debug enable
id=20085 trace_id=92 func=print_pkt_detail line=5824 msg="vd-root:0 received a packet(proto=6, 192.168.0.101:2690->8.8.8.8:22) from a. flag [S], seq 3902402880, ack 0, win 64240"
id=20085 trace_id=92 func=init_ip_session_common line=5995 msg="allocate a new session-00000a90"
id=20085 trace_id=92 func=vf_ip_route_input_common line=2615 msg="find a route: flag=04000000 gw-<Public.IP.addr.removed> via wan"
id=20085 trace_id=92 func=fw_forward_handler line=811 msg="Allowed by Policy-1: SNAT"
id=20085 trace_id=92 func=__ip_session_run_tuple line=3519 msg="SNAT 192.168.0.101->Public.IP.addr.removed:61310"
id=20085 trace_id=92 func=ipd_post_route_handler line=490 msg="out wan vwl_zone_id 0, state2 0x0, quality 0."
id=20085 trace_id=92 func=np6xlite_hif_nturbo_build_vtag line=1100 msg="np6xlite_hif_nturbo_build_vtag: vtag->magic d153beef, vtag->coretag 64, vtag->vid 0
vtag->sip[0] 55572a3f, vtag->sip[1] 0, vtag->sip[2] 0, vtag->sip[3] 0
vtag->sport 32495, vtag->mtu 1500, vtag->flags 12, vtag->np6_index 1, skb->npu_flag=0xc0880"
id=20085 trace_id=93 func=print_pkt_detail line=5824 msg="vd-root:0 received a packet(proto=6, 192.168.0.101:2690->8.8.8.8:22) from a. flag [S], seq 3902402880, ack 0, win 64240"
id=20085 trace_id=93 func=resolve_ip_tuple_fast line=5905 msg="Find an existing session, id-00000a90, original direction"
id=20085 trace_id=93 func=npu_handle_session44 line=1217 msg="Trying to offloading session from a to wan, skb.npu_flag=00000000 ses.state=00053200 ses.npu_state=0x00003008"
id=20085 trace_id=93 func=fw_forward_dirty_handler line=397 msg="state=00053200, state2=00000000, npu_state=00003008"
id=20085 trace_id=94 func=print_pkt_detail line=5824 msg="vd-root:0 received a packet(proto=6, 192.168.0.101:2690->8.8.8.8:22) from a. flag [S], seq 3902402880, ack 0, win 64240"
id=20085 trace_id=94 func=resolve_ip_tuple_fast line=5905 msg="Find an existing session, id-00000a90, original direction"
id=20085 trace_id=94 func=npu_handle_session44 line=1217 msg="Trying to offloading session from a to wan, skb.npu_flag=00000000 ses.state=00053200 ses.npu_state=0x00003008"
id=20085 trace_id=94 func=fw_forward_dirty_handler line=397 msg="state=00053200, state2=00000000, npu_state=00003008"
id=20085 trace_id=95 func=print_pkt_detail line=5824 msg="vd-root:0 received a packet(proto=6, 192.168.0.101:2690->8.8.8.8:22) from a. flag [S], seq 3902402880, ack 0, win 64240"
id=20085 trace_id=95 func=resolve_ip_tuple_fast line=5905 msg="Find an existing session, id-00000a90, original direction"
id=20085 trace_id=95 func=npu_handle_session44 line=1217 msg="Trying to offloading session from a to wan, skb.npu_flag=00000000 ses.state=00053200 ses.npu_state=0x00003008"
id=20085 trace_id=95 func=fw_forward_dirty_handler line=397 msg="state=00053200, state2=00000000, npu_state=00003008"
id=20085 trace_id=96 func=print_pkt_detail line=5824 msg="vd-root:0 received a packet(proto=6, 192.168.0.101:2690->8.8.8.8:22) from a. flag [S], seq 3902402880, ack 0, win 64240"
id=20085 trace_id=96 func=resolve_ip_tuple_fast line=5905 msg="Find an existing session, id-00000a90, original direction"
id=20085 trace_id=96 func=npu_handle_session44 line=1217 msg="Trying to offloading session from a to wan, skb.npu_flag=00000000 ses.state=00053200 ses.npu_state=0x00003008"
id=20085 trace_id=96 func=fw_forward_dirty_handler line=397 msg="state=00053200, state2=00000000, npu_state=00003008"
