ITNuvoAkademiya
Academy homePackagesPlaylistsToolsSubnet calculatorSearchGlossary
CiscoCCNA · CCNA: networking fundamentals1. Introduction2. Network Fundamentals3. Network Access4. IP Connectivity5. IP Services6. IPv67. Security Fundamentals8. AutomationCCNP: Enterprise networks · coming soon
LinuxLinux: system administrator üçün · Linux for system administrators1. Getting to know Linux2. Working with text3. Users and permissions4. Processes and packages5. Inside the system6. Monitoring and logs7. NetworkingRed Hat Enterprise Linux · Red Hat Enterprise Linux: from beginner to advanced1. Getting started2. Packages3. Users and permissions4. SELinux5. Services6. Storage7. Networking8. Building services9. Boot and recovery10. DevOps11. Security and monitoring
FortinetFortiGate Administrator · FortiGate Administrator: from first login to ZTNA1. Getting to know FortiGate2. Routing, policy and NAT3. Security profiles4. Users and logs5. Resilience, SD-WAN and automation6. VDOM7. VPN and ZTNA8. Proxy9. DMZ
MonitoringZabbix · Zabbix: from installation to alerts1. Introduction2. Installation and the database3. Basics: groups, templates, users4. Connecting devices5. Alerts, Grafana and the API
VirtualizationProxmox VE · coming soonVMware ESXi · coming soon
My account / Sign in
AZENRU
← itnuvo.com

Static routing: where should the packet go

Lesson 2.19 minBeginnerNovember 24, 2026
Open

This lesson is open to everyone. The other lessons open with a package: sign in or sign up, then choose a package.

Key points

  • The best route in the table is chosen by longest prefix match: a /24 always beats a /16, and a /16 always beats the default route.
  • If there are two routes to the same network, the one with the lower distance enters the table (connected 0, static 10). If the distances are equal, the one with the lower priority is used.
  • A default route is created without typing dst: set gateway and set device are enough, because dst defaults to 0.0.0.0/0.
  • get router info routing-table all shows only active routes; get router info routing-table database also shows the inactive ones.
  • The FortiGate checks the return path to the source of an incoming packet (RPF). If there is no route to the source through that port, the packet is dropped.

How the routing table is read

When a packet arrives, the FortiGate compares the destination IP with the routing table and picks the most specific match. This is called longest prefix match.

DestinationRoutes in the tableChosen
10.10.30.100.0.0.0/0, 10.10.0.0/16, 10.10.30.0/2410.10.30.0/24
10.10.99.50.0.0.0/0, 10.10.0.0/16, 10.10.30.0/2410.10.0.0/16
8.8.8.80.0.0.0/0, 10.10.0.0/16, 10.10.30.0/240.0.0.0/0

When you give ports an IP, their networks enter the table by themselves (connected routes). For everything else you have to write a route.

The default route

In our lab the internet is behind port1 and the provider's address is 203.0.113.1.

FGT-HQ
FGT-HQ # config router static
FGT-HQ (static) # edit 1
FGT-HQ (1) # set gateway 203.0.113.1
FGT-HQ (1) # set device port1
FGT-HQ (1) # next
FGT-HQ (static) # end

GUI: Network > Static Routes > Create New.

We did not type dst because its default is 0.0.0.0 0.0.0.0. A route to a specific network looks like this (the branch LAN is behind a neighbouring router on port4):

FGT-HQ
FGT-HQ # config router static
FGT-HQ (static) # edit 2
FGT-HQ (2) # set dst 10.20.0.0 255.255.255.0
FGT-HQ (2) # set gateway 10.255.1.2
FGT-HQ (2) # set device port4
FGT-HQ (2) # set comment "Filial LAN"
FGT-HQ (2) # next
FGT-HQ (static) # end

A difference from Cisco: on a FortiGate a static route names both the gateway and the device (the outgoing port).

Viewing the table

