Description | This article describes how to block specific ports. |
Scope | FortiGate. |
Solution |
In this scenario, the configuration has been setup to block the TCP port 4433 for outgoing traffic. A new service object is created followed by the outbound firewall policy that references the specific service to block.
Access the FortiGate web interface:
Adjust the following settings:
It is possible to customize the port by creating a new service as below: Go to Policy & Object -> Services -> Create New. Action: Set the action to Deny to block the traffic.
Save the new firewall policy.
In the CLI:
config firewall service custom
config firewall policy set action deny
In this example, policy is configured from LAN (port3) to WAN (port1).
Once the traffic reaches the FortiGate, it will be dropped by the policy. The debug and sniffer outputs for port 4433 are shown below.
Debug:
FGT-GRG # id=65308 trace_id=1 func=print_pkt_detail line=5942 msg="vd-root:0 received a packet(proto=6, 10.10.10.2:55925->142.250.203.238:4433) tun_id=0.0.0.0 from port3. flag [S], seq 568628668, ack 0, win 64240"
Sniffer:
FGT-GRG # diagnose sniffer packet any "port 4433" 4 0 l
Using Original Sniffing Mode:
interfaces=[any]
The syn packet is not being sent out.
To block local traffic, the following document can be used:local-in-policy
Open ports can be checked with the commands:
diagnose sys tcpsock <----- For TCP traffic and: diagnose sys udpsock <----- For UDP traffic .
If there is some specific port that needs to be checked, the grep function comes in handy. For this specific case about TCP port 4433, the following command should be used:
diagnose sys tcpsock | grep 4433
The lack of any output points out that the port is not open. |
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2025 Fortinet, Inc. All Rights Reserved.