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.

"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
end

Opties

edit 0Create a new entry instead of editing an existing one; FortiOS assigns the next free ID when the entry is saved.
nextSave the current entry and stay inside the config table to edit another one.
endLeave the config table and commit the changes.
abortLeave 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.

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.

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.

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.

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.

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.

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.

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.

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.

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 clearReset the session filter.
diagnose sys session clearClear every session in the table. Disruptive: every active connection through the firewall is dropped.
Let op: "diagnose sys session clear" terminates all current sessions immediately, which interrupts every active connection passing through the firewall.
execute rebootRestart the FortiGate.
Let op: This drops all traffic passing through the unit until it finishes booting. On an HA cluster, check failover behaves as expected before rebooting the active unit.
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.

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.

Voorbeeld

config system interface
  edit "port1"
    set ip 192.168.1.99 255.255.255.0
    set allowaccess ping https ssh
  next
end

Opties

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.
Let op: Enabling http/telnet (unencrypted management) on an interface facing an untrusted network exposes admin credentials. Prefer https and ssh only, and restrict allowaccess on WAN-facing interfaces.
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.

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.

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-6How 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.
Let op: A broad filter (or none) on a busy interface produces a huge amount of output and can affect CLI responsiveness. Always scope the filter to a specific host or port.
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.

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.
Let op: A new policy with no address or service restriction (both set to "all"/"ALL") and action accept allows all matching traffic. Double check srcaddr/dstaddr/service before enabling a broad policy.
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.

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.

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.

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.

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.
Let op: psksecret is a plaintext secret in the configuration. Treat exported configuration backups as sensitive and never share them unredacted.
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 -1Set IKE debug verbosity to maximum (-1 means all levels).
diagnose debug enableStart printing debug output to the console.
diagnose debug disableStop printing to the console; the debug is still running in the background.
diagnose debug resetFully 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.

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 stopStop tracing manually.
diagnose debug disable diagnose debug resetStop active debugging. "disable" stops console output only; "reset" fully clears all debug settings and filters.
Let op: Always run both commands after a debug/sniffer session. Leaving filters or debugs enabled in the background can affect performance and will unexpectedly reappear if debug output is re-enabled later.
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?

Meer in dit onderdeel

  • Palo Alto (PAN-OS) cheatsheetDoorzoekbare PAN-OS CLI-commandoreferentie: security policy, NAT, VPN en diagnose, met elke parameter uitgelegd.
  • Cisco IOS cheatsheetDoorzoekbare Cisco IOS/IOS-XE-referentie: interfaces, VLAN’s, routering, access lists, port security, STP, EtherChannel, SNMP en NAT, met elke parameter uitgelegd.
  • Nmap cheatsheetDoorzoekbare Nmap-commandoreferentie: host discovery, scantypes, service/OS-detectie, NSE-scripts en timing, met elke optie uitgelegd.

Ook handig

Een probleem gevonden of een suggestie? Laat het ons weten