Know a company with years of records? Refer it and earn up to $100K
Preparing infrastructure records

Anonymize PCAP Files and Logs Without Breaking Analysis

How to anonymize pcap files and firewall, DNS and proxy logs: why IP addresses can be personal data, prefix-preserving methods, tcprewrite and editcap.

IP anonymization schemes in RFC 6235
4Truncation, reverse truncation, permutation, prefix-preserving
editcap example truncation
64 bytesPer packet, from the editcap manual
GDPR recital on online identifiers
Recital 30Names IP addresses
A server rack with blue patch cables and a laptop showing a ticket queue
Short answer

To anonymize pcap files and logs and keep them usable, replace each IP address, host name and user name with the same pseudonym everywhere, using a secret key. Prefix-preserving methods keep subnets intact. tcprewrite rewrites addresses in captures; editcap truncates payloads and drops stored decryption secrets. Keep the key apart from the data, and remember timestamps can still identify activity.

  • An IP address can be personal data in the EU. GDPR Recital 30 names it as an online identifier.
  • Consistent, keyed pseudonyms keep logs joinable. Random values per line break analysis.
  • Prefix-preserving anonymization keeps subnet structure, and that structure can help an attacker reverse it.
  • Payload removal protects content but removes the signal many detections rely on.

Why do IP addresses in captures and logs need anonymizing?

Because they can point to people. A packet capture (pcap) is a file that records network packets as they crossed a link. Firewall, DNS and proxy logs record the same traffic as one line per connection, query or request. All of them carry IP addresses, and many carry host names and user names too. GDPR Recital 30 says people may be associated with online identifiers "such as internet protocol addresses, cookie identifiers" (GDPR Recital 30).

The EU's top court went further in the Breyer case. It ruled that a dynamic IP address a website operator records "constitutes personal data" for that operator when it "has the legal means which enable it to identify the data subject with additional data which the internet service provider has about that person" (CJEU, C-582/14). US state privacy laws treat identifiers differently. This page is general information, not legal advice.

Which IP anonymization method keeps logs usable?

The IETF's RFC 6235 sorts IP anonymization into four schemes and adds a fifth, simpler option: delete the field, which it calls "black-marker anonymization" (RFC 6235). The right choice depends on what the logs must still show. Anonymization means the result can no longer be linked to a person. Pseudonymization means each real value is swapped for a stand-in that a key could map back. See anonymization vs pseudonymization for the difference in law.

MethodWhat it doesWhat survivesWhat breaks
Black-marker (delete)Removes the fieldNothing about the addressEvery join on that field
TruncationRemoves the last n bits, for example 198.51.100.0/24The network, not the hostTelling hosts on one subnet apart
PermutationSwaps each address for a unique random oneWhich events share a hostSubnet structure
Prefix-preservingKeeps shared prefixes sharedWhich hosts sit on the same subnetLess; but the structure can be attacked

RFC 6235 defines prefix preservation this way: "If two real IP addresses match on a prefix of "n" bits, the two anonymized IP addresses will match on a prefix of "n" bits as well." It also warns that this "introduces structure into the anonymized data that can be exploited in attacks against the anonymization technique." Crypto-PAn is the best-known prefix-preserving tool.

How do you anonymize a pcap file?

Rewrite the headers, then decide what to do with the payload. tcprewrite "rewrites the packets in a pcap file and writes a new pcap" (tcprewrite docs). Its --seed option "causes the source and destination IPv4/v6 addresses to be pseudo randomized but still maintain client/server relationships", and because the randomization is deterministic based on the seed, the seed works like a key (tcprewrite manual). Its --pnat option rewrites addresses by network range. After either, recalculate checksums with --fixcsum.

The payload is the content inside each packet: web pages, file transfers, DNS answers. editcap's -s option keeps only the first bytes of each packet, so "packets in the input file with more captured data than the specified snapshot length will have only the amount of data specified by the snapshot length written to the output file" (editcap manual). A pcapng file can also store decryption keys, and editcap's --discard-all-secrets drops them. The Wireshark wiki lists more anonymizers, including Crypto-PAn, tcprewrite and TraceWrangler (Wireshark wiki).

