FortiGate (FortiOS) cheatsheet
Doorzoekbare FortiGate CLI-commandoreferentie: systeem, netwerk, firewallbeleid, VPN en diagnose, met elke parameter uitgelegd.
Draait in je browser · er wordt niets verstuurdNieuw
28 commando’s
CLI basics
config <object>
edit <name-or-id>
set <field> <value>
next
endThe core edit pattern used throughout the FortiOS CLI: enter a config table, edit (or create) one entry, set fields on it, then close the entry and the table.
config <object>
edit <name-or-id>
set <field> <value>
next
endThe core edit pattern used throughout the FortiOS CLI: enter a config table, edit (or create) one entry, set fields on it, then close the entry and the table."next" closes the current entry and lets you edit another one in the same config block. "end" closes the config block itself and applies the changes. Forgetting "end" means the changes are never committed.
Voorbeeld
config firewall policy
edit 0
set name "allow-web"
set srcintf "port1"
set dstintf "port2"
set action accept
set srcaddr "all"
set dstaddr "all"
set schedule "always"
set service "HTTP" "HTTPS"
next
endOpties
edit 0 | Create a new entry instead of editing an existing one; FortiOS assigns the next free ID when the entry is saved. |
|---|---|
next | Save the current entry and stay inside the config table to edit another one. |
end | Leave the config table and commit the changes. |
abort | Leave the config table and discard any uncommitted changes made since entering it. |
get <object> | show <object> | show full-configuration <object>Three ways to read configuration: "get" shows the current settings of the object you are inside; "show" prints the config in script form, but only fields that differ from their default; "show full-configuration" prints every field including defaults.
get <object> | show <object> | show full-configuration <object>Three ways to read configuration: "get" shows the current settings of the object you are inside; "show" prints the config in script form, but only fields that differ from their default; "show full-configuration" prints every field including defaults.Voorbeeld
show full-configuration firewall policy
? (question mark)Press ? at any point in a command to list the available keywords, options or syntax at that position.
? (question mark)Press ? at any point in a command to list the available keywords, options or syntax at that position.Works mid-word too: typing part of a command and pressing ? completes or lists matching options, similar to tab-completion.
config <object>
edit <name> | grep <pattern>Pipe CLI output through grep to filter long listings, for example a full "show" dump.
config <object>
edit <name> | grep <pattern>Pipe CLI output through grep to filter long listings, for example a full "show" dump.Voorbeeld
show firewall policy | grep "edit\|name\|action"
System
get system statusShow the FortiOS version, build number, serial number, operation mode and virtual domain status.
get system statusShow the FortiOS version, build number, serial number, operation mode and virtual domain status.The first command to run on an unfamiliar unit, and useful when reporting a firmware version to Fortinet support.
get system performance statusShow current CPU, memory and network usage, and the top processes by CPU and memory.
get system performance statusShow current CPU, memory and network usage, and the top processes by CPU and memory.Check this first before any deeper CPU troubleshooting with "diagnose sys top".
diagnose sys top {sort} {refresh-seconds} {iterations}Show a live, refreshing list of running processes and their CPU/memory usage, similar to Linux top.
diagnose sys top {sort} {refresh-seconds} {iterations}Show a live, refreshing list of running processes and their CPU/memory usage, similar to Linux top.All three arguments are optional. Press q to quit.
Voorbeeld
diagnose sys top 5
execute tac reportGenerate a diagnostic report file for Fortinet TAC support, bundling configuration, logs and system state.
execute tac reportGenerate a diagnostic report file for Fortinet TAC support, bundling configuration, logs and system state.Use this before opening a support ticket; Fortinet support will usually ask for this file.
diagnose sys session statShow session table statistics: current session count, and the session setup/teardown rate.
diagnose sys session statShow session table statistics: current session count, and the session setup/teardown rate.A quick health check before diving into "diagnose sys session list"; a session count near the unit's rated maximum points at capacity, not a configuration problem.
diagnose sys session filter <field> <value>
diagnose sys session listFilter the live session table on a field (source IP, destination IP, port, policy ID, ...) and then list the matching sessions.
diagnose sys session filter <field> <value>
diagnose sys session listFilter the live session table on a field (source IP, destination IP, port, policy ID, ...) and then list the matching sessions.The filter persists for subsequent "diagnose sys session" commands until cleared. Always set a filter before "list" on a busy firewall, or the output is unmanageable.
Voorbeeld
diagnose sys session filter dst 10.0.0.5 diagnose sys session list
Opties
diagnose sys session filter clear | Reset the session filter. |
|---|---|
diagnose sys session clear | Clear every session in the table. Disruptive: every active connection through the firewall is dropped. |
execute rebootRestart the FortiGate.
execute rebootRestart the FortiGate.execute backup config <tftp|usb|flash> <filename> [server-ip]Save the running configuration to TFTP, a USB drive, or internal flash.
execute backup config <tftp|usb|flash> <filename> [server-ip]Save the running configuration to TFTP, a USB drive, or internal flash.Voorbeeld
execute backup config tftp fgt-backup.conf 192.168.1.10
Network
get system interface | show system interface [<name>]Show the configuration (show) or live status (get) of one or all interfaces.
get system interface | show system interface [<name>]Show the configuration (show) or live status (get) of one or all interfaces.Voorbeeld
show system interface port1
config system interface
edit <port-name>
set ip <ip> <netmask>
set allowaccess <protocols>
next
endSet an interface's IP address and which management protocols are allowed on it.
config system interface
edit <port-name>
set ip <ip> <netmask>
set allowaccess <protocols>
next
endSet an interface's IP address and which management protocols are allowed on it.Voorbeeld
config system interface
edit "port1"
set ip 192.168.1.99 255.255.255.0
set allowaccess ping https ssh
next
endOpties
set ip <ip> <netmask> | IPv4 address and subnet mask for the interface. |
|---|---|
set allowaccess <list> | Space-separated list of management protocols allowed on this interface: ping, https, ssh, http, telnet, snmp, fgfm, etc. Only enable what is needed. |
set mode [static|dhcp|pppoe] | How the interface obtains its IP address. |
get router info routing-table allShow the full routing table, combining static and dynamically learned routes.
get router info routing-table allShow the full routing table, combining static and dynamically learned routes.Add a specific protocol instead of "all" (for example "get router info routing-table static" or "ospf") to narrow the output on a router with many routes.
config router static
edit 0
set dst <network> <netmask>
set gateway <ip>
set device <port-name>
next
endAdd a static route.
config router static
edit 0
set dst <network> <netmask>
set gateway <ip>
set device <port-name>
next
endAdd a static route.Opties
set dst <network> <netmask> | Destination network and subnet mask. Use 0.0.0.0 0.0.0.0 for a default route. |
|---|---|
set gateway <ip> | Next-hop IP address. |
set device <port-name> | Outgoing interface for this route. |
set distance <1-255> | Administrative distance; lower is preferred when multiple routes match. |
diagnose sniffer packet <interface> "<filter>" <verbosity> <count>Capture live packets on an interface using a tcpdump-style filter, printed directly to the CLI.
diagnose sniffer packet <interface> "<filter>" <verbosity> <count>Capture live packets on an interface using a tcpdump-style filter, printed directly to the CLI.Voorbeeld
diagnose sniffer packet port1 "host 10.0.0.5 and port 443" 4 50
Opties
<interface> | Interface name, or "any" to capture on all interfaces. |
|---|---|
"<filter>" | A tcpdump-style filter expression in quotes, for example "host 10.0.0.5 and port 443". |
<verbosity> 1-6 | How much detail per packet: 1 is minimal headers, 3 includes full packet headers, 4+ adds interface and more detail. |
<count> | Number of packets to capture before stopping automatically. Omit to run until Ctrl+C. |
execute ping <ip-or-host>
execute traceroute <ip-or-host>Run ping or traceroute from the FortiGate itself, useful for testing connectivity that does not depend on a client machine.
execute ping <ip-or-host>
execute traceroute <ip-or-host>Run ping or traceroute from the FortiGate itself, useful for testing connectivity that does not depend on a client machine."execute ping-options" and "execute traceroute-options" let you set the source interface, packet size and repeat count before running the test.
Firewall policy
config firewall policy
edit 0
set name "<name>"
set srcintf "<intf>"
set dstintf "<intf>"
set srcaddr "<addr>"
set dstaddr "<addr>"
set action accept
set schedule "always"
set service "<svc>"
next
endCreate or edit a firewall (security) policy, FortiOS's equivalent of a firewall rule.
config firewall policy
edit 0
set name "<name>"
set srcintf "<intf>"
set dstintf "<intf>"
set srcaddr "<addr>"
set dstaddr "<addr>"
set action accept
set schedule "always"
set service "<svc>"
next
endCreate or edit a firewall (security) policy, FortiOS's equivalent of a firewall rule.Opties
set srcintf / set dstintf <name> [<name>...] | Source and destination interface(s) or zone(s) the policy applies to. |
|---|---|
set srcaddr / set dstaddr <name> [<name>...] | Source and destination address objects or groups. Use "all" to match any address. |
set action [accept|deny] | Whether matching traffic is allowed or blocked. |
set schedule "<name>" | Time schedule object the policy is active during. "always" means no time restriction. |
set service <name> [<name>...] | Service object(s), for example HTTP, HTTPS, or a custom service. Use "ALL" to match any service. |
set nat [enable|disable] | Apply source NAT (using the outgoing interface IP, or an IP pool if configured) to matching traffic. |
set logtraffic [all|utm|disable] | Which traffic through this policy gets logged: all sessions, only sessions with a UTM event, or none. |
set utm-status [enable|disable] | Whether UTM profiles (antivirus, IPS, web filter, etc.) attached to this policy are applied. |
config firewall policy
move <policyid> before <policyid>
endReorder a policy in the policy list. Policies are evaluated top to bottom; the first match wins.
config firewall policy
move <policyid> before <policyid>
endReorder a policy in the policy list. Policies are evaluated top to bottom; the first match wins.Use "move <id> after <id>" to move it the other way. Getting the order wrong is one of the most common causes of "my new rule has no effect": a broader rule above it may already be matching the traffic.
config firewall address
edit "<name>"
set subnet <ip> <mask>
next
endCreate an address object (a named IP, subnet or range) for use in policies instead of a raw IP.
config firewall address
edit "<name>"
set subnet <ip> <mask>
next
endCreate an address object (a named IP, subnet or range) for use in policies instead of a raw IP.Opties
set subnet <ip> <mask> | Subnet address object, for example 10.0.0.0 255.255.255.0. |
|---|---|
set type [ipmask|iprange|fqdn|...] | Kind of address object. fqdn resolves a hostname instead of a fixed IP/subnet. |
set fqdn "<hostname>" | Hostname to resolve, when type is fqdn. |
diagnose firewall iprope listShow the compiled, kernel-level policy lookup table FortiOS actually uses to match traffic.
diagnose firewall iprope listShow the compiled, kernel-level policy lookup table FortiOS actually uses to match traffic.Useful when a policy appears correct in "show firewall policy" but traffic still is not matching as expected; this shows the lower-level view.
VPN
get vpn ipsec tunnel summary
diagnose vpn ike gateway listShow the status of configured IPsec tunnels, and detail on IKE gateways (phase 1) specifically.
get vpn ipsec tunnel summary
diagnose vpn ike gateway listShow the status of configured IPsec tunnels, and detail on IKE gateways (phase 1) specifically.A tunnel showing as "down" with phase 1 up but phase 2 down usually points to a selector (local/remote subnet) mismatch between the two ends.
config vpn ipsec phase1-interface
edit "<name>"
set interface "<intf>"
set remote-gw <ip>
set psksecret <key>
next
endCreate the phase 1 (IKE) side of a site-to-site IPsec VPN tunnel.
config vpn ipsec phase1-interface
edit "<name>"
set interface "<intf>"
set remote-gw <ip>
set psksecret <key>
next
endCreate the phase 1 (IKE) side of a site-to-site IPsec VPN tunnel.Opties
set interface "<name>" | Local outgoing interface for the tunnel. |
|---|---|
set remote-gw <ip> | Public IP of the remote VPN peer. |
set psksecret <key> | Pre-shared key; must match exactly on both ends. |
set ike-version [1|2] | IKE protocol version. Must match the remote peer. |
set proposal <list> | Allowed encryption/authentication algorithm combinations offered during negotiation. |
diagnose vpn ike log-filter dst-addr4 <peer-ip>
diagnose debug application ike -1
diagnose debug enableFilter and then enable verbose IKE negotiation debugging, to troubleshoot a tunnel that will not come up.
diagnose vpn ike log-filter dst-addr4 <peer-ip>
diagnose debug application ike -1
diagnose debug enableFilter and then enable verbose IKE negotiation debugging, to troubleshoot a tunnel that will not come up.Always filter first (log-filter) on a firewall with many tunnels, or the debug output from every tunnel mixes together. Run "diagnose vpn ike log-filter clear" and "diagnose debug disable" when done.
Opties
diagnose debug application ike -1 | Set IKE debug verbosity to maximum (-1 means all levels). |
|---|---|
diagnose debug enable | Start printing debug output to the console. |
diagnose debug disable | Stop printing to the console; the debug is still running in the background. |
diagnose debug reset | Fully stop and clear all debug settings, including ones not currently printing. |
Diagnose & debug
diagnose debug flow filter <field> <value>
diagnose debug flow trace start <count>
diagnose debug enableTrace how the firewall processes specific packets step by step: routing lookup, policy match, NAT, UTM inspection.
diagnose debug flow filter <field> <value>
diagnose debug flow trace start <count>
diagnose debug enableTrace how the firewall processes specific packets step by step: routing lookup, policy match, NAT, UTM inspection.This is the most detailed way to see exactly why traffic is or is not being allowed. Always set a filter (source/destination IP, port) first; an unfiltered trace on production traffic is unreadable.
Voorbeeld
diagnose debug flow filter saddr 10.0.0.5 diagnose debug flow trace start 20 diagnose debug enable
Opties
diagnose debug flow filter <field> <value> | Restrict the trace to packets matching this field, for example saddr, daddr, port. |
|---|---|
diagnose debug flow trace start <count> | Start tracing and stop automatically after this many matching packets. |
diagnose debug flow trace stop | Stop tracing manually. |
diagnose debug disable
diagnose debug resetStop active debugging. "disable" stops console output only; "reset" fully clears all debug settings and filters.
diagnose debug disable
diagnose debug resetStop active debugging. "disable" stops console output only; "reset" fully clears all debug settings and filters.get system ha statusShow HA cluster status: which unit is primary, synchronization state, and uptime per member.
get system ha statusShow HA cluster status: which unit is primary, synchronization state, and uptime per member.Run this before and after any maintenance on a clustered pair to confirm both members stay in sync.
De omschrijvingen in dit naslagwerk zijn voorlopig in het Engels.
Uitleg
Zoek of filter op groep en kopieer een commando met één klik. Open een commando voor uitleg, een voorbeeld en elke parameter die het accepteert, met waarschuwingen bij alles dat sessies kan verbreken of beheertoegang kan blootstellen.
🔒 Je invoer blijft in je browser en wordt nergens naartoe gestuurd.
Veelgestelde vragen
Wat is het verschil tussen next en end in de FortiOS CLI?
"next" bewaart het huidige item en laat je een ander item bewerken binnen dezelfde configtabel. "end" verlaat de tabel helemaal en past de wijzigingen toe. "end" vergeten betekent dat niets wordt toegepast.
Wat nu?
Een probleem gevonden of een suggestie? Laat het ons weten