Creating geographic addresses on FortiGate can be long if you need to declare a lot of countries. This repository aims to provide you the full list of countries supported by your FortiGate.
Full list is available at cli.txt. You can copy / paste this directly to your equipment using SSH / console access.
I get it, you can be suspicious. Are there any errors in this list ? Is it up to date ? Can I trust it ??
If you prefer, you can re-create it, following these steps :
- Connect to your FortiGate using console / SSH. Type in
config firewall address. Then, create a new dummy object usingedit "dummy object". - Type in command
set type geography. Then, typeset country ?to see the full list of country code supported by your equipment. - Copy/paste this list
Paste in the previous list in Notepad++ (or some other tool, but then you might have to adapt the following commands).
Use replace utility, enabling regular expressions, and replace the following expressions :
1. Create the "set country" command
Find :
(.*)\s{4}(.*)
Meaning : Something, then 4 spaces, then something else
And replace it with :
`$2\n set country "$1"`
Meaning : Insert the content of the second (.*), go to the next line, insert 4 spaces, insert 'set country ', and insert the content of the first (.*)
2. Create the "edit" command
Find :
^(?!\s{4})(.*)$
Meaning : Something, that doesn't start with 4 spaces
And replace it with :
$edit "$1"
Meaning : Insert 'edit "', then the string you found, then close the quotation mark
3. Create the "set type geography" command
Find :
edit "(.*)"
Meaning : Something, that doesn't start with 4 spaces
And replace it with :
$edit "edit "$1"\n set type geography"
Meaning : Keep the 'edit' string, add a new line, add four spaces, and set insert 'set type geography'
4. Add the "next" command
Find :
set country "(.*)"
Meaning : Something, that doesn't start with 4 spaces
And replace it with :
$edit "set country "$1"\nnext
Meaning : Keep the 'edit' string, add a new line, add four spaces, and set insert 'set type geography'