What Truncating an IP Address Actually Anonymises

Management Summary
An IP address identifies a network connection and often appears in website analytics and server records. Removing part of the address reduces the detail retained about that connection, which can support data minimisation. It does not automatically make the surrounding records anonymous: timestamps, other identifiers or additional knowledge may still enable identification. The relevant question is therefore whether the complete stored information can be linked to a person, rather than how many address digits were removed.
Contents
- Address Space and People Are Different Quantities
- A Plain Hash Does Not Remove Identification Risk
- IPv6 Prefixes Do Not Define Anonymity Groups
- Recognizing IPv4-Mapped IPv6 Properly
- The Processing Stage Determines the Scope of Protection
- Anonymity Requires Assessment of the Whole Dataset
- Questions and answers
- Sources
Truncating an IP address reduces stored precision. For example, 203.0.113.45 becomes 203.0.113.0/24, removing the distinction between 256 possible IPv4 addresses. This establishes neither a group of 256 people nor an anonymous dataset.
An IP address identifies a network endpoint used to exchange data. IPv4 and IPv6 are two address formats. A bit is a binary digit, either 0 or 1. A prefix is the retained beginning of an address; the number after the slash states how many bits it contains.
Three questions matter: which bits remain, which other attributes are present, and which realistic means of identification are available to the relevant recipient? Prefix length answers only the first question.

Address Space and People Are Different Quantities
An IPv4 address contains 32 bits. /24 means retaining the first 24 bits and setting the last eight to zero. The number of possible original addresses is 2⁸ = 256. The addresses below are documentation examples, not evidence of geographic location.
| Stored value | Possible original addresses | Interpretation limit |
|---|---|---|
203.0.113.45/32 | 1 | One address, not necessarily one household or person. |
203.0.113.0/24 | 256 | An address range, with no guaranteed street or user count. |
203.0.0.0/16 | 65 536 | A larger range, with no fixed geographic resolution. |
| IP field removed | No longer derivable from this field | Other attributes can still identify a person. |
Network address translation (NAT) replaces internal addresses with a public address, allowing many devices to share that public address. Carrier-grade NAT can also share that address across customer connections. Conversely, one connection may receive different addresses over time. Mathematical address capacity therefore describes neither actual occupancy nor the number of distinct people in a dataset.
Geolocation has no fixed relationship between prefix length and home location. Provider assignments, mobile networks, VPNs and database quality influence the result. MaxMind explicitly states that GeoIP data cannot reliably identify a particular household or street address. Truncation can change geographic reporting; retaining almost unchanged city-level results requires verification against the actual data.
A Plain Hash Does Not Remove Identification Risk
Pseudonymization replaces identifying details with substitute values. Identification may still be possible with additional information. Anonymity requires that identification is no longer reasonably possible in the relevant context.
SHA-256 turns an address into a less readable but deterministic value: identical inputs produce identical hashes. IPv4 has only 2³² = 4 294 967 296 possible addresses. Calculating the hash of each possible address and comparing it with the stored hash is therefore much easier than for a long random secret.
ENISA documented practical attacks on SHA-256-pseudonymized IPv4 addresses in 2019. Runtime depends on hardware, implementation and the known candidate range. A claim that every ordinary machine builds the complete table in minutes goes beyond that evidence. The relevant conclusion remains: an unprotected hash is not reliable anonymization.
A salt is an extra value added to the input before hashing. A publicly stored salt changes hash values but is not a secret key. A fixed salt prevents reuse of a pre-existing generic table while allowing a new table for the dataset. Random per-event salts hinder precomputation and direct linkage; known salts still allow candidate testing for each event. Hashing a truncated prefix does not reliably hide the prefix either: truncation makes the possible input space smaller.
IPv6 Prefixes Do Not Define Anonymity Groups
IPv6 addresses contain 128 bits. /64 is common for an individual subnet. A customer connection or site may receive multiple subnets within a /56 or /48. RFC 6177 does not prescribe one universal assignment size for every site. Interface-identifier generation also varies; every device inventing a suffix is not a universal rule.
Removing the lower 64 bits eliminates the interface portion stored there, while retaining the subnet prefix. A /56 or /48 can still identify a single customer site. Greater truncation can combine assignments, but the actual effect depends on allocation practice and additional data.
Google’s familiar rule of zeroing the last 80 IPv6 bits belongs to legacy Universal Analytics IP masking and leaves a /48. GA4 is different: Google states that IP addresses are used for location derivation at collection and discarded before logging or storage. This does not establish anonymity of the remaining GA4 data.

