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

    Configuring Static Source Translation in IPv4 Networks

    To configure the translation type as basic-nat44, you must configure the NAT pool and rule, service set with service interface, and trace options. This topic includes the following tasks:

    Configuring the NAT Pool and Rule

    To configure the NAT pool, rule, and term:

    1. In configuration mode, go to the [edit services nat] hierarchy level.
      [edit]user@host# edit services nat
    2. Configure the NAT pool with an address.
      [edit services nat]user@host# set pool pool name address address

      In the following example, the pool name is src_pool and the address is 10.10.10.2/32.

      [edit services nat]user@host# set pool src_pool address 10.10.10.2/32
    3. Configure the NAT rule and the match direction.
      [edit services nat]user@host# set rule rule-name match-direction match-direction

      In the following example, the NAT rule name is rule-basic-nat44 and the match direction is input.

      [edit services nat]user@host# set rule rule-basic-nat44 match-direction input
    4. Configure the source address in the from statement.
      [edit services nat]user@host# set rule rule-basic-nat44 term term-name from from

      In the following example, the term name is t1 and the input condition is source-address 3.1.1.2/32.

      [edit services nat]user@host# set rule rule-basic-nat44 term t1 from source-address 3.1.1.2/32
    5. Configure the NAT term action and properties of the translated traffic.
      [edit services nat]user@host# set rule rule-basic-nat44 term t1 then term-action translated-property

      In the following example, the term action is translated and the property of the translated traffic is source-pool src_pool.

      [edit services nat]user@host# set rule rule-basic-nat44 term t1 then translated source-pool src_pool
    6. Configure the translation type. 
      [edit services nat]user@host# set rule rule-basic-nat44 term t1 then translated translation-type translation-type

      In the following example, the translation type is basic-nat44.

      [edit services nat]user@host# set rule rule-basic-nat44 term t1 then translated translation-type basic-nat44
    7. Verify the configuration by using the show command at the [edit services nat] hierarchy level.
      [edit services]
      user@host# show
      nat {
          pool src_pool {
              address 10.10.10.2/32;
          }
          rule rule-basic-nat44 {
              match-direction input;
              term t1 {
                  from {
                      source-address {
                          3.1.1.2/32;
                      }
                  }
                  then {
                      translated {
                          source-pool src_pool;
                          translation-type {
                              basic-nat44;
                          }
                      }
                  }
              }
          }
      }

    Note: If you don’t configure a stateful firewall (SFW) rule for your traffic, then each packet is subjected to the following default stateful firewall rule:

    • Allow any valid packets from inside to outside.
    • Create forward and return flow based on packets 5-tuple.
    • Allow only valid packets matching return flows from outside to inside.

    The stateful firewall’s packet validity checks are described in the Stateful Firewall Anomaly Checking in Junos Network Secure Overview. When a packets pass stateful firewall validity checking but are not matched by a NAT rule, they are not translated and may be forwarded if the NAT node has a valid route to the packets’ destination IP addresses.

    Note: When you add or delete a parameter in the from statement (NAT rule term match condition) at the [edit services service-set service-set-name nat-rules rule-name term term- name] hierarchy level, this configuration change triggers a deletion and addition of the NAT policy (which is equivalent to the deactivation and activation of a service set) that causes all existing NAT mappings to be deleted. Because the sessions are not closed owing to the change in the NAT policy, this behavior causes the mappings to timeout immediately after the sessions are closed. This behavior is expected and is applicable only with Junos OS Extension-Provider packages installed on a device. When a NAT policy is deleted and readded, only EIM mappings are deleted. This NAT policy change does not deactivate and activate the service set. We recommend that you deactivate and reactivate the service set in such scenarios in Junos OS Release 14.2 and earlier.

    Configuring the Service Set for NAT

    To configure the service set for NAT:

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

      In the following example, the service set name is s1.

      [edit services]user@host# edit service-set s1
    3. For the s1 service set, set the reference to the NAT rules configured at the [edit services nat] hierarchy level.
      [edit services service-set s1]user@host# set nat-rules rule-name

      In the following example, the rule name is rule-basic-nat44.

      [edit services service-set s1]user@host# set nat-rules rule-basic-nat44
    4. Configure the service interface.
      [edit services service-set s1]user@host# set interface-service service-interface service-interface-name

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

      [edit services service-set s1]user@host# set interface-service service-interface ms-1/2/0

      Note: If you have a Trio-based line card, you can configure an inline-services interface on that card:

      [edit]user@host# set interfaces si-0/0/0 [edit services service-set s1]user@host# set interface-service service-interface si-0/0/0
    5. 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-basic-nat44;
          interface-service {
              service-interface ms-1/2/0;
          }
      }
    6. Associate the NAT service set with an xe- interface:
      user@host# set interfaces xe-1/1/0 unit 0 family inet address 10.255.247.2/24user@host# set interfaces xe-1/1/0 unit 0 family inet service input service-set s1user@host# set interfaces xe-1/1/0 unit 0 family inet service output service-set s1
    7. Verify the configuration by using the show command at the [edit interfaces] hierarchy level.
      [edit interfaces]
      user@host# show
      xe-1/1/0 {
          unit 0 {
              family inet {
                  service {
                      input {
                          service-set s1;
                      }
                      output {
                          service-set s1;
                      }
                   }
                  address 10.255.247.2/24;
              }
          }
      }

    Configuring Trace Options

    To configure the trace options:

    1. In configuration mode, go to the [edit services adaptive-services-pics] hierarchy level.
      [edit]user@host# edit services adaptive-services-pics
    2. Configure the trace options.
      [edit services adaptive-services-pics]user@host# set traceoptions flag tracing parameter

      In the following example, the tracing parameter is all.

      [edit services adaptive-services-pics]user@host# set traceoptions flag all
    3. Verify the configuration by using the show command at the [edit services] hierarchy level.
      [edit services]
      user@host# show
      adaptive-services-pics {                
          traceoptions {                      
              flag all;                       
          }                                   }
    [edit]
    user@host# show services 
    service-set s1 {
        nat-rules rule-basic-nat44;
        interface-service {
            service-interface ms-1/2/0;
        }
    }
    nat {
        pool src_pool {
            address 10.10.10.2/32;
        }
        rule rule-basic-nat44 {
            match-direction input;
            term t1 {
                from {
                    source-address {
                        3.1.1.2/32;
                    }
                }
                then {
                    translated {
                        source-pool src_pool;
                        translation-type {
                            basic-nat44;
                        }
                    }
                }
            }
        }
    }
    adaptive-services-pics {
        traceoptions {
            flag all;
        }
    }

    Sample Configuration - Static Source NAT Using a Static Pool With An Address Prefix And An Address Range

    [edit services nat]
    pool p1 {address 30.30.30.252/30;address-range low 20.20.20.1 high 20.20.20.2;}
    rule r1 {match-direction input;term {from {source-address {10.10.10.252/30;}}then {translated {source-pool p1;translation-type basic-nat44;}}}}

    Sample Configuration - Static Source Nat for One-To-One Mapping Between a Private Subnet and a Public Subnet

    [edit]
    user@host# show services 
    service-set s1 {
        nat-rules rule-basic-nat44;
        interface-service {
            service-interface ms-1/2/0;
        }
    }
    nat {
        pool src_pool {
            address 10.10.10.2/32;
        }
        rule rule-basic-nat44 {
            match-direction input;
            term t1 {
                from {
                    source-address {
                        3.1.1.2/32;
                    }
                }
                then {
                    translated {
                        source-pool src_pool;
                        translation-type {
                            basic-nat44;
                        }
                    }
                }
            }
        }
    }
    adaptive-services-pics {
        traceoptions {
            flag all;
        }
    }
    [edit interfaces]
    user@host# show
    xe-1/1/0 {
        unit 0 {
            family inet {
                service {
                    input {
                        service-set s1;
                    }
                    output {
                        service-set s1;
                    }
                 }
                address 10.255.247.2/24;
            }
        }
    }

    Published: 2015-03-16