Routing in FortiGate
Routing in FortiGate
Next Hop?
Each route in the routing table indicates the next hop for a particular destination. The next hop
refers to the outgoing interface and gateway to use for forwarding the packet. The next hop can
be the destination of the packet or another router along the path to the destination. If the next
hop isn’t the destination, the next router in the path routes the packet to the next hop.
Routing Process?
The routing process is repeated on each router along the path until the packet reaches its
destination.
Route Lookup?
To route packets, FortiGate performs a route lookup to identify the best route to the destination.
Best Route?
The best route is the most specific route to the destination.
Duplicate Routes?
If FortiGate finds duplicate routes—multiple routes to the same destination—it uses various
route attributes as a tiebreaker to determine the best route.
Note That:
Routing takes place before most security features. For example, routing precedes firewall policy
evaluation, content inspection, traffic shaping, and source NAT (SNAT). This means that the
security actions that FortiGate performs depend on the outgoing interface determined by the
routing process. This also means that your security policy configuration must follow your routing
configuration, and not the opposite.
For each session, FortiGate performs two route lookups:
• For the first packet sent by the originator
• For the first reply packet coming from the responder
After completing these two lookups, FortiGate writes the routing information to its
session table. Subsequent packets are routed according to the session table, not the routing
table. So, all packets that belong to the same session follow the same path. However, there is an
exception to this rule: if there is a change in the routing table that impacts the session, then
FortiGate removes the route information for the session table, and then performs additional
route lookups to rebuild this information.
✓ RIB:
The routing table, also known as the routing information base (RIB), is a standard routing
table containing active (or the best) connected, static, and dynamic routes.
✓ FIB:
The forwarding information base (FIB) can be described as the routing table from the
kernel point of view, and is built mostly out of RIB entries plus some system-specific
entries required by FortiOS.
When FortiGate performs a route lookup, it checks the FIB and not the RIB. However, because
the FIB is composed mostly by RIB entries, then the route lookup mainly involves checking routes
from the RIB. For this reason, the route lookup is often referred to as the routing table lookup
process. Nonetheless, a more accurate statement is to refer to it as the FIB lookup process. You
can display the RIB entries on the FortiGate GUI and CLI. However, for the FIB, you can display
its entries on the FortiGate CLI only. The output on this slide shows the CLI command that displays the FIB.
One type of manually configured route is called a static route. When you configure a static route,
you are telling FortiGate, “When you see a packet whose destination is within a specific range,
send it through a specific network interface, towards a specific router.”
You can also configure the distance and priority so that FortiGate can identify the best route to
any destination matching multiple routes.
For example, in simple home networks, DHCP automatically retrieves and configures a route.
Your modem then sends all outgoing traffic through your ISP internet router, which can relay
packets to their destination. This is typically referred to as a default route, because all traffic not
matching any other routes will, by default, be routed using this route. The example shown on
this slide is a default route. The destination subnet value of 0.0.0.0/0.0.0.0 matches all addresses
within any subnet. Most FortiGate devices deployed at the edge of the network have at least one
of these default routes to ensure internet traffic is forwarded to the ISP network. Static routes
are not needed for subnets to which FortiGate has direct Layer 2 connectivity.
The default route tells FortiGate where to send traffic when packets do not include an exact
match for the destination address in the FortiGate routing table. Usually, all the users that are
behind FortiGate need a default route in order to have internet access.
In the default route, the destination address is set to 0.0.0.0. The gateway address is typically the
address of another router, either a device in your network that is between FortiGate and the
network edge, or part of your ISP network if FortiGate is located on the network edge. Finally,
the interface is the FortiGate port that connects to that router, typically the WAN interface.
Static Routes with Named Addresses
If you create a firewall address object with the type Subnet or FQDN, you can use that firewall
address as the destination of one or more static routes. First, enable Static route configuration
in the firewall address configuration. After you enable it, the firewall address object becomes
available for use in the Destination drop-down list for static routes with named addresses.
The routing monitor widget on the dashboard page enables you to view the routing table and
policy route table entries. Dashboard > Network > Static & Dynamic Routing
The routing table contains the best routes (or active routes) of the following type:
• Dynamic: routes learned using a dynamic routing protocol such as BGP or OSPF. FortiGate
installs these routes automatically in the routing table and indicates the dynamic routing
protocol used.
To view the routing table entries, select Static & Dynamic, as shown on this slide. However, keep
in mind that the routing table doesn’t contain the following routes:
• Inactive routes: static and connected routes whose interfaces are administratively down or
whose links are down. Static routes are also marked inactive when their gateway is detected as
dead by the link health monitor.
• Standby routes: These are active routes that are removed from the routing table because
they are duplicate and have higher distances. For instance:
➢ A second static default route with a higher distance than another static default route.
➢ A dynamic route such as BGP or OSPF, to the same destination as another static route.
However, the dynamic route is not displayed in the routing table because the static route
has a lower distance.
• Policy routes: These include regular policy routes (PBR), ISDB routes, and SD-WAN rules.
Policy routes are viewed in a separate table— the policy route table. To view the policy route
table entries, select Policy.
Distance, or administrative distance (AD), is the first tiebreaker that routers use to determine the
best route for a particular destination. If there are two or more routes to the same destination
(duplicate routes), the lowest-distance route is considered the best route and, as a result, is
installed in the routing table. Other lower-distance routes to the same destination are standby
routes and, as a result, are not installed in the routing table. Instead, they are installed in the
routing table database.
Lower AD Route ➔ is Installed in the Routing Table
Other lower-distance routes ➔ are Installed in the Routing Table Database
Default Administrative Distance:
You can set the distance for all route types except connected and IS-IS routes—both are
hardcoded and their distance value cannot change.
In case FortiGate learns two equal-distance routes to the same destination but that are sourced
from different protocols, then FortiGate installs in the routing table the route that was learned
last. For example, if you set the distance of BGP routes to 110, and there is another OSPF route
to the same destination using the default administrative distance (110), then FortiGate keeps
whichever route was learned last in the routing table. Because this behavior can lead to different
results based on the timing of events, then it’s not recommended to configure differentprotocol
routes with the same distance.
When a dynamic route protocol learns two or more routes to the same destination, it uses the
metric as a tiebreaker to identify the best route. The lower the metric, the higher the
preference. The dynamic routing protocol then installs the best route in the routing table and
the higher metric routes in the routing table database.
Lower Metric Route ➔ is Installed in the Routing Table
Higher Metric routes ➔ are Installed in the Routing Table Database
Note that the metric is used as tiebreaker for same protocol dynamic routes, and not between
different-protocol dynamic routes.
The metric calculation differs among routing protocols. For example, RIP uses the hop count,
which is the number of routers the packet must pass through to reach the destination. OSPF uses
cost, which is determined by the link bandwidth.
What is ECMP static routes?
When there are two or more duplicate static routes that have the same distance,
FortiGate installs all of them in the routing table. If they also have the same
priority, then the routes are known as ECMP static routes, and you will learn more
about them in this lesson.
Route Attributes?
AD, Metric, Priority, Weight, ...
This command doesn't show standby or inactive routes, which are present in the routing table
database only. For example, when two static routes to the same destination subnet have
different distances, the one with the lower distance is installed in the routing table, and the one
with the higher distance in the routing table database.
Each of the routes listed in the routing table includes several attributes with associated values.
The Network column lists the destination IP address and subnet mask to match. The Interfaces
column lists the interface to use to deliver the packet. The Distance, Metric, and Priority
attributes are used by FortiGate to make various route selection decisions.
This slide shows the command you can run to display the routing table on the FortiGate CLI. The
get router info routing-table all command displays the same route entries as
the routing monitor widget on the FortiGate GUI.
You can perform a route lookup on the routing monitor widget by clicking Route Lookup. Then,
you must indicate at least the destination address to look up for, and optionally, the destination
port, source address, source port, protocol, and source interface. The way the route lookup
works is as follows:
• If you don’t provide all lookup criteria, FortiGate considers only the routing table entries.
FortiGate then highlights the matching route, if any.
• If you provide all lookup criteria, FortiGate considers both routing table and policy table
entries.
If the lookup matches a policy route (PBR), the GUI redirects you to the policy route page, and
then highlights the corresponding matching policy route. The example on this slide shows a route
lookup tool for 8.8.8.8 and TCP as destination address and protocol, respectively. Because the
administrator doesn’t provide all criteria, FortiGate considers the routing table entries only.
Then, the route lookup highlights the static default route as the matching route.
The RPF check is a mechanism that protects FortiGate and your network from IP spoofing
attacks by checking for a return path to the source in the routing table.
Whenever a packet arrives at one of the interfaces on a FortiGate, the FortiGate determines
whether the packet was received on a legitimate interface by doing a reverse look-up using the
source IP address in the packet header. This protects against IP spoofing attacks. If the FortiGate
does not have a route to the source IP address through the interface on which the packet was
received, the FortiGate drops the packet as per Reverse Path Forwarding (RPF) check.
• Strict: In this mode, FortiGate also verifies that the matching route is the best route in the
routing table. That is, if the routing table contains a matching route for the source address and
incoming interface, but there is a better route for the source address through another interface,
then, the RPF check fails.
This slide also shows how to change the RPF check mode on the FortiGate CLI, as well as how to
disable the RPF check on the interface level.
So far, you’ve learned about the different route attributes that FortiGate looks at to identify the
best route to a destination. But what happens when two or more routes of the same type have
the same destination, distance, metric, and priority? These routes are called equal cost
multipath (ECMP) routes, and FortiGate installs all of them in the routing table. FortiGate also
load balances the traffic among the ECMP routes.
ECMP pre-requisites are as follows:
• Routes must have the same destination and costs. In the case of static routes, costs
include distance and priority
• Routes are sourced from the same routing protocol. Supported protocols include static
routing, OSPF, and BGP
Example:
The example on this slide shows two ECMP static routes, two ECMP BGP routes, and two ECMP
OSPF routes. For each ECMP group, the destination subnet, distance, metric, and priority are the
same. The result is that FortiGate installs both routes of each ECMP group in the routing table.
ECMP can load balance sessions using one of the following four
algorithms:
• Source IP: This is the default algorithm. FortiGate uses the same ECMP route to route
sessions sourced from the same address.
• Source-destination IP: FortiGate uses the same ECMP route to route sessions with the same
source-destination IP address pair.
• Weighted: Applies to static routes only. FortiGate load balances sessions based on the route
weight or the respective interface weight. The higher the weight, the more sessions FortiGate
routes through the selected route.
For a weighted algorithm, you must configure the weights on the interface level or route level.
The weight that you assign to each interface is used to calculate the percentage of the total
sessions that are allowed to connect through an interface, and the sessions are distributed to
the interfaces accordingly.
• Usage (spillover): FortiGate sends sessions to the interface of the first ECMP route until the
bandwidth of the interface reaches the configured spillover limit. After the spillover limit is
reached, FortiGate uses the interface of the next ECMP route.
• If SD-WAN is disabled, you can change the ECMP load balancing algorithm on the FortiGate
CLI using the commands shown on this slide.
• When SD-WAN is enabled, FortiOS hides the v4-ecmp-mode setting and replaces it with
the load-balance-mode setting under config system sdwan. That is, when you
enable SDWAN, you control the ECMP algorithm with the load-balance-mode setting.
• For spillover to work, you must also configure the egress and ingress spillover thresholds, as
shown on this slide. The thresholds are set to 0 by default, which disables spillover check.
• For a weighted algorithm, you must configure the weights on the interface level or route
level, as shown on this slide. If two or more routes are added to the routing table, and you set
v4-ecmp-mode to weight-based, FortiGate routes sessions based on the weight value
of each route in the percentage value.
Result:
Both routes are added to the routing table and load-balanced based on the source IP.
Result:
Both routes are added to the routing table, but traffic is routed to port2 which has a lower
priority value with a default of 0.
Example 3: Weight-based ECMP
config router static
edit 3
set dst 10.10.30.0 255.255.255.0
set weight 80
set device "vpn2HQ1"
next
edit 5
set dst 10.10.30.0 255.255.255.0
set weight 20
set device "vpn2HQ2"
next
end Copy
# get router info routing-table all
Routing table for VRF=0
...
S 10.10.30.0/24 [10/0] is directly connected, vpn2HQ1, [0/80]
[10/0] is directly connected, vpn2HQ2, [0/20]
C 172.16.151.0/24 is directly connected, port1
C 192.168.0.0/24 is directly connected, port3
C 192.168.2.0/24 is directly connected, port2
Result:
Both routes are added to the routing table, but 80% of the sessions to 10.10.30.0/24 are routed
to vpn2HQ1, and 20% are routed to vpn2HQ2.
vs.
When you enable SD-WAN, FortiOS hides the v4-ecmp-mode setting and replaces it with the
load-balance-mode setting under config system sdwan. That is, after you enable
SDWAN, you now control the ECMP algorithm with the load-balance-mode setting.
There are some differences between the two settings:
• The main difference is that load-balance-mode supports the volume algorithm,
and v4-ecmp-mode does not.
• In addition, the related settings such as weight and spillover thresholds are configured
differently. That is, when you enable SD-WAN, the weight and spillover thresholds are
defined on the SD-WAN member configuration. When you disable SDWAN, the weight and
spillover thresholds are defined on the static route and interface settings, respectively.
When you set the ECMP algorithm to volume— this is when SD-WAN is enabled, FortiGate load
balances sessions across members based on the measured interface volume and the member
weight. That is, the volume algorithm instructs FortiGate to track the cumulative number of
bytes of each member and to distribute sessions based on the weight. The higher the weight, the
higher the target volume of the interface and, as a result, the more traffic FortiGate sends to it.
In this lab, you will configure the router settings and test scenarios to learn how FortiGate
makes routing decisions.
Objectives
• Route traffic based on the destination IP address, as well as other criteria
• Balance traffic among multiple paths
• Implement route failover
• Diagnose a routing problem
LAB Topology:
In the lab network, Local-FortiGate has two interfaces connected to the internet: port1 and
port2. In this exercise, you will configure the port1 connection as the primary internet link and
the port2 connection as the backup internet link. Local-FortiGate should use the port2
connection only if the port1 connection is down. To achieve this objective, you will configure two
default routes with different administrative distances, and then you will disable the primary
default route interface to activate the standby route.
Note that, by default, static routes have a Distance value of 10 and a Priority value of 1.
Configure a Second Default Route
You will create a second default route using the port2 interface. To make sure this second default route remains the
standby route, you will assign it a higher administrative distance than the first default route.
FIELD VALUE
GATEWAY ADDRESS 10.200.2.254
INTERFACE port2
ADMINISTRATIVE DISTANCE 20
1. Continuing on the Local-FortiGate GUI, click Policy & Objects > Firewall Policy.
All Sessions logging ensures that FortiGate logs all traffic, not only
sessions that security profiles inspected. This will assist you in
verifying traffic routing using the Forward Traffic logs.
4. Click OK.
Field Value
Name Backup_Access
Incoming Interface port3
Outgoing Interface port2
Source LOCAL_SUBNET
Destination all
Schedule always
Service ALL
Log Allowed Traffic All Sessions
7. Click OK.
View the Routing Table
The Local-FortiGate configuration now has two default routes with different distances. You will view the routing table to
see which route was installed in the routing table and which route was installed in the routing table database.
The port2 default route has a higher administrative distance than the
port1 default route. When two or more routes to the same destination
have different distances, the higher distance route is not installed in the
routing table, but you can still see it in the routing table database. Routes
marked as inactive are marked inactive when the corresponding interface
is down.
• http://neverssl.com
• http://eu.httpbin.org
6. On the Local-FortiGate GUI, click Log & Report > Forward Traffic.
8. Locate the relevant log entries for the websites you accessed, and then verify that the Destination
Interface indicates port1.
This verifies that the port1 route is currently the route in use.
To force the failover
1. Continuing on the Local-FortiGate GUI, click Network > Interfaces.
4. Click OK.
The port1 internet connection is now down, and FortiGate removes the corresponding route
from the routing table.
• http://neverssl.com
• http://eu.httpbin.org
2. Return to the browser tab where you are logged in to the Local-FortiGate GUI, and then click Log &
Report > Forward Traffic.
3. Locate the relevant log entries for the websites you accessed, and then verify that the Destination
Interface indicates port2.
This verifies that the Local-FortiGate is using the port2 default route.
4. Click OK.
2. In the routing table, verify that the port1 route replaced the port2 route.
3. Close the browser.
Exercise 2: Configuring Equal-Cost Multi-Path Routing
In this exercise, you will configure equal-cost multi-path (ECMP) routing on Local-FortiGate to load balance the
internet traffic between port1 and port2.
2. Verify that both default routes are installed in the routing table.
2. Enter the following commands to change the ECMP load balancing method:
end
3. Leave the Local-FortiGate CLI session open.
• http://neverssl.com
• http://example.com
• http://eu.httpbin.org
2. On the Local-FortiGate GUI, click Log & Report > Forward Traffic.
3. In the relevant log entries for the websites you accessed, identify the Destination Interface.
The port2 route is not being used to route internet traffic. Why?
Configure Priority
You will change the priority value for the port2 route to match the port1 route.
To configure priority
5. Click OK.
Verify ECMP
Now that both port1 and port2 routes share the same distance and priority values, they are eligible for ECMP. First, you
will verify the routing table, and then you will verify traffic routing using the Forward Traffic logs.
diagnose sniffer packet any 'not host 172.16.100.1 and not host 172.16.100.3
and tcp[13]&2==2 and port 80' 4
The filter 'tcp[13]&2==2' matches packets with the SYN flag on,
so the output will show all SYN packets for port 80 (HTTP).
• http://neverssl.com
• http://example.com
• http://eu.httpbin.org
2. Return to the Local-FortiGate CLI session, and then press Ctrl+C to stop the sniffer.
4. On the Local-FortiGate GUI, click Log & Report > Forward Traffic.
5. Identify the Destination Interface in the relevant log entries for the websites you accessed.