I analysed logs with http://www.w3perl.com/, now i want the IPs made anonymous.
So i want them changed in all html-files in the whole directory.
-
I thought about just always turning the third and fourth octet into the same number for all IPs. But i read something about XOR-ing them – what is that about?
-
what is the better way to manage the replacing and why? sed or perl or another option?
I am pretty new to this, i hope i searched the other topics enough. I haven’t found anything related to my problem.
Thanks in advance and please excuse my English.
This website is just great – i’ve learned so much in the last days!
Masking IP-Address can be better achieved with
perl. You can take a look here for using already available modules so that you won’t have to re-invent the wheel. Unfortunately I don’t knowperl, so I can only offersedsolution.You can use something like this for replacing all ip-address in your file.
Your file:
Step 1: Identify IP-Addresses:
Step 2: Replace IP-Address with your mask
You can either make
sed -i(in-line) substitution or use>to re-direct your output to another file.Obviously this can be reduced to the following. The above would be useful for debugging as you can view what is being changed before making the change.
Good Luck!!
Update:
As posted by Mark in the
comments, aperlvariant would be –Update II:
As requested by OP, the following one-liner will find the files and perform the substitution.