Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    Configuring Dynamic Source Address and Port Translation in IPv4 Networks

    Network Address Port Translation (NAPT) is a method by which many network addresses and their TCP/UDP ports are translated into a single network address and its TCP/UDP ports. This translation can be configured in both IPv4 and IPv6 networks. This section describes the steps for configuring NAPT in IPv4 networks.

    To configure NAPT, you must configure a rule at the [edit services nat] hierarchy level for dynamically translating the source IPv4 addresses.

    To configure the NAPT in IPv4 networks:

    1. In configuration mode, go to the [edit services] hierarchy level.
      [edit]user@host# edit services
    2. Configure the service set and NAT rule.
      [edit services]user@host# set service-set service-set-name nat-rules rule-name

      In the following example, the name of the service set is s1 and the name of the NAT rule is rule-napt-44.

      [edit services]user@host# set service-set s1 nat-rules rule-napt-44
    3. Go to the [interface-service] hierarchy level of the service set.
      [edit services]user@host# edit service-set s1 interface-service
    4. Configure the service interface.
      [edit services service-set s1 interface service]user@host# set service-interface service-interface-name

      In the following example, the name of the service interface is ms-0/1/0.

      Note: If the service interface is not present in the router, or the specified interface is not functional, the following command can result in an error.

      [edit services service-set s1 interface service]user@host# set service-interface ms-0/1/0
    5. Go to the [edit services nat] hierarchy level. Issue the command from the top of the services hierarchy, or use the top keyword.
      [edit services service-set s1 interface service]user@host# top editservices nat
    6. Configure the NAT pool with an address.
      [edit services nat]user@host# set pool pool-name address address

      In the following example, the name of the pool is napt-pool and the address is 10.10.10.0.

      [edit services nat]user@host# set pool napt-pool address 10.10.10.0
    7. Configure the port.
      [edit services nat]user@host# set pool pool-name port port-type

      In the following example, the port type is selected as automatic.

      [edit services nat]user@host# set pool napt-pool port automatic
    8. Configure the rule and the match direction.
      [edit services nat]user@host# set rule rule-name match-direction match-direction

      In the following example, the name of the rule is rule-napt-44 and the match direction is input.

      [edit services nat]user@host# set rule rule-napt-44 match-direction input
    9. Configure the term, the action for the translated traffic, and the translation type.
      [edit services nat]user@host# set rule rule-name term term-name then translated translated-action translation-type translation- type

      In the following example, the name of the term is t1, the action for the translated traffic is translated, the name of the source pool is napt-pool, and the translation type is napt-44.

      [edit services nat]user@host# set rule rule-napt-44 match-direction input term t1 then translated source-pool napt-pool translation-type napt-44
    10. Go to the [edit services adaptive-services-pics] hierarchy level. In the command, the top keyword ensures that the command is run from the top of the hierarchy.
      [edit services nat]user@host# top edit services adaptive-services-pics
    11. Configure the trace options.
      [edit services adaptive-services-pics]user@host# set traceoptions flag tracing parameter

      In the following example, the tracing parameter is configured as all.

      [edit services adaptive-services-pics]user@host# set traceoptions flag all
    12. Verify the configuration by using the show command at the [edit services] hierarchy level.
      [edit services]
      user@host# show 
      service-set s1 {
          nat-rules rule-napt-44;
          interface-service {
              service-interface ms-0/1/0;
          }
      }
      nat {
          pool napt-pool {
              address 10.10.10.0/32;
              port {
                  automatic;
              }
          }
          rule rule-napt-44 {
              match-direction input;
              term t1 {
                  then {
                      translated {
                          source-pool napt-pool;
                          translation-type {
                              napt-44;
                          }
                      }
                  }
              }
          }
      }
      adaptive-services-pics {
          traceoptions {
              flag all;
          }
      }
      

    The following example configures the translation type as napt-44.

    [edit services]
        user@host# show  
        service-set s1 {
        nat-rules rule-napt-44;
        interface-service {
            service-interface ms-0/1/0;
        }
    }
    nat {
        pool napt-pool {
            address 10.10.10.0/32;
            port {
                automatic;
            }
        }
        rule rule-napt-44 {
            match-direction input;
            term t1 {
                then {
                    translated {
                        source-pool napt-pool;
                        translation-type {
                            napt-44;
                        }
                    }
                }
            }
        }
    }
    adaptive-services-pics {
        traceoptions {
            flag all;
        }
    }
                       
    

    Dynamic Address Translation to a Small Pool with Fallback to NAT

    The following configuration shows dynamic address translation from a large prefix to a small pool, translating a /24 subnet to a pool of 10 addresses. When the addresses in the source pool (src-pool) are exhausted, NAT is provided by the NAPT overload pool (pat-pool).

    [edit services nat]
    pool src-pool {address-range low 192.16.2.1 high 192.16.2.10;}
    pool pat-pool {address-range low 192.16.2.11 high 192.16.2.12;port automatic;rule myrule {match-direction input;term myterm {from {source-address 10.150.1.0/24;}then {translated {source-pool src-pool;overload-pool pat-pool;translation-type napt-44;}}}}

    Dynamic Address Translation with Small Pool

    The following configuration shows dynamic address translation from a large prefix to a small pool, translating a /24 subnet to a pool of 10 addresses. Sessions from the first 10 host sessions are assigned an address from the pool on a first-come, first-served basis, and any additional requests are rejected. Each host with an assigned NAT can participate in multiple sessions.

    [edit services nat]
    pool my-pool {address-range low 10.10.10.1 high 10.10.10.10;}
    rule src-nat {match-direction input;term t1 {from {source-address 192.168.1.0/24;}then {translated {translation-type dynamic-nat44;source-pool my-pool;}}}}

    Published: 2013-08-29