Prefix Preserving IP Anonymization

Is there any algorithm that preserves prefix property of IP?

I'm not sure what you mean. Could you give an example?

Ok. Suppose I have bunch of IP's having same network id like,
here netmask id
So after anonymization these should look like,
Here I mean that NID should get same hash value. So after anonymization, I should able to figure out that these bunch of IPs belongs to same subet.

This sounds close to what the fingerprint filter does with method => "IPV4_NETWORK":

If set to IPV4_NETWORK the input data needs to be a IPv4 address and the hash value will be the masked-out address using the number of bits specified in the key option. For example, with "" as the input and key set to 16, the hash becomes "".

But you want to keep the last bits and hash those that match the network mask?

Yes, I want to hash NID and HID separately. So I can identify IP belonging to same network after anonymization also.

Sounds like a reasonable feature request to the fingerprint plugin, but for now you'll probably have to use a ruby filter and write some custom code.