# CGNAT and Law 5651: Traceable Records with Port Blocks

> How ISPs deploy CGNAT: NAT444, RFC 6598 address space, deterministic NAT and port block allocation, and how they cut the log volume required for traceability.

The number of public IPv4 addresses an internet service provider holds is fixed, while its subscriber count grows. RIPE NCC's free IPv4 pool ran out in 2019, so obtaining a new block now means waiting in a queue or buying on the secondary market. Almost every growing operator therefore reaches a point where it has to share public addresses between subscribers, and the standard way to do that is **CGNAT**.

There is a second dimension that matters as much as the engineering. Under Turkish Law No. 5651, an operator must be able to show afterwards which subscriber a given connection belonged to. Once addresses are shared, the public IP address alone no longer answers that question. How the deployment is designed determines both the log volume and the cost of compliance.

## What CGNAT does

In a classic setup each subscriber gets one public IPv4 address. With CGNAT, the subscriber receives a private address inside the operator's network and shares a public address with other subscribers on the way out. They are told apart by source port number.

There is already a NAT on the subscriber side: the home router puts every device behind a single address. With CGNAT the traffic is translated a second time. This arrangement is called **NAT444**, because the packet passes through three separate IPv4 domains: the home network, the operator's internal network and the internet.

A dedicated range exists for the operator's internal network. The `100.64.0.0/10` block defined in **RFC 6598** is reserved for exactly this purpose. Using it rather than RFC 1918 space such as `192.168.0.0/16` matters, because the subscriber's own home network already uses RFC 1918 and overlapping the two breaks routing.

## The logging problem: one record per session

The real burden CGNAT introduces is on the logging side. When a judicial request arrives, the operator is expected to answer one question: which subscriber was using a particular public IP address and port number at a particular date and time?

The simplest approach is to log every NAT session, but that quickly becomes unsustainable. A single subscriber's browser opens dozens of concurrent connections just to load one web page. Mobile apps, update services and background clients multiply that. Across thousands of subscribers the daily record count reaches billions. The resulting cost is not only disk: that volume has to be written, moved, backed up and searched within a reasonable time when a query comes in.

## The answer: deterministic NAT and port block allocation

The common solution is to give each subscriber a predetermined **port block** instead of logging sessions one by one. This is known as port block allocation (PBA) or deterministic NAT.

The logic is straightforward. When a subscriber connects, they are allocated a public IP address and a fixed port range on that address, for example the 1,008 ports between 20160 and 21167. The subscriber cannot go outside that range, so a single allocation record is enough to know which subscriber owns every connection in it.

Records are then produced **per block** rather than per session. One record is written when the subscriber connects and closed when the session ends, with no separate record for the thousands of connections in between. Volume becomes proportional to subscriber count rather than session count.

How many subscribers fit on one public IP depends directly on the block size. An IPv4 address has roughly 64,000 usable ports, so allocating 1,008 ports per subscriber fits about 64 subscribers on the same address.

| Ports per subscriber | Subscribers per IP | Note |
|---|---|---|
| 512 | ~125 | Dense sharing, risk of port exhaustion with many open tabs |
| 1,008 | ~64 | A common balance point |
| 2,048 | ~31 | Comfortable headroom, less address saving |
| 4,096 | ~15 | For heavy user profiles |

Choose the block size against the subscriber profile. A household with many devices, or a small business, can hit port exhaustion in a narrow block. Most platforms can allocate a second block when the first fills up, which creates one more record and keeps the volume under control.

## Which fields a Law 5651 record needs

For a port block record to lead back to the subscriber, it has to hold:

- the subscriber identity (a subscriber number or an identifier that matches the RADIUS session)
- the private IP address given to the subscriber
- the public IP address after translation
- the allocated port range
- the start and end time of the allocation

These records must be matchable against RADIUS accounting data, because that is where the link between subscriber identity and session is established. Clock synchronisation is equally critical: a time difference between NAT records and RADIUS records can make matching impossible, so every system should run against the same NTP source.

Preserving the accuracy, integrity and confidentiality of the records is an explicit requirement of Law No. 5651. In practice that means timestamping them and storing them so they cannot be altered. For retention periods and scope, go by current BTK regulations and your legal counsel.

## Side effects to plan for

CGNAT changes the subscriber's relationship with the internet, so a few things need thinking through up front.

**Inbound connections stop working.** The subscriber no longer has an address reachable from the internet. Home servers, IP cameras and anything needing port forwarding are affected. Keeping a separate pool of static public IPs for customers who need them is the usual answer.

**NAT behaviour affects gaming and VoIP.** Peer-to-peer applications need the NAT to behave predictably. **EIM/EIF** support (endpoint-independent mapping and filtering) keeps traffic from the same internal port mapped to the same external port. **Hairpinning** is needed so two subscribers behind the same public address can reach each other.

**Some protocols need help.** FTP, SIP and PPTP carry address information inside the packet payload, so they need **ALG** support to work behind NAT.

**Reputation is shared.** If one subscriber on a shared address abuses it, the address can land on a blocklist and the others feel it too. Being able to tie an abuse complaint from a port range back to a subscriber quickly is as much an operational requirement as a technical one.

**Geolocation can be wrong.** Shared addresses may be recorded in location databases as a different city from the subscriber's, which can produce unexpected results in content services.

## Checklist

- Use RFC 6598 (`100.64.0.0/10`) internally and avoid overlapping RFC 1918
- Log per port block, not per session
- Size blocks against the subscriber profile and allow a second block when one fills
- Record subscriber identity, private IP, public IP, port range and time together
- Synchronise NAT and RADIUS records against the same NTP source
- Store records timestamped and tamper-evident
- Keep a separate pool for customers who need a static public IP
- Verify EIM/EIF, hairpinning and the ALG support you need
- Build a process that maps an abuse complaint from a port range to a subscriber

## Frequently asked questions

### Why not move to IPv6 instead of CGNAT?

IPv6 is the right long-term answer, but it is not sufficient on its own. Much of the content and many services subscribers want are still offered only over IPv4. Operators therefore usually run both stacks: IPv6 is handed out directly and IPv4 access goes through CGNAT. As IPv6 usage grows, less traffic crosses the CGNAT layer and the same hardware lasts longer.

### Does a port block record replace a session record?

For answering a judicial request, yes, because the allocation record identifies the subscriber using a given public IP and port at a given time. The request has to include the port number. A request that gives only the public IP address lists every subscriber sharing it and cannot distinguish between them.

### How many ports should I allocate per subscriber?

Around 1,000 ports is a common starting point for residential subscribers. You can find the right figure by measuring concurrent sessions on your own network. Subscribers hitting port exhaustion report failed connections and pages that do not load, which is a good signal to revisit the block size.

### How is CGNAT performance measured?

Three figures matter: total throughput in Gbps, concurrent session count and new sessions per second. The bottleneck usually appears in concurrent session capacity rather than throughput. When sizing, check that small-packet (64-byte) performance is published as well, because the packet size distribution in real traffic decides the outcome.

### Which products do we build this with?

Our own product, [CoreGate](/en/solutions/coregate), delivers CGNAT on the same platform as BNG, BGP Edge, DPI and DDoS protection, and manages port block records within the platform. [Syslog](/en/solutions/syslog) can collect logs from the other devices on the network centrally, while [Cetvel and WiRadius](/en/solutions/cetvel) handle subscriber records, billing and BTK reporting.

---
Canonical: https://internetten.com.tr/en/knowledge-base/cgnat-port-block-logging-traceability
