NAT Configuration Components

Learn about NAT components, rule processing, and how to configure, verify, and troubleshoot NAT on Junos OS devices.

Use Feature Explorer to confirm platform and release support for specific features. Additional platforms might be supported.

NAT Rule Sets and Rules

Network Address Translation (NAT) processing centers on the evaluation of NAT rule sets and rules. A rule set determines the overall direction of the traffic to be processed. For example, a rule set can select traffic from a particular interface or to a specific zone. A rule set can contain multiple rules. Once a rule set is found that matches specific traffic, each rule in the rule set is evaluated for a match. Each rule in the rule set further specifies the traffic to be matched and the action to be taken when traffic matches the rule.

This topic includes the following sections:

NAT Rule Sets

A rule set specifies a general set of traffic-matching conditions. For static NAT and destination NAT, a rule set specifies one of the following match criteria:

  • Source interface

  • Source zone

  • Source routing instance

For source NAT rule sets, you configure both source and destination conditions:

  • Source interface, zone, or routing instance

  • Destination interface, zone, or routing instance

It is possible for a packet to match more than one rule set; in this case, the rule set with the more specific match is used. An interface match is considered more specific than a zone match, which is more specific than a routing instance match. If a packet matches both a destination NAT rule set that specifies a source zone and one that specifies a source interface, the rule set with the source interface is more specific.
Source NAT rule set matching is more complex because you specify both source and destination conditions in a source NAT rule set. In the case where a packet matches more than one source NAT rule set, the rule set chosen is based on the following source/destination conditions (in order of priority):
  1. Source interface/destination interface

  2. Source zone/destination interface

  3. Source routing instance/destination interface

  4. Source interface/destination zone

  5. Source zone/destination zone

  6. Source routing instance/destination zone

  7. Source interface/destination routing instance

  8. Source zone/destination routing instance

  9. Source routing instance/destination routing instance

For example, you can configure rule set A, which specifies a source interface and a destination zone, and rule set B, which specifies a source zone and a destination interface. If a packet matches both rule sets, rule set B is the more specific match.

You cannot specify the same source and destination conditions for source NAT rule sets.

NAT Rules

Once a rule set that matches the traffic has been found, each rule in the rule set is evaluated in order for a match. NAT rules can match on the following packet information:

  • Source and destination address

  • Source port (for source and static NAT only)

  • Destination port

The first rule in the rule set that matches the traffic is used. If a packet matches a rule in a rule set during session establishment, traffic is processed according to the action specified by that rule.

You can use the show security nat source rule and show security nat destination rule and the show security nat static rule commands to view the number of sessions for a specific rule.

Rule Processing

The NAT type determines the order in which NAT rules are processed. During the first packet processing for a flow, NAT rules are applied in the following order:
  1. Static NAT rules

  2. Destination NAT rules

  3. Route lookup

  4. Security policy lookup

  5. Reverse mapping of static NAT rules

  6. Source NAT rules

Figure 1 illustrates the order for NAT rule processing.

Figure 1: NAT Rule Processing Flowchart showing packet processing in a network device focusing on NAT and policy checks: Static NAT, Destination NAT, Route/Zone Lookup, Reverse Static NAT, Policy Lookup, Source NAT, Permit Packet.

Static NAT and destination NAT rules are processed before route and security policy lookup. Static NAT rules take precedence over destination NAT rules. Reverse mapping of static NAT rules takes place after route and security policy lookup and takes precedence over source NAT rules. Source NAT rules are processed after route and security policy lookup and after reverses mapping of static NAT rules.

The configuration of rules and rule sets is basically the same for each type of NAT—source, destination, or static. But because both destination and static NAT are processed before route lookup, you cannot specify the destination zone, interface or routing instance in the rule set.

NAT Rule Capacity

The NAT rule capacity requirement depends on the SRX Series Firewall and the Junos OS release.

The restriction on the number of rules per rule set is a device-wide limitation on how many rules a device can support. This restriction helps you better plan and configure the NAT rules for the device.

Available memory might not support the combined maximum number of source NAT rules or rule sets, destination NAT rules or rule sets, and static NAT rules or rule sets.

The NAT rule capacity requirement depends on the SRX Series Firewall and the Junos OS release.

