NAT for VRF

Learn how Network Address Translation (NAT) supports address translation between VRF groups and routing instances in an SD-WAN deployment. Understand source NAT, destination NAT, and static NAT for translating private and public IP addresses across VRF groups and routing instances.

NAT for VRF Group and Routing Instance

NAT modifies or translates network address information in packet headers. RFC 1631 describes NAT as a solution for IPv4 address depletion. NAT supports firewall deployments, traffic redirection, load sharing, and network migrations.

In an SD-WAN deployment, you deploy firewalls at hub-and-spoke locations. Sites connect to spoke firewalls and send packets to public Internet servers or remote sites. After security processing at the hub, the device evaluates each packet to determine whether the destination is a public Internet server or an MPLS next-hop device. If the destination is a public Internet server, NAT translates the private IP address in the VRF instance to a public IP address and establishes a session. NAT is also required for traffic from public Internet servers to reach a private network in a VRF instance.

The following types of NAT are supported:

  • Static NAT

  • Destination NAT

  • Source NAT

In an SD-WAN network, you use NAT to translate private IP addresses in a VRF group to IP addresses in different VRF instances. You can configure the following VRF group NAT types:

  • VRF group destination NAT

  • VRF group source NAT

  • VRF group static NAT

Example: Configure Source NAT to Convert the Private IP Address of a VRF Group to the Private IP Address of a Different VRF Instance

This example describes how to configure a source NAT between two MPLS networks.

Requirements

Overview

Source NAT is used to allow hosts with private IP addresses to access a public network.

In Figure 1, Firewall is configured with VRF group vpn-A and vpn-B, which are connected to the interfaces ge-0/0/1.0 and ge-0/0/1.1 on Firewall. In the hub firewall, the source IP addresses 192.168.1.200 and 192.168.1.201 from VRF group vpn-A and vpn-B are translated to 203.0.113.200 and 203.0.113.201.

Figure 1: Source NAT using VRF group Network diagram showing SRX device with VRF, NAT, and GRE connections to Global IP Network. Traffic flows through VRF groups and MPLS labels.

Configuration

Procedure

CLI Quick Configuration

To quickly configure this example, copy the following commands, paste the commands 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.

To configure source NAT mapping:

  1. In L3VPN create a VRF group vpn-A with VRF instances A1 and A2.

  2. Create another VRF group vpn-B with VRF instances B1 and B2.

  3. Create a source NAT pool.

  4. Create a source NAT rule set.

  5. Configure a rule that matches packets and translates the source IP address to an IP address in the source NAT pool.

Results

From configuration mode, confirm your configuration by entering the show security nat 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

Verifying Source NAT Rule Usage
Purpose

Verify the traffic matching the source NAT rule.

Action

From operational mode, enter the show security nat source rule all command. In the Translation hits field, verify whether the traffic matches the source NAT rules.

Example: Configure Destination NAT to Convert a Public IP Address of a VRF Group to the Private IP Address of a Different VRF Instance

This example describes how to configure the destination NAT mapping of a public IP address of a VRF group to the single VRF’s private address for directing the packets to the correct VRF instance.

Requirements

Overview

Destination NAT is the translation of the destination IP address of a packet entering the Juniper Networks device. Destination NAT is used to redirect traffic destined to a virtual host (identified by the original destination IP address) to the real host (identified by the translated destination IP address).

In Figure 2, the Firewall is configured destination NAT to convert from IP’s that belong to different VRF groups, to different set of IP’s with routing instance pointing to different VRF. After the destination NAT rule search, NAT updates the destination routing table to point to right VRF instance for flow to do destination route look-up in right table.

Figure 2: Destination NAT using VRF Group Network diagram showing MPLS IP networks, GRE tunnels, VRF groups, NAT, and an SRX device processing traffic between networks. Orange arrows indicate VRF-GROUP A flow; green arrows indicate VRF-GROUP B flow.

Configuration

Procedure

CLI Quick Configuration

To quickly configure this example, copy the following commands, paste the commands 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.

To configure destination NAT mapping for a single VRF:

  1. In L3VPN create a VRF group vpn-A with VRF instances A1 and A2.

  2. Create another VRF group vpn-B with VRF instances B1 and B2.

  3. Specify a destination NAT IP address pool.

  4. Assign the routing instance to the destination pool.

  5. Create a destination NAT rule set.

  6. Configure a rule that matches packets and translates the destination IP address to an IP address in the destination NAT IP address pool.

Results

From configuration mode, confirm your configuration by entering the show security nat 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

Verifying Destination NAT Rule Usage

Purpose

Verify the traffic matching the destination NAT rule.

Action

From operational mode, enter the show security nat destination rule all command. In the Translation hits field, verify whether the traffic matches the destination NAT rules.

Example: Configure Source NAT to Convert the Private IP Address of a VRF Instance to the Private IP Address of Another VRF Instance

This example describes how to configure a source NAT between two MPLS networks.

Requirements

Before you Begin

Example Prerequisites

  • Software requirements: Any supported Junos release.

  • Hardware requirements: On supported devices.

Overview

Source NAT is used to allow hosts with private IP addresses to access a public network.

