User Tools

Site Tools


regex_to_add_objets

Explain how to use regex to add office urls in fortigate

  • Format the list of IPs :

Get your IPs list on what you want.

Here an example :

example.txt
157.55.139.177/32
52.178.150.186/32
13.84.216.209/32

So i recommend you to use atom (but an other text editor with regex search is fine).

  • Open your file
  • search for the regex “(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(/\d{2})”
  • replace with “edit ExchangeOnline-$1.$2.$3.$4\nset subnet $1.$2.$3.$4$5\nnext\n”
  • select “replace all” button

Like this :

You will get the following output :

outputexample.txt
edit ExchangeOnline-157.55.139.177
set subnet 157.55.139.177/32
next
 
edit ExchangeOnline-52.178.150.186
set subnet 52.178.150.186/32
next
 
edit ExchangeOnline-13.84.216.209
set subnet 13.84.216.209/32
next

  • Import IPs on fortigate CLI :

Connect to you fortigate terminal, once your connected enter in firewall configuration like this :

$config firewall address

Right after copy, paste you outputexample.txt in the terminal and press ENTER !


  • Import IPs on fortigate CLI IF USE VDOM:

Connect to you fortigate terminal, once your connected enter in firewall configuration like this :

$config vdom
$edit root
$config firewall address

Right after copy, paste you outputexample.txt in the terminal and press ENTER !


Source regex : everythingsysadmin


- created date : 2017.03.15 -

regex_to_add_objets.txt · Last modified: 2019/02/18 15:21 by admin