Use Feature Explorer to confirm platform and release support for specific features. Additional platforms may be supported.

Configure NAT Using the NAT Wizard

You can use the NAT Wizard to perform basic NAT configuration. To perform more advanced configuration, use the J-Web interface or the CLI.

To configure NAT using the NAT Wizard:

  1. Select Configure > Tasks > Configure NAT in the J-Web interface.
  2. Click the Launch NAT Wizard button.
  3. Follow the wizard prompts.

The upper-left area of the wizard page shows where you are in the configuration process. The lower-left area of the page shows field-sensitive help. When you click a link under the Resources heading, the document opens in your browser. If the document opens in a new tab, be sure to close only the tab (not the browser window) when you close the document.

Example: Configure NAT for Multiple ISPs

This example shows how to configure a Juniper Networks device for address translation of multiple ISPs.

Requirements

Before you begin:

  1. Configure network interfaces on the device. See Interfaces User Guide for Security Devices.

  2. Create security zones and assign interfaces. See Understanding Security Zones.

Overview

In this example, you can configure an SRX Series Firewall by connecting the LAN to the Internet by using NAT feature through two ISP connections. In this configuration, the trust zone contains the private address space, and the two untrust zones contain the public address space. The configuration connects the LAN to the two ISPs and supports traffic in both directions. The example is a combination of source NAT rules to connect to Internet from the LAN, and destination and static NAT rules to connect to the LAN from Internet.

Configuration

Configure NAT for Multiple ISPs

CLI Quick Configuration
To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, copy and paste the commands into the CLI at the [edit] hierarchy level, and then enter commit from configuration mode.
Step-by-Step Procedure

The following example requires you to navigate various levels in the configuration hierarchy. For instructions on how to do that, see Using the CLI Editor in Configuration Mode in the Junos OS CLI User Guide.

  1. Configure routing instances.

  2. Configure rib groups and routing options.

  3. Configure security policies.

  4. Configure source NAT pools and rules.

  5. Configure destination NAT pools and rules.

  6. Configure static NAT rules.

Results

From configuration mode, confirm your configuration by entering the show configuration command. If the output does not display the intended configuration, repeat the configuration instructions in this example to correct it.

If you are done configuring the device, enter commit from configuration mode.

Verification

Verify Interfaces

Purpose

Verify that the interfaces are configured correctly.

Action

From operational mode, enter the following commands:

  • show interfaces

  • show zones

  • show routing-instances

  • show routing-options

  • show policies

  • show source nat

  • show destination nat

  • show static nat

Configure Proxy ARP for NAT (CLI Procedure)

You use NAT proxy ARP functionality to configure proxy ARP entries for IP addresses that require either source or destination NAT and that are in the same subnet as the ingress interface. On SRX Series Firewalls, you must explicitly configure NAT proxy ARP.

When configuring NAT proxy ARP, you must specify the logical interface on which to configure proxy ARP. Then you enter an address or address range.

The device performs proxy ARP for addresses that meet the following conditions:

  • Addresses defined in a static NAT rule or source NAT pool are in the same subnet as the ingress interface.

  • Addresses in the original destination address entry in the destination NAT rules are in the same subnet as the ingress interface.

Configure NAT Trace Options

Purpose

The NAT trace options hierarchy configures trace file and flags for verification purposes.

The SRX Series Firewalls have two main components: the Routing Engine and the Packet Forwarding Engine . The Packet Forwarding Engine is divided into the ukernel portion and the real-time portion.

When a NAT configuration is committed, the configuration is first checked and validated on the RE. After validation, the configuration is pushed to the PFE. The configuration is installed on the ukernel PFE, then action is taken on each packet that matches NAT rules on the real-time PFE.

For verification, you can turn on flags individually to debug NAT functionality on the RE, ukernel PFE, or real-time PFE:

  • The nat-re flag records the trace of the NAT configuration validation on the RE and the configuration push to the PFE.

  • The nat-pfe flag records the trace of the NAT configuration installation on the ukernel PFE.

  • The nat-rt flag records the trace of the NAT rule match, and subsequent action on the real-time PFE.

The trace data is written to /var/log/security-trace by default, and you can view the data using the command show log security-trace.

