Some of my customers get a bit touchy about IP addresses leaving their corporate environment, so they need to be removed before any documents see the outside world. I’ve already added this as a feature in my script that turns a Sonus gateway backup into a DOCX and PDF.
Occasionally I need to send a trace file to a colleague or the vendor, so it needs to be cleansed first. If the addresses aren’t in themselves significant in the interpretation of the file, I generally just open the LOG file in Word and use this quick-and-dirty Find/Replace:
[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}
If you want to make the file a little more readable you might want to take a few more steps to retain the device’s own IP, masks and null values:
- To retain references to the device’s own IP, find/replace it with something like “<MyIpAddress>”
- To retain null/empty IP values (“0.0.0.0”), find “([!(1-9)])(0.0.0.0)” and replace with “\1” followed immediately by a temporary junk value that you’re not going to see elsewhere in the file – maybe “banana”:
- To retain (most) masks, find “255.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}” and replace with “<SubnetMask>”
- With all of the wanted IPs protected, now use the wildcard at the top of the post to banish any remaining IPs. Find “[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}” and replace with “<IPStripped>”
- Now revert “banana” back to “0.0.0.0” and you’re good to go!
– G.