Capture commands, from the tcpreplay docs and the editcap manual
# Pseudo-randomize every IP address with a repeatable seed (tcprewrite manual: -s, --seed)
tcprewrite --infile=capture.pcap --outfile=anon.pcap --seed=SEED --fixcsum

# Or map a whole network range to another (adapted from the tcprewrite docs' worked example)
tcprewrite --infile=capture.pcap --outfile=lab.pcap --pnat=10.0.0.0/8:192.168.50.0/24 --fixcsum

# Keep only the first 64 bytes of each packet, dropping most payload (editcap manual example)
editcap -s 64 -F snoop capture.pcapng shortcapture.snoop

# Drop any TLS or other decryption secrets stored in a pcapng file (editcap manual)
editcap --discard-all-secrets capture.pcapng nosecrets.pcapng

Read the output in Wireshark before sharing. Host names, user names and email addresses also sit inside DNS, HTTP and mail payloads, where header rewriting does not reach.

How do you anonymize firewall, DNS and proxy logs?

Logs are text, so you replace values field by field. The rule that keeps them useful is consistency: the same real value must become the same pseudonym in every file, from every system, for the whole period. Then a firewall deny, a DNS query and a proxy download from one laptop still line up as one story.

Use one keyed mapping, such as a keyed hash or a prefix-preserving cipher, shared by all the log sources. Keep the key apart from the data and never ship it with the logs.

LogFields to replaceKeep as is
FirewallSource and destination IPs, user names, internal host namesAction, protocol, port, rule ID, timestamp
DNSClient IP, internal host names in queriesRecord type, response code, public domains under study
ProxyClient IP, user name, URL query strings with personal dataMethod, status, bytes, category, destination domain
VPN and sign-inUser names, device IDs, home IPsResult, method, timestamp

What anonymization breaks, and how to limit it

Every method trades privacy for analysis. Removing payloads protects content, but the Canadian Institute for Cybersecurity, which publishes the CIC-IDS2017 dataset, criticizes older datasets that "anonymize packet payload data, which cannot reflect the current trends" (CIC-IDS2017). Keep the bytes the analysis needs, such as protocol headers and DNS names under study, and remove the rest.

Timing is the other leak. RFC 6235 notes that "timestamps can be used in traffic injection attacks": someone who sent known traffic can find it again and learn the mapping (RFC 6235). The same document says information about the permutation function or its parameters "SHOULD NOT be exported." In practice: keep real timestamps when the order of events is the point, keep the key private, and do not share the mapping table.

Worked example: three log lines before and after

An illustration, not a real company. A firewall, a DNS server and a web proxy each log one step of the same event: an SSH probe is blocked, then an internal laptop looks up its own name and downloads a file from the probing network. The team applies one keyed, prefix-preserving mapping across all three logs, and replaces user and host names with numbered pseudonyms.

Fictional log lines, written for this page
BEFORE
2026-02-03T02:14:09Z fw01 DENY tcp 198.51.100.23:51544 -> 203.0.113.10:22 user=jsmith
2026-02-03T02:14:11Z dns01 QUERY 203.0.113.55 laptop-jsmith.corp.example.com A
2026-02-03T02:15:40Z proxy01 GET http://198.51.100.99/payload.bin client=203.0.113.55

AFTER (keyed, consistent, prefix-preserving)
2026-02-03T02:14:09Z fw01 DENY tcp 10.71.4.23:51544 -> 10.9.200.10:22 user=user-0193
2026-02-03T02:14:11Z dns01 QUERY 10.9.200.55 host-0412.corp.example A
2026-02-03T02:15:40Z proxy01 GET http://10.71.4.99/payload.bin client=10.9.200.55