FGT-HQ
FGT-HQ # get router info routing-table all
Routing table for VRF=0
S*      0.0.0.0/0 [10/0] via 203.0.113.1, port1, [1/0]
C       10.10.10.0/24 is directly connected, port2
C       10.10.30.0/24 is directly connected, port3
S       10.20.0.0/24 [10/0] via 10.255.1.2, port4, [1/0]
C       10.255.1.0/30 is directly connected, port4
C       203.0.113.0/30 is directly connected, port1
  • S is static, C is connected, * marks a candidate default route.
  • [10/0]: the first number is the distance, the second the metric.
  • The trailing [1/0]: the first number is the priority, the second the weight.

Distance and priority

With two providers you write two default routes. Which one will be used? (The example below is a separate scenario: port4 is connected to a second provider.)

SituationResult
Distances differ (10 and 20)Only the lower one (10) enters the table. The other is a standby and is visible in database.
Same distance, different priorityBoth are in the table, but outgoing traffic uses the one with the lower priority.
Same distance and priorityBoth are used and sessions are shared between them (ECMP).
FGT-HQ
FGT-HQ (static) # edit 3
FGT-HQ (3) # set gateway 198.51.100.1
FGT-HQ (3) # set device port4
FGT-HQ (3) # set distance 20
FGT-HQ (3) # next

When a port goes down, the static route bound to it leaves the table by itself and the standby route takes over. But if the port stays "up" and the problem is inside the provider, the FortiGate does not know. For that you need a link monitor or SD-WAN (section 5).

To see inactive routes:

FGT-HQ
FGT-HQ # get router info routing-table database

RPF: checking the source address

On the first packet of every new session the FortiGate checks: does the route to this packet's source address go through the port the packet arrived on? If not, the packet is treated as spoofed and dropped. This is the reverse path forwarding (RPF) check.

In practice it looks like this: a packet from 10.20.0.5 arrives on port4, but the table has no route for 10.20.0.0/24 and the default route points to port1. The FortiGate drops the packet without even looking at the policies. The debug output says reverse path check fail, drop.

There are two modes:

  • Feasible path (default): any route to the source through that port is enough; it does not have to be the best route.
  • Strict: the best route to the source must go through exactly that port. It is enabled with set strict-src-check enable under config system settings.

Watch out on a real device: most "there is a policy but traffic does not pass" complaints are caused by routing. First check with get router info routing-table all that there is a route both to the destination and to the source, and only then look at the policy.

Blackhole and policy routes

  • A blackhole route silently drops traffic: set blackhole enable. We will use it in the VPN lessons so that traffic for internal addresses does not leak to the internet when a tunnel is down.
  • A policy route (config router policy) looks at criteria other than the destination: source address, incoming port, protocol. Policy routes are checked before the routing table, so use them with care.

🧪 Hands-on lab · Topology: FGT (fortigate), ISP (pc), PC1 (pc)

Default route

The WAN port of the FortiGate (port1, 203.0.113.2/30) is connected to the provider (ISP, 203.0.113.1). Write a default route: gateway 203.0.113.1, outgoing port port1. If you do not type dst, it defaults to 0.0.0.0/0. Finally look at the table with get router info routing-table all and test with execute ping 203.0.113.1.

Checked:

  • Gateway 203.0.113.1
  • Outgoing port port1
  • Routing table viewed
  • The FortiGate pings the ISP

▶ Start the lab

Check yourself

5 questions · answers are shown instantly · 3 correct answers complete the lesson

1The table has 0.0.0.0/0, 10.10.0.0/16 and 10.10.30.0/24. Which route does a packet to 10.10.30.10 take?

The most specific match (longest prefix match) is chosen.

2There are two default routes: one with distance 10, the other with 20. What appears in the routing table?

The lower distance enters the table; the other is a standby visible in the database.

3What happens if you do not type set dst when writing a default route?

The default value of dst is 0.0.0.0 0.0.0.0, which is a default route.

4Which command shows inactive (standby) routes?

all shows only active routes; database shows all of them.

5There is no route through port4 to the source of a packet that arrived on port4. What does the FortiGate do?

The RPF check comes before policies; with no return path the packet is dropped.
Was this lesson useful?

Comments

Sign in to comment.