If session logging has been enabled in the policy configurations on the device, the session logs will include specific NAT details for each session. See Monitoring Security Policy Statistics for information about how to enable session logging and Information Provided in Session Log Entries for SRX Series Services Gateways for a description of the information provided in session logs.

Action

To verify that NAT configurations are correctly updated to the device upon commit, and that the NAT rule match and subsequent actions are correct, use the security nat traceoptions statement.

To verify that NAT translations are being applied to the traffic, and to view individual traffic flow processing with NAT translations, use both the security nat traceoptions command and the security flow traceoptions command together. The commands are used together because the NAT trace, configured using the security nat traceoptions command, is not recorded unless the flow traceoptions command is also configured.

To filter a specific flow, you can define a packet filter and use it as a trace option:

To verify NAT traffic and to enable all traffic trace in data plane, use the traceoptions set security flow traceoptions flag basic-datapath command, as shown in the following example using a simple packet filter:

Monitor NAT Incoming Table Information

Purpose

View NAT table information.

Action

Select Monitor > NAT > Incoming Table in the J-Web UI, or enter the following CLI command:

show security nat incoming-table

Table 1 summarizes the key output fields in the incoming table display.

Table 1: Summary of Key Incoming Table Output Fields

Field

Values

Statistics

In use

Number of entries in the NAT table.

Maximum

Maximum number of entries possible in the NAT table.

Entry allocation failed

Number of entries failed for allocation.

Incoming Table

Clear

Destination

Destination IP address and port number.

Host

Host IP address and port number that the destination IP address is mapped to.

References

Number of sessions referencing the entry.

Timeout

Timeout, in seconds, of the entry in the NAT tables.

Source-pool

Name of source pools where translation is allocated.

Monitor Interface NAT Port Information

Purpose

View port usage for an interface source pool information.

Action

To monitor interface NAT port information, do one of the following:

  • Click Monitor > Firewall/NAT > Interface NAT or Monitor > NAT > Interface NAT Ports in the J-Web UI or enter the CLI command show security nat interface-nat-ports.

Table 2 summarizes key output fields in the interface NAT display.

Table 2: Summary of Key Interface NAT Output Fields

Field

Values

Additional Information

 

Pool Index

Port pool index.

–

Total Ports

Total number of ports in a port pool.

–

Single Ports Allocated

Number of ports allocated one at a time that are in use.

–

Single Ports Available

Number of ports allocated one at a time that are free for use.

–

Twin Ports Allocated

Number of ports allocated two at a time that are in use.

–

Twin Ports Available

Number of ports allocated two at a time that are free for use.

–

Additional Platform Information

Use Feature Explorer to confirm platform and release support for specific features. Additional platforms may be supported.

NAT Rule Type

SRX300SRX320

SRX340SRX345

SRX400

SRX440SRX440-2AC

SRX1500SRX1600

SRX2300SRX4120SRX4100SRX4200

SRX4600SRX5400SRX5600SRX5800

SRX4700

Source NAT rule

2048

2048

1280 1536

8192

20,480

30,720

51200

Destination NAT rule

2048

2048

1280 1536

8192

20,480

30,720

51200

Static NAT rule

2048

4096

1280 1536

8192

20,480

30,720

51200

Objects

SRX1600SRX2300SRX4120

SRX4600SRX5400SRX5600SRX5800

SRX4700

Total NAT rule sets per system

10,000

30,720

51200

Total NAT rules per rule set

10,000

30,720

51200

Platform Number of IPs Supported with OL
vSRX small VSRX-2CPU-4G 1
SRX1600 2
SRX2300, SRX4120 16
SRX4300 16
vSRX XL VSRX-17CPU-32G 64
SRX4700 128
SRX5000 line of devices 128

Change History Table

Feature support is determined by the platform and release you are using. Use Feature Explorer to determine if a feature is supported on your platform.

Release
Description
19.3R1
Starting from Junos OS Release 19.3R1, SRX5000 line devices with SRX5K-SPC3 card, SRX4100, SRX4200, and vSRX Virtual Firewall instances support NAT features such as source NAT, destination NAT, and static NAT for both IPv4 and IPv6 traffic in PowerMode IPsec (PMI) mode. NAT64 is not supported in PMI mode. However, NAT64 works properly in normal mode, when PMI is enabled.