My next Python project can help you find non-used objects in your ASA
configuration. I saw it’s very common to update ASA’s configuration,
add network objects, modify ACLs but no one remember about objects which
are not used anymore. The only one time when people review the config
is migration from one vendor to another one. My script can help you in
keeping config clean from non-used objects.
This is a config I will work with:
As usual the script has two modes: normal one with final output only and debug one with all steps the script takes.
This is an output from a normal mode:
https://github.com/hzw7/oof
This is a config I will work with:
[hzw@zeus oof]$ cat acl2.txt
object network 172.16.0.0_16
subnet 172.16.0.0 255.255.0.0
object network 192.168.1.0_24
subnet 192.168.1.0 255.255.254.0
object network 192.168.1.0_23
subnet 192.168.1.0 255.255.254.0
object network 172.16.250.5
host 172.16.250.5
object network 172.16.250.0_24
subnet 172.16.250.0 255.255.255.0
object network 172.16.250.5_
host 172.16.250.5
object network 172.16.250.110
host 172.16.250.110
object network 10.10.0.100_h
host 10.10.0.100
object-group network TEST1
network-object object 172.16.250.5
network-object object 172.16.250.0_24
network-object object 172.16.250.5_
network-object object 172.16.250.110
network-object 172.16.250.0 255.255.255.0
object-group network TEST2
network-object host 10.10.0.100
network-object host 10.10.0.20
network-object host 172.16.250.5
network-object 192.168.1.0 255.255.255.0
network-object object 192.168.1.0_24
network-object object 192.168.1.0_23
[hzw@zeus oof]$
and two object networks are not used by any ‘network-object object’. You can review Python source code here: https://github.com/hzw7/oof
As usual the script has two modes: normal one with final output only and debug one with all steps the script takes.
This is an output from a normal mode:
[hzw@zeus oof]$ python oof-0.01.py acl2.txt
Orphan objects:
[1, '172.16.0.0_16']
[15, '10.10.0.100_h']
[hzw@zeus oof]$
and from a debug mode:
[hzw@zeus oof]$ python oof-0.01.py acl2.txt -d
object network -> OBJECT NAME: 172.16.0.0_16
object network -> OBJECT NAME: 192.168.1.0_24
object network -> OBJECT NAME: 192.168.1.0_23
object network -> OBJECT NAME: 172.16.250.5
object network -> OBJECT NAME: 172.16.250.0_24
object network -> OBJECT NAME: 172.16.250.5_
object network -> OBJECT NAME: 172.16.250.110
object network -> OBJECT NAME: 10.10.0.100_h
|-network-object object -> NETWORK-OBJECT OBJECT NAME: 172.16.250.5
|-network-object object -> NETWORK-OBJECT OBJECT NAME: 172.16.250.0_24
|-network-object object -> NETWORK-OBJECT OBJECT NAME: 172.16.250.5_
|-network-object object -> NETWORK-OBJECT OBJECT NAME: 172.16.250.110
|-network-object object -> NETWORK-OBJECT OBJECT NAME: 192.168.1.0_24
|-network-object object -> NETWORK-OBJECT OBJECT NAME: 192.168.1.0_23
Network-object table:
[18, '172.16.250.5']
[19, '172.16.250.0_24']
[20, '172.16.250.5_']
[21, '172.16.250.110']
[28, '192.168.1.0_24']
[29, '192.168.1.0_23']
Object network table:
[1, '172.16.0.0_16']
[3, '192.168.1.0_24']
[5, '192.168.1.0_23']
[7, '172.16.250.5']
[9, '172.16.250.0_24']
[11, '172.16.250.5_']
[13, '172.16.250.110']
[15, '10.10.0.100_h']
togn i
172.16.250.5
ton j
172.16.0.0_16
ton j
192.168.1.0_24
ton j
192.168.1.0_23
ton j
172.16.250.5
removed
ton j
172.16.250.5_
ton j
172.16.250.110
ton j
10.10.0.100_h
togn i
172.16.250.0_24
ton j
172.16.0.0_16
ton j
192.168.1.0_24
ton j
192.168.1.0_23
ton j
172.16.250.0_24
removed
ton j
172.16.250.110
ton j
10.10.0.100_h
togn i
172.16.250.5_
ton j
172.16.0.0_16
ton j
192.168.1.0_24
ton j
192.168.1.0_23
ton j
172.16.250.5_
removed
ton j
10.10.0.100_h
togn i
172.16.250.110
ton j
172.16.0.0_16
ton j
192.168.1.0_24
ton j
192.168.1.0_23
ton j
172.16.250.110
removed
togn i
192.168.1.0_24
ton j
172.16.0.0_16
ton j
192.168.1.0_24
removed
ton j
10.10.0.100_h
togn i
192.168.1.0_23
ton j
172.16.0.0_16
ton j
192.168.1.0_23
removed
Orphan objects:
[1, '172.16.0.0_16']
[15, '10.10.0.100_h']
[hzw@zeus oof]$
Final result “Orphaned objects:” is the same but you have many additional steps where you see how the script run.
https://github.com/hzw7/oof
Comments
Post a Comment