# Prefix Preserving IP Anonymization

**URL:** <https://discuss.elastic.co/t/prefix-preserving-ip-anonymization/58709>\
**Category:** Logstash\
**Created:** [August 23, 2016, 3:58pm UTC](https://discuss.elastic.co/t/prefix-preserving-ip-anonymization/58709 "2016-08-23T15:58:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saurabh\_Jambhule](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Saurabh\_Jambhule](https://discuss.elastic.co/u/Saurabh_Jambhule)\
**Post date:** [August 23, 2016, 3:58pm UTC](https://discuss.elastic.co/t/prefix-preserving-ip-anonymization/58709/1 "2016-08-23T15:58:15Z")

</div>

Is there any algorithm that preserves prefix property of IP?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 27, 2016, 2:31pm UTC](https://discuss.elastic.co/t/prefix-preserving-ip-anonymization/58709/2 "2016-08-27T14:31:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Saurabh\_Jambhule](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Saurabh\_Jambhule](https://discuss.elastic.co/u/Saurabh_Jambhule)\
**Post date:** [August 27, 2016, 3:12pm UTC](https://discuss.elastic.co/t/prefix-preserving-ip-anonymization/58709/3 "2016-08-27T15:12:36Z")

</div>

Ok. Suppose I have bunch of IP's having same network id like,  
10.130.120.11  
10.130.125.26  
here netmask id 255.255.0.0  
So after anonymization these should look like,  
XXX.YYY.ssdasd.dasa  
XXX.YYY.werew.wefw  
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.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 28, 2016, 1:22pm UTC](https://discuss.elastic.co/t/prefix-preserving-ip-anonymization/58709/4 "2016-08-28T13:22:23Z")

</div>

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 "1.2.3.4" as the input and `key` set to 16, the hash becomes "1.2.0.0".

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

---

<div class="post-metadata">

**Author:** ![Saurabh\_Jambhule](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Saurabh\_Jambhule](https://discuss.elastic.co/u/Saurabh_Jambhule)\
**Post date:** [August 28, 2016, 6:15pm UTC](https://discuss.elastic.co/t/prefix-preserving-ip-anonymization/58709/5 "2016-08-28T18:15:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 29, 2016, 5:27am UTC](https://discuss.elastic.co/t/prefix-preserving-ip-anonymization/58709/6 "2016-08-29T05:27:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:41am UTC](https://discuss.elastic.co/t/prefix-preserving-ip-anonymization/58709/7 "2017-07-06T04:41:14Z")

</div>

Closed on July 6, 2017, 4:41am UTC