In this example, the firewall connects two MPLS private networks to convert the private IP address from one VRF’s private IP address to another VRF’s private IP address. In Figure 3, the spoke firewall is configured with VRF-a and VRF-b routing instances, which are connected to the hub firewall. Site C and site D are connected to another spoke firewall. In the hub firewall, the source IP addresses 192.168.1.200 and 192.168.1.201 from VRF-a and VRF-b routing instances are translated to 203.0.113.200 and 203.0.113.201.

Figure 3: Source NAT conversion Network topology with Juniper SRX devices in hub-and-spoke architecture. Sites A and B connect to one spoke, Sites C and D to another. Spokes link to a central hub via GRE+MPLS tunnels. Hub uses VRFs and NAT for IP translation.

Configuration

Procedure

CLI Quick Configuration

To quickly configure this example, copy the following commands, paste the commands 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.

To configure source NAT mapping:

  1. L3VPN require a VRF table for distributing routes within the networks. Create a VRF instance and specify the value vrf.

  2. Assign an RD to the routing instance.

  3. Create a community policy to import or export all routes.

  4. Assign a single VPN label for all the routes in the VRF.

  5. Create a source NAT pool.

  6. Create a source NAT rule set.

  7. Configure a rule that matches packets and translates the source IP address to an IP address in the source NAT pool.

Results

From configuration mode, confirm your configuration by entering the show security nat and show routing-instances 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

Verifying Source NAT Rule Usage
Purpose

Verify that the traffic matching the source NAT rules.

Action

From operational mode, enter the show security nat source rule all command. In the Translation hits field, verify whether the traffic that matches the source NAT rule.

Example: Configure Destination NAT to Convert a Public IP Address to a Single Private IP Address in a VRF Instance

This example describes how to configure the destination NAT mapping of a public IP address to the single VRF’s private address for directing the packets to the correct VRF instance.

Requirements

Overview

Destination NAT is the translation of the destination IP address of a packet entering the Juniper Networks device. Destination NAT is used to redirect traffic destined to a virtual host (identified by the original destination IP address) to the real host (identified by the translated destination IP address).

In this example, a firewall is configured with destination NAT to convert a public IP address to the VRF private IP address of a VRF instance. The public IP address can be configured per VRF instance. In Figure 4, the firewall is configured with two VRF instances, VRF-a and VRF-b. The firewall coverts the public IP address to private IP address of a VRF instance.

Figure 4: Destination NAT Network diagram showing SRX Series devices: Hub with NAT, VRF-a, VRF-b connects to internet; GRE+MPLS Tunnel links to Spoke, which connects to Site A and Site B. IP translation: 203.0.113.200 to 192.168.1.200; 203.0.113.201 to 192.168.1.201.

Configuration

Procedure

CLI Quick Configuration

To quickly configure this example, copy the following commands, paste the commands 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.

To configure destination NAT mapping for a single VRF:

  1. L3VPN require a VRF table for distributing routes within the networks. Create a VRF instance and specify the value vrf.

  2. Assign an RD to the routing instance.

  3. Create a community policy to import or export all routes.

  4. Assign a single VPN label for all the routes in the VRF.

  5. Specify a destination NAT IP address pool.

  6. Assign the routing instance to the destination pool.

  7. Create a destination NAT rule set.

  8. Configure a rule that matches packets and translates the destination IP address to an IP address in the destination NAT IP address pool.

Results

From configuration mode, confirm your configuration by entering the show security nat and show routing-instances 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

Verifying Destination NAT Rule Usage

Purpose

Verify that the traffic matching the destination NAT rules.

Action

From operational mode, enter the show security nat destination rule all command. In the Translation hits field, verify whether the traffic that matches the destination NAT rule.

Example: Configure Static NAT to Convert the Private IP Address of a VRF Instance to a Public IP Address

This example describes how to configure a static NAT mapping of VRF single private IP address to a public IP address.

Requirements

Understand how firewalls work in an SD-WAN deployment for NAT.

Overview

In this example, a firewall is configured with static NAT to convert the VRF private IP address of a VRF instance to a public IP address of a VRF instance. Static NAT can be applied on the source NAT and destination NAT. In Figure 5, the firewall is configured with two VRF instances, VRF-a and VFR-b. The firewall converts the private IP address of a VRF instance to a public IP address.

Figure 5: Static NAT Network topology with Juniper SRX devices for NAT and GRE+MPLS tunneling: public cloud, hub with VRF-a and VRF-b, tunnels to spoke, private sites, and IP translation table.

Configuration

Procedure

CLI Quick Configuration

To quickly configure this example, copy the following commands, paste the commands 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.

To configure static NAT mapping for the IP address of a single VRF:

  1. L3VPN require a VRF table for distributing routes within the networks. Create a VRF instance and specify the value vrf.

  2. Assign an RD to the routing instance.

  3. Create a community policy to import or export all routes.

  4. Assign a single VPN label for all the routes in the VRF.

  5. Create a static NAT rule set.

  6. Configure a rule that matches packets and translates the destination address in the packets to a private IP address.

Results

From configuration mode, confirm your configuration by entering the show security nat and show routing-instances 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

Verifying Static NAT Rule Usage

Purpose

Verify that the traffic matching the static NAT rules.

Action

From operational mode, enter the show security nat static rule command. In the Translation hits field, verify whether the traffic that matches the static NAT rule.