Fictional data. The original addresses are documentation ranges. Because the mapping is consistent, 198.51.100.23 and 198.51.100.99 still share a /24 after anonymization, and the laptop at 203.0.113.55 is the same pseudonym in the DNS and proxy logs. The story survives; the identities do not.

Common mistakes when anonymizing captures and logs

These come up in almost every first attempt.

  • Random values per line, so the same host gets a different pseudonym in each log and nothing joins.
  • A different key for each log source.
  • Shipping the key, the seed or the mapping table with the data.
  • Rewriting IP headers but leaving user names, host names and emails inside DNS, HTTP or mail payloads.
  • Forgetting stored decryption secrets in pcapng files.
  • Breaking checksums after rewriting, so tools reject the packets.
  • Treating anonymized data as safe when prefix structure or timing can still re-identify hosts.

Source: IETF RFC 6235: IP Flow Anonymization Support

Are anonymized attack logs and captures worth anything?

Only as part of an incident record. AI data buyers have asked Origin for attack and defense sequences that can be replayed: logs or captures of what happened and what was done, in order, from the company's own infrastructure and its own incidents. They asked for them joined to the change that fixed the incident (the ticket, the chat thread, the config diff or pull request, and the outcome) and to the runbooks, SOC tickets, on-call records and postmortems of the same period. The company must own the logs. Raw logs or captures without that case context do not qualify, and captures are excluded by default; see security incident data. The first step buyers asked for is two or three incidents end to end plus a slice of the config history; the incident timeline template shows how the pieces join.

Origin is an independent data partner. Your company decides what is shared and signs any license itself, and a buyer may pay Origin when a deal closes.

  • Personal data: apply one consistent, keyed mapping to IPs, user names and host names across every source, and keep the key in-house.
  • Payloads: strip content and stored decryption secrets unless a specific field is needed and cleared.
  • Client traffic: an MSSP or hosting provider keeps client environments out unless the client has agreed. See SOC case data.
  • Secrets: scan logs for keys and tokens as well as code. See remove secrets from git history.
  • Sharing rules: data received under the Traffic Light Protocol (TLP), the labels that set how far shared security information may travel, or from an information-sharing group stays under those rules.

Does your company hold records like these? See what your data is worth.

Common questions

How do I anonymize IP addresses in a pcap file?

Use a tool that rewrites packet headers, such as tcprewrite with --seed for repeatable pseudo-random addresses or --pnat to map one network range to another, then fix checksums with --fixcsum. Check the result in Wireshark, because names and addresses inside payloads are not rewritten.

Is an IP address personal data under GDPR?

It can be. GDPR Recital 30 names IP addresses as online identifiers, and in the Breyer case the EU Court of Justice held that a dynamic IP address can be personal data where the holder has legal means to identify the person with the internet provider's help. This is general information, not legal advice.

What is prefix-preserving IP anonymization?

It replaces each IP address so that two addresses sharing their first n bits still share their first n bits after anonymization. Subnet structure survives, so analysts can still see which hosts sit together. RFC 6235 warns that this structure can also be used to attack and reverse the anonymization.

How do I anonymize firewall logs and keep them useful?

Replace IP addresses, user names and internal host names with keyed pseudonyms that stay the same across every log and every day, and keep actions, ports, rule IDs and timestamps. Consistency is what lets one host be followed from the firewall to the DNS and proxy logs.

Can tcprewrite remove packet payloads?

tcprewrite is built to rewrite headers such as MAC and IP addresses, ports and VLAN tags. To cut payloads, use editcap with -s and a small snapshot length, which keeps only the first bytes of each packet. editcap can also drop decryption secrets stored in a pcapng file.

Can anonymized network logs be re-identified?

Sometimes. Prefix structure, timing and traffic volumes can reveal hosts, and RFC 6235 describes traffic injection attacks that use timestamps to recover mappings. Keep the key and mapping private, remove fields the analysis does not need, and review what an outsider could match.

Sources and further reading

What is your company’s data worth?

AI companies pay $20K to $5M for company records. Six questions, no files.