Supported Platforms
CGN Implementation: Best Practices
The following topics present the best practices for carrier-grade NAT implementation on MS-DPCs using the Layer 3 services package:
- Use APP and Round-Robin Address-Allocation
- Do Not Use EIM with SIP
- Do Not Use EIM with HTTP, DNS, or When Not Needed
- Define PBA Blocks Based on User Profiles
- Do Not Change the PBA Configuration on Running Systems
- Do Not Allocate Excessively Large NAT Pools
- Configure the System Log for PBA Only When Needed
- Use Redundant Service PIC (RSP) Interfaces for Failover
- Contain the Effects of Missing IP Fragments
- Do Not Use Configurations Prone to Routing Loops
Use APP and Round-Robin Address-Allocation
Scenario:
- Address-pooling paired (APP) allows a private IP address to be mapped to the same public IP address from a NAT pool for all its sessions. The binding between private IP and public IP is triggered by the first packet seen from such private host.
- By default, an MS-DPC or MS-PIC allocates ports from a NAT pool in a sequential fashion from each consecutive IP address available in the pool.
- Sequential allocation, together with APP, can result in mapping multiple private hosts to the same public IP address, resulting in fast port exhaustion for the interested public IP address while other ports are still available from the remaining of NAT pool.
![]() | Best Practice: Configure round-robin address allocation for the NAT pool used by traffic served with APP. Round-robin allocation allocates ports from different IP addresses. |
The following snippet provides an example of round-robin address allocation.
user@router# show services nat pool natpool-1
address-range low 9.9.9.1 high 9.9.9.10; port { automatic; } address-allocation round-robin; mapping-timeout 120;
Do Not Use EIM with SIP
Scenario:
- Session Initiation Protocol (SIP) traffic requires an Application Level Gateway (ALG) to allow SIP servers and clients on the public side of the CGNAT to communicate with the SIP hosts on the private side.
- The SIP ALG opens the pinholes in the CGNAT router to permit the forwarding of outbound traffic based on any supported SIP feature.
- Endpoint-independent mapping (EIM) is not needed by SIP to function, nor by the SIP ALG to create the flows for forwarding the SIP traffic
![]() | Best Practice: Do not configure EIM together with the SIP ALG; doing so adds processing overhead with no benefit. |
user@router# show services nat rule natrule-1
match-direction input; term 1 { from { applications junos-sip; } then { translated { source-pool natpool-3; translation-type { napt-44; } address-pooling paired;
Do Not Use EIM with HTTP, DNS, or When Not Needed
Scenario:
- Most Internet traffic uses HTTP, and there is no browser on any OS that reuses the same source port for sending traffic to different destinations. EIM provides no benefit for HTTP traffic.
- Because none of the junos-algs require EIM to work, avoid using EIM with the ALGs.
- EIM allocates memory for each mapping; this is in addition to the memory used for flow allocation. This reduces the maximum number of flows that can be established through the services PIC, and causes processing overhead for the creation and deletion of flows and mappings.
![]() |
|
Define PBA Blocks Based on User Profiles
Scenario:
- When a user connects to a website that requires the establishment of a significant number of sockets for a single HTML page, a corresponding number of new ports must be allocated. Port blocks should be large enough to prevent continual allocation of new blocks.
- If the number of concurrent sessions exceeds the number of ports available in the active port block, the other allocated port-blocks will be scanned for available ports to use or a new block will be allocated from the free block pool.
- The process of continually scanning the allocated port-blocks and/or allocating additional blocks from the free block pool could result in experienced latency for setting up new sessions and delay loading of web pages.
- Having a user continuously allocating or de-allocating from different PBA blocks impacts performance.
![]() | Best Practice: Define PBA blocks with a size that is a power of 2 or 4 related to the average number of sessions a user is expected to have active. For example, if a user is expected to have an average of approximately 200 to 250 sessions active, configuring the PBA block size to 512 or 1024 will provide a liberal allocation. |
user@router# show services nat pool natpool-1
address-range low 9.9.9.1 high 9.9.9.10; port { automatic; secure-port-block-allocation { block-size 1024; max-blocks-per-user 8; /* Max 2048, default 8 */ active-block-timeout 300; } } mapping-timeout 300;
Do Not Change the PBA Configuration on Running Systems
Scenario:
- PBA settings in NAT pools are mapped to memory at the time of the Service PIC boot up and cannot be changed while processing traffic.
- Do not change the following settings:
- Update any NAT pool PBA configuration.
- Change a PBA NAT pool to a non-PBA NAT pool.
- Change a non-PBA NAT pool to a PBA NAT pool.
Any of these changes result in the logging of the following message:
PBA_CATASTROPIC_CHANGE: The recent PBA configuration changes will reflect in the Service-PIC only after deactivate and activate of the service-set again
![]() | Best Practice: When changing PBA configurations, restart the services PIC if possible. Minimally, you must deactivate and reactivate the affected service set. |
Do Not Allocate Excessively Large NAT Pools
Scenario:
- The maximum number of flows supported by the MS-DPC and each PIC on an MS-DPC is 8 million.
- Assuming that the 8 million flow maximum consists of 4 million sessions (1 reverse flow for each forward flow), these sessions would require a maximum of 4 million ports that are available from 64 IP addresses within the 1024 to 65,535 ports range (64K ports per IP address).
- Do not configure ports to support more than 8 million flows; they will never be needed.
- This scenario assumes that APP, EIM, and EIF are not enabled. When they are enabled, the total number of flows is lower, which means that you should configure the number of IP addresses in the NAT pool based on the maximum supported flows.
![]() | Best Practice: Do not configure NAT pools with more than 64 addresses (that is, a /26 network) and round-robin configured and 64K ports from each address. |
Configure the System Log for PBA Only When Needed
Scenario:
- Session logging can negatively affect performance depending on the frequency of creation and deletion of flows.
- PBA is meant to reduce the need for logging.
- Deterministic NAT is designed to eliminate the need for logging.
- All system log messages created by the services PIC constitutes traffic that will be sent to the Packet Forwarding Engine. competing with user traffic to reach the external destination.
![]() |
|
![]() | Best Practice: System log generation can be rule-based or event-based.
|
Use Redundant Service PIC (RSP) Interfaces for Failover
![]() |
|
Contain the Effects of Missing IP Fragments
Scenario:
- IP fragments are buffered as they arrive to facilitate the integrity check of the completely reassembled packet before being serviced by the services PIC.
- Missing fragments cause received fragments to be held until the internal buffer is full and are flushed out. This causes CPU usage overhead and reduced traffic forwarding.
![]() | Best Practice: Configure the fragment-limit, the maximum number of fragments for a packet, and reassembly-timeout, the maximum wait for a missing fragment, after which all other fragments for the same packet are flushed out. user@router# show interfaces sp-0/0/0 services-options { open-timeout 5; close-timeout 5; inactivity-timeout 30; tcp-tickles 4; fragment-limit 10; reassembly-timeout 3; cgn-pic; } |
Do Not Use Configurations Prone to Routing Loops
Scenario:
- Sudden and persistent high CPU usage is most likely an indication of packet looping between the Packet Forwarding Engine and the services PIC. Depending on whether the configuration uses interface-style or next-hop-style service sets, different network flaps can lead to routing loops.
![]() | Ensure that only the intended traffic is allowed to reach the services PIC and is serviced based on service set rule.
|