Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

Stateful NAT64

date_range 13-Jan-21

Configuring Stateful NAT64

To configure stateful NAT64, you must configure a rule at the [edit services nat] hierarchy level for translating the source address dynamically and the destination address statically.

Best Practice:

When you configure the service set that includes your NAT rule, include the set stateful-nat64 clear-dont-fragment-bit at the [edit services service-set service-set-name] hierarchy level.This clears the DF (don't fragment) bit in order to prevent unnecessary creation of an IPv6 fragmentation header when translating IPv4 packets that are less than 1280 bytes. RFC 6145, IP/ICMP Translation Algorithm, provides a full discussion of the use of the DF flag to control generation of fragmentation headers. For more information on service sets for NAT, see Configuring Service Sets for Network Address Translation.

To configure stateful NAT64:

  1. In configuration mode, go to the [edit services nat] hierarchy level.
    content_copy zoom_out_map
     [edit]
    user@host# edit services nat
    
  2. Define the pool of source addresses to be used for dynamic translation.
    content_copy zoom_out_map
     [edit services nat]
    user@host# set pool pool name address source addresses
    user@host# set pool pool name port source ports
    

    For example:

    content_copy zoom_out_map
     [edit services nat]
    user@host#  set pool src-pool-nat64 address 203.0.113.0/24
    user@host#  set pool src-pool-nat64 port automatic 
    
    Note:

    Starting in Junos OS release 14.2, the sequential option is introduced to enable you to configure sequential allocation of ports. The sequential and random-allocation options available with the port automatic statement at the [edit services nat pool nat-pool-name] hierarchy level are mutually exclusive. You can include the sequential option for sequential allocation and the random-allocation option for random delegation of ports. By default, sequential allocation of ports takes place if you include only the port automatic statement at the [edit services nat pool nat-pool- name] hierarchy level. The auto option is hidden and is deprecated in Junos OS Release 14.2 and later, and is only maintained for backward compatibility. It might be removed completely in a future software release.

  3. Define a NAT rule for translating the source addresses. Set the match-direction statement of the rule as input. Then define a term that uses stateful-nat64 as the translation type for translating the addresses of the pool defined in the previous step.
    content_copy zoom_out_map
     [edit services nat]
    user@host# set rule rule name match-direction input
    user@host# set rule rule name term term name from source-address source address
    user@host# set rule rule name term term name from destination-address destination address
    user@host# set rule rule name term term name then translated source-pool pool name
    user@host# set rule rule name term term name then translated destination-prefix destination prefix
    user@host# set rule rule name term term name then translated translation-type stateful-nat64
    

    For example:

    content_copy zoom_out_map
     [edit services nat]
    user@host# set rule stateful-nat64 match-direction input
    user@host# set rule stateful-nat64 term t1 from source-address 2001:DB8::0/96
    user@host# set rule stateful-nat64 term t1 from destination-address 64:FF9B::/96
    user@host# set rule stateful-nat64 term t1 then translated source-pool src-pool-nat64
    user@host# set rule stateful-nat64 term t1 then translated destination-prefix 64:FF9B::/96
    user@host# set rule stateful-nat64 term t1 then translated translation-type stateful-nat64
    

The following example configures dynamic source address (IPv6-to-IPv4) and static destination address (IPv6-to-IPv4) translation.

content_copy zoom_out_map
[edit services]
user@host# show
nat {
    pool src-pool-nat64 {
        address 203.0.113.0/24;
        port {
            automatic;
        }
    }
    rule stateful-nat64 {
        match-direction input;
        term t1 {
            from {
                source-address {
                    2001:db8::0/96;
                }
                destination-address {
                    64:ff9b::/96;
                }
            }
            then {
                translated {
                    source-pool src-pool-nat64;
                    destination-prefix 64:ff9b::/96;
                    translation-type {
                        stateful-nat64;
                    }
                }
            }
        }
    }
}
service-set sset-nat64 {
    nat-options {
        stateful-nat64 {
            clear-dont-fragment-bit;
        }
    }
    service-set-options;
    nat-rules stateful-nat64;
    interface-service {
        service-interface ms-0/1/0;
    }
}
Note:

If you configure two NAT64 rules and associate them with the same service set, along with stateful firewall rules, and apply the service set on two VLAN-tagged interfaces, for traffic that is transmitted matching both the NAT rules, the traffic that is destined to the second NAT rule is dropped. In such a scenario, traffic flows are not dropped on the Routing Engine. This behavior of traffic drop by the second NAT rule is expected. With Junos OS Extension-Provider packages installed on a device, because endpoint-independent mapping (EIM) is not supported, EIM per VLAN or per NAT rule term. The second session, which is dropped by the second NAT rule in the configuration scenario described here, is not created owing to the following sequence of events:

  1. The first packet matching either rule creates an EIM and a session.

  2. The second packet matches the EIM entry because the second packet is sent with the same source IP address and port as the first packet (but with a different destination address).

This condition causes allocation (reuse) of the same public IP address and port to the second packet as the first packet. The reverse flow for this session has the same 5-tuple data as the reverse flow of the first session. This behavior causes flow addition failure because a duplicate flow in the same service set is not permitted.

To work around this problem, disable EIM in both the NAT rules, which causes both the sessions to be established and processed correctly. Alternatively, to avoid this problem, specify the NAT rules on different service-sets configured on different units of the media interface with EIM enabled to successfully establish both the sessions.

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
14.2
Starting in Junos OS release 14.2, the sequential option is introduced to enable you to configure sequential allocation of ports.
footer-navigation