Recognizing IPv4-Mapped IPv6 Properly
A server supporting both IPv4 and IPv6 (dual stack) may represent an IPv4 connection as ::ffff:203.0.113.45. The IPv4 address occupies the lower 32 bits. Genuine binary truncation to IPv6 /48 removes those bits completely; the embedded IPv4 address does not survive intact.
The practical problem is string manipulation or inconsistent treatment of equivalent representations. ::ffff:cb00:712d and 0:0:0:0:0:ffff:cb00:712d describe the same mapped address. A string-prefix check for ::ffff: therefore misses valid forms. A parser reads the address according to its format and first recognizes the address type, then applies the appropriate rule:
import ipaddress
def mask_ip(text, ipv4_prefix=24, ipv6_prefix=48):
address = ipaddress.ip_address(text.strip())
if isinstance(address, ipaddress.IPv6Address):
if address.scope_id is not None:
raise ValueError('Scoped addresses are outside this example')
address = address.ipv4_mapped or address
prefix = ipv4_prefix if address.version == 4 else ipv6_prefix
network = ipaddress.ip_network((address, prefix), strict=False)
return network.with_prefixlenAll three mapped forms and 203.0.113.45 produce 203.0.113.0/24 in this example. Invalid inputs are rejected. The defaults /24 and /48 illustrate the mechanism and are not universal privacy recommendations. The function expects one address from a trusted source, not an unchecked X-Forwarded-For list.
The Processing Stage Determines the Scope of Protection
Truncation at the recipient can minimize later storage even when the full address was processed earlier to establish the connection. Preventing disclosure of the full visitor address requires applying the transformation before that disclosure.
For a genuine server-to-server request, the network peer normally sees the public outbound address of the server or its proxy. Visitor addresses can nevertheless be forwarded in payloads, URL parameters or headers. Truncating one field such as client_ip_address works only if no complete copy travels through another route. The destination API must also support truncated values meaningfully.
A browser tag loaded directly from a vendor uses the browser’s network connection, including any VPN or proxy. A truncated payload parameter does not hide that connection address. An owned domain alone changes nothing: a DNS alias (CNAME) can still point to an external provider receiving the connection. The important boundary is an actual controlled intermediary and its forwarding behavior.
Anonymity Requires Assessment of the Whole Dataset
A truncated IP combined with timestamps, account IDs, cookie identifiers or unusual activity can remain identifiable. Conversely, a particular prefix length alone does not establish personal-data status for every recipient. Available additional information and realistic identification methods determine the assessment.
In Case C-413/23 P in 2025, the Court of Justice emphasized, under Regulation (EU) 2018/1725, that pseudonymized information is not automatically personal data for every person. Processing context matters; existing transparency obligations at collection do not disappear. An IP mask does not replace that assessment.
Useful documentation records purpose, prefix length, processing stage, remaining identifiers, recipients and retention periods. Address capacity must be described as a mathematical quantity, not a verified number of anonymous people. Depending on purpose, combining individual records into totals (aggregation), shorter retention or omitting the address altogether may provide additional protection.
Questions and answers
How large is an IPv6 /48 range?
A /48 contains 256 possible /56 blocks and 65,536 possible /64 blocks. This is capacity arithmetic, not evidence of actual use, customer assignments or user counts. A /48 allocated entirely to one site can still distinguish that site after truncation.
What additional protection does HMAC provide?
HMAC calculates a hash-based value using a secret key as well as the input. Without that key, an ordinary hash candidate table cannot be computed. Key separation, access controls and limited validity are therefore significant safeguards. Possession of the key still enables candidate testing; a stable HMAC can also link events. HMAC supports pseudonymization but does not automatically guarantee anonymity or replace data minimization for every purpose.
Where can complete addresses remain stored?
Possible locations include web-server access and error logs, content delivery networks (CDNs), web application firewalls (WAFs), systems distributing requests between servers (load balancers), blocking tools and backups. Common Apache and nginx log formats include a remote address; the actual value depends on proxy configuration and log format. Truncation in an analytics application does not automatically modify these other stores. Each relevant processing stage needs an assessment of purpose, access and retention.
Why can removing the IP field be insufficient?
An account ID or another distinctive attribute can preserve identifiability independently of the IP address. Removing the field eliminates only that information source. Anonymity assessment covers all remaining attributes and possible linkages.
Sources
- Google: Universal Analytics IP masking (legacy)
- Google: Regional data collection (GA4)
- RFC 6177: IPv6 address assignment
- RFC 4291: IPv6 addressing architecture
- RFC 6598: Shared address space and CGN
- Python: ipaddress
- MaxMind: Geolocation accuracy
- ENISA: Pseudonymisation techniques and best practices
- Court of Justice: Case C-413/23 P, 4 September 2025
- nginx: HTTP log module
- Apache: Log files


