Evil_TTL> show | s

Extract Hosts IP Address Objects from Juniper SRX using Notepad Plus Plus

Category:Automation -> Notepad Plus Plus

Given:

set logical-systems LOGICAL-SYSTEM-1 security address-book global address H-10.1.2.3 10.1.2.3/32
set logical
-systems LOGICAL-SYSTEM-1 security address-book global address H-10.10.20.30 10.10.20.30/32
set logical
-systems LOGICAL-SYSTEM-1 security address-book global address H-10.111.222.111 10.111.222.111/32
set logical
-systems LOGICAL-SYSTEM-1 security address-book global address H-10.15.16.17 10.15.16.17/32 

Objective:
Extract IP addresses, remove everything else.


In Notepad++ do the following:


Find what:

(\d*)([.])(\d*)([.])(\d*)([.])(\d*)([/])(\d*)$ 


Where

\d* - matches any number of consecutive digits, where “\d” is one digit and “*” - as many as which equals to as many consecutive following digits
([.]) OR (.) OR \. - matches a “.” character
([.]) OR (.) OR \. - matches a “/” character
$ - matches the end of the line


Replace with:

\n$0 - returns results in new line


Search mode: Regular expression


Result:

set logical-systems LOGICAL-SYSTEM-1 security address-book global address H-10.1.2.3 
10.1.2.3
/32
set logical
-systems LOGICAL-SYSTEM-1 security address-book global address H-10.10.20.30 
10.10.20.30
/32
set logical
-systems LOGICAL-SYSTEM-1 security address-book global address H-10.111.222.111 
10.111.222.111
/32
set logical
-systems LOGICAL-SYSTEM-1 security address-book global address H-10.15.16.17 
10.15.16.17
/32 

Next go to “Mark” tab

Find what: set -> click “Mark all”

Go to Search -> Bookmark -> Remove Bookmarked Lines

The end result:

10.1.2.3/32
10.10.20.30
/32
10.111.222.111
/32
10.15.16.17
/32 
By privilege15