Skip to main content
siva3g
New Member
Sep 17, 2018 7:38 AM UTC
Question

Adding bulk static routes via CLI in fortigate firewall

Kindly suggest the automatic way to add bulk static routes via CLI in fortinet firewalls.

 

The syntax showed in below is to add a single static route.

configure routing static

edit 1

set gateway 172.100.20.5

set distance 10

set device port2

set dst 0.0.0.0

end

end

 

But i have a requirement to add the automatic way to add bulk static routes via CLI from the raw data in excel/notepad with network and gateway details

 

Kindly help and Thanks in Advance

 

Cheers

Siva

2 replies

ede_pfau
SuperUser
SuperUser
Sep 17, 2018 8:33 AM UTC

hi,

 

and welcome to the forums.

 

Your task is not complicated. Write a wrapper script which translates your data into the syntax you posted. This could be DOS commands, powershell, VBA...whatever you are proficient in.

 

Use "edit 0" for automatic numbering. Save as a text file and import via Bulk command (System > Advanced).

 

You may search the forum for "bulk" to see how other members have solved this. Examples are usually for bulk import of addresses but maybe you can adapt it.

Translate
siva3g
siva3gAuthor
New Member
Sep 18, 2018 4:05 AM UTC

Thanks for your response and cracked as per your advise...thanks a lot

 

@echo off REM input: textfile addr.txt with IP,name,interface (one per line) REM values delimited by commas, comments start with # REM redirect output to a batch command file for uploading to a Fortigate echo config router static for /f " eol=# tokens=1-4 delims=," %%i in (addr2.txt) do CALL :oneaddr %%i %%j %%k %%l echo end goto :EOF :oneaddr echo edit %1 echo set dst %2 echo set gateway %3 echo set distance 10 echo set device %4 echo next

 

#SNO,Network,Nexthop,Port

Translate
Risk and Resilience in the Age of AI. An OT Thought Leadership Summit for Houston's Critical Infrastructure Leaders. Date: Thursday, December 3, 2026. Time: 8:30 am - 1:30 pm (CT). Location: The Westin Houston, Memorial City | 945 Gessner Road, Houston, TX 77024