How to build a script for address objects when you have a very large list of IPs

To be able to add many IPs as address objects from a large list, for example from a vendor if there is no internet

Problem

I have a big list of IPs like here: my.pingdom.com/probes/ipv4

 

e.g

10.10.10.10

10.20.20.20

10.30.30.30

10.40.40.40

….etc

 

I want to create address objects in FMG or a FGT but need the CIDR notation adding and then a script building:

10.10.10.10/32

10.20.20.20/32

10.30.30.30/32

10.40.40.40/32

…etc

 

In Notepad++ Place your curser at the end of the 1st line, hold down alt + shift and down arrow to the last line, then type /32 and you will type on all lines at the same time

 

Then we need to turn that into a script for FGT or FMG… in notepad++:

 

Ctrl + H

 

In find what section:

 

(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(/\d{2})

 

In replace section:

 

edit NameIP-$1.$2.$3.$4\nset subnet $1.$2.$3.$4$5\nnext

 

NameIP can be changed to your object name

 

Example:

 

Click Replace all….

 

 

edit NameIP-10.10.10.10

set subnet 10.10.10.10/32

next

edit NameIP-10.20.20.20

set subnet 10.20.20.20/32

next

edit NameIP-10.30.30.30

set subnet 10.30.30.30/32

next

edit NameIP-10.40.40.40

set subnet 10.40.40.40/32

next

 

 

Just add:

Config firewall address <at the start>

End <at the end>

 

 

And you have your script!