Example: Configuring Destination NAT for Subnet Translation
This example describes how to configure a destination NAT mapping of a public subnet address to a private subnet address.
![]() | Note: Mapping addresses from one subnet to another can also be accomplished with static NAT. Static NAT mapping allows connections to be established from either side of the gateway device, whereas destination NAT allows connections to be established from only one side. However, static NAT only allows translations between blocks of addresses of the same size. |
Requirements
Before you begin:
- Configure network interfaces on the device. See the Junos OS Interfaces Configuration Guide for Security Devices.
- Create security zones and assign interfaces to them. See Understanding Security Zones.
Overview
This example uses the trust security zone for the private address space and the untrust security zone for the public address space. In Figure 113, devices in the untrust zone access devices in the trust zone by way of public subnet address 1.1.1.0/16. For packets that enter the Juniper Networks security device from the untrust zone with a destination IP address in the 1.1.1.0/16 subnet, the destination IP address is translated to a private address on the 192.168.1.0/24 subnet.
Figure 113: Destination NAT Subnet Translation

This example describes the following configurations:
- Destination NAT pool dst-nat-pool-1 that contains the IP address 192.168.1.0/24.
- Destination NAT rule set rs1 with rule r1 to match packets received from the ge-0/0/0.0 interface with the destination IP address on the 1.1.1.0/16 subnet. For matching packets, the destination address is translated to the address in the dst-nat-pool-1 pool.
- Proxy ARP for the addresses 1.1.1.1/32 through 1.1.1.62/32 on the interface ge-0/0/0.0; these are the IP addresses of the hosts that should be translated from the 1.1.1.0/16 subnet. This allows the Juniper Networks security device to respond to ARP requests received on the interface for those addresses. The address 1.1.1.63/32 is assigned to the interface itself, so this address is not included in the proxy ARP configuration. The addresses that are not in the 1.1.1.1/32 through 1.1.1.62/32 range are not expected to be present on the network and would not be translated.
- Security policies to permit traffic from the untrust zone to the translated destination IP addresses in the trust zone.
Configuration
CLI Quick Configuration
To quickly configure a destination NAT mapping from a public subnet address to a private subnet address, copy the following commands and paste them into the CLI.
Step-by-Step Procedure
The following example requires you to navigate throughout various levels in the configuration hierarchy. For instructions on how to do that, see Using the CLI Editor in Configuration Mode.
To configure a destination NAT mapping from a public subnet address to a private subnet address:
- Create the destination NAT pool.[edit security nat destination]user@host# set pool dst-nat-pool-1 address 192.168.1.0/24
- Create a destination NAT rule set.[edit security nat destination]user@host# set rule-set rs1 from interface ge-0/0/0.0
- Configure a rule that matches packets
and translates the destination address to an address in the pool.[edit security nat destination]user@host# set rule-set rs1 rule r1 match destination-address 1.1.1.0/16user@host# set rule-set rs1 rule r1 then destination-nat pool dst-nat-pool-1
- Configure proxy ARP.[edit security nat]user@host# set proxy-arp interface ge-0/0/0.0 address 1.1.1.1/32 to 1.1.1.62/32
- Configure an address book entry in the
trust zone for the private subnet address.[edit security]user@host# set zones security-zone trust address-book address internal-net 192.168.1.0/24
- Configure a security policy that allows
traffic from the untrust zone to the devices in the trust zone.[edit security policies from-zone untrust to-zone trust]user@host# set policy internal-access match source-address any destination-address internal-net application anyuser@host# set policy internal-access then permit
Results
From configuration mode, confirm your configuration by entering the show security nat and show security policies commands. 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
To confirm that the configuration is working properly, perform these tasks:
- Verifying Destination NAT Pool Usage
- Verifying Destination NAT Rule Usage
- Verifying NAT Application to Traffic
Verifying Destination NAT Pool Usage
Purpose
Verify that there is traffic using IP addresses from the destination NAT pool.
Action
From operational mode, enter the show security nat destination pool all command. View the Translation hits field to check for traffic using IP addresses from the pool.
Verifying Destination NAT Rule Usage
Purpose
Verify that there is traffic matching the destination NAT rule.
Action
From operational mode, enter the show security nat destination rule all command. View the Translation hits field to check for traffic that matches the rule.
Verifying NAT Application to Traffic
Purpose
Verify that NAT is being applied to the specified traffic.
Action
From operational mode, enter the show security flow session command.
Related Topics
- Junos OS Feature Support Reference for SRX Series and J Series Devices
- Understanding Destination NAT
- Destination NAT Configuration Overview
- Example: Configuring Destination NAT for Single Address Translation
- Example: Configuring Destination NAT for IP Address and Port Translation
Hide Navigation Pane
Show Navigation Pane
Download
SHA1
