FortiGate
FortiGate Next Generation Firewall utilizes purpose-built security processors and threat intelligence security services from FortiGuard labs to deliver top-rated protection and high performance, including encrypted traffic.
hbac
Staff
Staff
Article Id 385766
Description This article describes the creation or deletion of a static route via CLI on the FortiGate. It will be useful in case the GUI is inaccessible. 
Scope FortiGate.
Solution

To list active routes in the routing-table, run the command below:

 

get router info routing-table all

Routing table for VRF=0
S* 0.0.0.0/0 [10/0] via 10.9.x.x, port1, [1/0]

 

  1. To create a static route through the CLI: 

 

The following example shows CLI commands to create a static route to destination 192.168.100.0/24: 

 

config router static

    edit 0 

        set dst 192.168.100.0/24                <----- Destination subnet and mask. 

        set device port3                        <----- Interface through which traffic will be forwarded.

        set gateway 192.168.10.2                <----- Next hop IP address.

end 

 

Once the above changes are applied, the new static route will appear in the routing-table: 

 

get router info routing-table all

Routing table for VRF=0
S* 0.0.0.0/0 [10/0] via 10.9.x.x, port1, [1/0]

S  192.168.100.0/24 [10/0] via 192.168.10.2, port3, [1/0]

 

  1. To delete a static route through the CLI:

 

The following example shows CLI commands to delete a static route created in Step 1. 

 

config router static

show                     <----- Shows all static route entries. Based on the output below, entry 2 was created in step 1. 

 

config router static
    edit 1 
        set gateway 10.9.x.x
        set device "port1"
    next
    edit 2
        set dst 192.168.100.0 255.255.255.0
        set gateway 192.168.10.2
        set device "port3"
    next
end

 

To delete entry 2, run the following commands: 

 

delete 2               <----- Deletes entry 2. 

end                    <----- Saves changes. 

 

Related article:

Technical Tip: How to create a static route on FortiGate from the GUI Interface