home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1997 December / Internet_Info_CD-ROM_Walnut_Creek_December_1997.iso / drafts / draft_n_r / draft-rfced-info-srisuresh-03.txt < prev    next >
Text File  |  1997-09-03  |  45KB  |  1,063 lines

  1.  
  2. Network Working Group                                       P. Srisuresh
  3. INTERNET-DRAFT                              Livingston Enterprises, Inc.
  4. Obsoletes: RFC 1631                                           K. Egevang
  5. Category: Informational                                Intel Corporation
  6. Expire in six months                                      September 1997
  7.  
  8.  
  9.                 The IP Network Address Translator (NAT)
  10.                    <draft-rfced-info-srisuresh-03.txt>
  11.  
  12. Status of this Memo
  13.  
  14.    This document is an Internet-Draft.  Internet-Drafts are
  15.    working documents of the Internet Engineering Task Force
  16.    (IETF), its areas, and its working groups. Note that other
  17.    groups may also distribute working documents as Internet-
  18.    Drafts.
  19.  
  20.    Internet-Drafts are draft documents valid for a maximum of six
  21.    months. Internet-Drafts may be updated, replaced, or obsoleted
  22.    by other documents at any time.  It is not appropriate to use
  23.    Internet-Drafts as reference material or to cite them other
  24.    than as a "working draft" or "work in progress".
  25.  
  26.    To learn the current status of any Internet-Draft, please
  27.    check the 1id-abstracts.txt listing contained in the
  28.    Internet-Drafts Shadow Directories on ds.internic.net (US East
  29.    Coast), nic.nordu.net (Europe), ftp.isi.edu (US West Coast),
  30.    or munnari.oz.au (Pacific Rim).
  31.  
  32. Preface
  33.  
  34.    This document extends address translation introduced in RFC 1631 
  35.    to incorporate TCP/UDP port translation.  In addition, this 
  36.    document corrects the Checksum adjustment algorithm published in 
  37.    RFC 1631 and attempts to discuss NAT operation and limitations
  38.    in detail.
  39.  
  40. Abstract
  41.  
  42.    Basic Network Address Translation or Basic NAT is a feature by 
  43.    which IP addresses are mapped from one group to another, transparent 
  44.    to users. Network Address Port Translation, or NAPT is an extension 
  45.    to Basic NAT, in that many network addresses and their TCP/UDP ports 
  46.    are translated to a single network address and its TCP/UDP ports.
  47.  
  48.  
  49.  
  50.  
  51.  
  52. Srisuresh & Egevang                                             [Page 1]
  53.  
  54. Internet Draft         Network Address Translator         September 1997
  55.  
  56.  
  57. 1. Introduction
  58.  
  59.    The need for IP Address translation arises when a network's internal 
  60.    IP addresses cannot be used outside the network either for security 
  61.    reasons or because they are invalid for use outside the network. 
  62.  
  63.    Network topology outside a local domain can change in many ways. 
  64.    Customers may change providers, company backbones may be 
  65.    reorganized, or providers may merge or split.  Whenever external 
  66.    topology changes with time, address assignment for nodes within the
  67.    local domain must also change to reflect the external changes.
  68.    Changes of this type can be hidden from the users within the domain
  69.    by centralizing changes to a single address translation router.
  70.  
  71.    Basic Address translation feature would allow local hosts on a 
  72.    private network to transparently access the external global network 
  73.    and enable access to  selective local hosts from the outside. 
  74.    Organizations with a network setup predominantly for internal use, 
  75.    with a need for occasional external access are good candidates for 
  76.    this feature.
  77.  
  78.    Many Small Office, Home Office (SOHO) users and telecommuting 
  79.    employees have multiple Network nodes in their office, running 
  80.    TCP/UDP applications, but have a single IP address assigned to 
  81.    their remote access router by their service provider to access 
  82.    remote networks. This ever increasing community of remote access 
  83.    users would be benefited by NAPT, which would permit multiple 
  84.    nodes in a local network to simultaneously access remote networks 
  85.    using the single IP address assigned to their router. 
  86.  
  87.    There are limitations to using the translation feature. Address 
  88.    translation must be enabled only on border routers to a stub domain, 
  89.    where all IP packets are either originated from the domain or 
  90.    destined to the domain.  Address translation requires translation of 
  91.    not only the IP headers but also some application specific headers 
  92.    and data, which make reference to IP addresses.  FTP is one such 
  93.    application. Encoded FTP sessions and any encoded sessions in 
  94.    general that might include IP addresses in the encoding will not 
  95.    be supported by NAT.
  96.  
  97.    This solution has the disadvantage of taking away the end-to-end
  98.    significance of an IP address, and making up for it with increased
  99.    state in the network. The huge advantage of this approach is that it 
  100.    can be installed without changes to either hosts or routers. (A few 
  101.    unusual applications may require changes). 
  102.  
  103. 2. Terminology and concepts used
  104.  
  105.  
  106.  
  107.  
  108. Srisuresh & Egevang                                             [Page 2]
  109.  
  110. Internet Draft         Network Address Translator         September 1997
  111.  
  112.  
  113. 2.1. Session flow vs. Packet flow
  114.  
  115.    Connection or session flows are different from packet flows. 
  116.    A session flow  indicates the direction in which the session was 
  117.    initiated with reference to a network port. Packet flow is the 
  118.    direction in which the packet has traveled with reference to a 
  119.    network port.
  120.  
  121.    Take for example, an outbound telnet session. The telnet session 
  122.    consists of packet flows in both inbound and outbound directions. 
  123.    Outbound telnet packets carry terminal keystrokes and inbound 
  124.    telnet packets carry screen displays from the telnet server.
  125.  
  126.    Performing address or TCP port translation for a telnet session 
  127.    would involve translation of incoming as well as outgoing packets 
  128.    belonging to that session.
  129.  
  130.    Packets belonging to a TCP/UDP  session are uniquely identified 
  131.    by the tuple of (source IP address, source TU port, target IP 
  132.    address, target TU port). Packets belonging to all other sessions 
  133.    are characterized simply by the tuple of (source IP address, target 
  134.    IP address, IP protocol). A session is uniquely identified by the 
  135.    first packet of that session.
  136.  
  137. 2.2. TU ports, Server ports, Client ports
  138.  
  139.    For the reminder of this document, we will refer TCP/UDP ports 
  140.    associated with an IP address simply as "TU ports".
  141.  
  142.    For most TCP/IP hosts, TU port range 0-1023 is used by servers 
  143.    listening for incoming connections. Clients trying to initiate 
  144.    a connection typically select a TU port in the range of 1024-65535. 
  145.    However, this convention is not universal and not always followed. 
  146.    Some client stations initiate connections using a TU port number 
  147.    in the range of 0-1023, and there are servers  listening on TU 
  148.    port numbers in the range of 1024-65535.
  149.  
  150.    A complete list of TU port services may be found in Ref[2].
  151.  
  152. 2.3. Start of session for TCP, UDP and others
  153.  
  154.    The first packet of every TCP session tries to establish a session 
  155.    and contains connection startup information. The first packet of a 
  156.    TCP session may be recognized by the presence of SYN bit and 
  157.    absence of ACK bit in the TCP flags. All TCP packets, with the 
  158.    exception of the first packet must have the ACK bit set.
  159.  
  160.    However, there is no deterministic way of recognizing the start of 
  161.  
  162.  
  163.  
  164. Srisuresh & Egevang                                             [Page 3]
  165.  
  166. Internet Draft         Network Address Translator         September 1997
  167.  
  168.  
  169.    a UDP based session or any non-TCP session. 
  170.  
  171. 3. Overview of NAT
  172.  
  173.    The design presented in this memo is called NAT, for Network Address
  174.    Translator. NAT is a router function that involves address 
  175.    translation alone or address and TCP/UDP port translation. We will 
  176.    call the former Basic NAT and the latter NAPT. Together they are 
  177.    referred to as NAT.  Unless mentioned otherwise, Address Translation 
  178.    or NAT throughout this document will pertain to Basic NAT as well 
  179.    as NAPT.  Only the stub border routers may be configured to perform 
  180.    address translation.
  181.  
  182. 3.1 Overview of Basic NAT
  183.  
  184.    Basic NAT operation is as follows. A stub domain with a set of 
  185.    private network addresses could be enabled to communicate with 
  186.    external network by dynamically mapping to a set of globally 
  187.    valid network addresses. If the number of local nodes are less 
  188.    than or equal to addresses in the global set, each local address 
  189.    is guaranteed to be mapped to an address from global set. Otherwise, 
  190.    local nodes allowed to have simultaneous access to external network 
  191.    are limited by the number of addresses in global set. In addition, 
  192.    individual local addresses may be statically mapped to specific 
  193.    global addresses to ensure guaranteed access to the outside or to 
  194.    expose a local node for access from the outside.  Multiple sessions 
  195.    may be initiated from a local node, using the same address mapping. 
  196.    
  197.    Addresses inside a stub domain are local to that domain and not
  198.    valid outside the domain. Thus, addresses inside a stub domain
  199.    can be reused by any other stub domain. For instance, a single
  200.    Class A address could be used by many stub domains. At each exit
  201.    point between a stub domain and backbone, NAT is installed. If 
  202.    there is more than one exit point it is of great importance that 
  203.    each NAT has the same translation table.
  204.  
  205.  
  206.         \ | /                 .                                /
  207.    +---------------+  WAN     .           +-----------------+/
  208.    |Regional Router|----------------------|Stub Router w/NAT|---
  209.    +---------------+          .           +-----------------+\
  210.                               .                      |         \
  211.                               .                      |  LAN
  212.                               .               ---------------
  213.                         Stub border
  214.  
  215.                       Figure 1: NAT Configuration
  216.  
  217.  
  218.  
  219.  
  220. Srisuresh & Egevang                                             [Page 4]
  221.  
  222. Internet Draft         Network Address Translator         September 1997
  223.  
  224.  
  225.    For instance, in the example of figure 2, both stubs A and B
  226.    internally use class A address 10.0.0.0. Stub A's NAT is 
  227.    assigned the class C address 198.76.29.0, and Stub B's NAT is 
  228.    assigned the class C address 198.76.28.0. The class C addresses 
  229.    are globally unique no other NAT boxes can use them.
  230.  
  231.                                    \ | /
  232.                                  +---------------+
  233.                                  |Regional Router|
  234.                                  +---------------+
  235.                                WAN |           | WAN
  236.                                    |           |
  237.                Stub A .............|....   ....|............ Stub B
  238.                                    |           |
  239.                  {s=198.76.29.7,^  |           |  v{s=198.76.29.7,
  240.                   d=198.76.28.4}^  |           |  v d=198.76.28.4}
  241.                    +-----------------+       +-----------------+
  242.                    |Stub Router w/NAT|       |Stub Router w/NAT|
  243.                    +-----------------+       +-----------------+
  244.                          |                         |
  245.                          |  LAN               LAN  |
  246.                    -------------             -------------
  247.                              |                 |
  248.            {s=10.33.96.5, ^  |                 |  v{s=198.76.29.7,
  249.             d=198.76.28.4}^ +--+             +--+ v d=10.81.13.22}
  250.                             |--|             |--|
  251.                            /____\           /____\
  252.                          10.33.96.5       10.81.13.22
  253.  
  254.                      Figure 2: Basic NAT Operation
  255.  
  256.    When stub A host 10.33.96.5 wishes to send a packet to stub B host
  257.    10.81.13.22, it uses the globally unique address 198.76.28.4 as
  258.    destination, and sends the packet to it's primary router. The stub
  259.    router has a static route for net 198.76.0.0 so the packet is
  260.    forwarded to the WAN-link. However, NAT translates the source 
  261.    address 10.33.96.5 of the IP header to the globally unique 
  262.    198.76.29.7 before the packet is forwarded. Likewise, IP packets
  263.    on the return path go through similar address translations.
  264.  
  265.    Notice that this requires no changes to hosts or routers. For
  266.    instance, as far as the stub A host is concerned, 198.76.28.4 is
  267.    the address used by the host in stub B. The address translations
  268.    are completely transparent. Of course, this is just a simple 
  269.    example. There are numerous issues to be explored.
  270.  
  271. 3.2. Overview of NAPT
  272.  
  273.  
  274.  
  275.  
  276. Srisuresh & Egevang                                             [Page 5]
  277.  
  278. Internet Draft         Network Address Translator         September 1997
  279.  
  280.  
  281.    Say, an organization has a private IP network and a WAN link to a
  282.    service provider. The private network's stub router is assigned
  283.    a globally valid address on the WAN link and the remaining nodes 
  284.    in the organization have IP addresses that have only local 
  285.    significance. In such a case, nodes on the private network could 
  286.    be allowed simultaneous access to external network, using the 
  287.    single registered IP address with the aid of NAPT. NAPT would 
  288.    allow mapping of tuples of the type (local IP addresses, local 
  289.    TU port number) to tuples of the type (registered IP address, 
  290.    assigned TU port number).
  291.  
  292.    This model fits the requirements of most Small Office Home Office 
  293.    (SOHO) groups to access external network using a single service 
  294.    provider assigned IP address. This model could be extended to 
  295.    allow inbound access by statically mapping a local node per each 
  296.    service TU port of the registered IP address.
  297.  
  298.    In the example of figure 3 below, stub A internally uses class A 
  299.    address 10.0.0.0. The stub router's WAN interface is assigned an 
  300.    IP address 138.76.28.4 by the service provider.
  301.  
  302.  
  303.                                    \ | /
  304.                                  +-----------------------+
  305.                                  |Service Provider Router|
  306.                                  +-----------------------+
  307.                                WAN |
  308.                                    |
  309.                Stub A .............|....
  310.                                    |
  311.        ^{s=138.76.28.4,sport=1024, |  v{s=138.76.29.7, sport = 23,
  312.        ^ d=138.76.29.7,dport=23}   |  v d=138.76.28.4, dport = 1024}
  313.                        +------------------+
  314.                        |Stub Router w/NAPT|
  315.                        +------------------+
  316.                          |
  317.                          |  LAN
  318.    --------------------------------------------
  319.       |        ^{s=10.0.0.10,sport=3017, |  v{s=138.76.29.7, sport=23,
  320.       |        ^ d=138.76.29.7,dport=23} |  v d=10.0.0.10, dport=3017}
  321.       |                                  |
  322.      +--+      +--+                    +--+
  323.      |--|      |--|                    |--|
  324.     /____\    /____\                  /____\
  325.    10.0.0.1  10.0.0.2   .....        10.0.0.10
  326.  
  327.     Figure 3: Network Address Port Translation (NAPT) Operation
  328.  
  329.  
  330.  
  331.  
  332. Srisuresh & Egevang                                             [Page 6]
  333.  
  334. Internet Draft         Network Address Translator         September 1997
  335.  
  336.  
  337.  
  338.    When stub A host 10.0.0.10 sends a telnet packet to host 
  339.    138.76.29.7, it uses the globally unique address 138.76.29.7 as 
  340.    destination, and sends the packet to it's primary router. The 
  341.    stub router has a static route for net 138.76.0.0 so the packet 
  342.    is forwarded to the WAN-link. However, NAPT translates the tuple 
  343.    of source address 10.0.0.10 and source TCP port 3017 in the IP 
  344.    and TCP headers into the globally unique 138.76.28.4 and a 
  345.    uniquely assigned TCP port, say 1024, before the packet is 
  346.    forwarded. Packets on the return path go through similar address 
  347.    and TCP port translations for the target IP address and target 
  348.    TCP port. Once again, notice that this requires no changes to 
  349.    hosts or routers.  The translation is completely transparent.
  350.  
  351.    In NAPT setup, only TCP/UDP sessions are allowed and must originate 
  352.    from the local network. However, there are services such as DNS that 
  353.    demand inbound access. There may be other services for which the 
  354.    organization wishes to allow inbound session access.  It is possible 
  355.    to statically configure a TU port service on the stub router to be 
  356.    directed to a specific node in the private network. 
  357.  
  358.    In NAPT setup, where the registered IP address is the same as the IP 
  359.    address of the stub router WAN interface, the router has to be sure
  360.    to make distinction between sessions originated from itself versus 
  361.    those originated from the nodes on local network. All inbound 
  362.    TCP/UDP sessions are assumed to be directed to the NAT router as 
  363.    the end node, unless the target service port is statically mapped to 
  364.    a different node in the local network.
  365.  
  366.    In addition to TCP/UDP sessions, all ICMP messages, with the 
  367.    exception of REDIRECT message type, will be NAT monitored as 
  368.    well. In particular, modifications to  ICMP query messages in
  369.    NAPT setup, will be similar to that of TCP/UDP packets, in that 
  370.    the identifier field in ICMP message header will be uniquely mapped.
  371.    The identifier field in ICMP query messages is set by a Query 
  372.    sender and returned unchanged in the response message from the 
  373.    query responder.  So, the tuple of (Local IP address, local ICMP 
  374.    query message identifier) may be mapped to a tuple of 
  375.    (registered IP address, assigned ICMP query message Identifier) 
  376.    to uniquely identify ICMP queries of all types from any of the 
  377.    local hosts. Modifications to ICMP error messages are discussed 
  378.    in a later section, as that involves modifications to ICMP payload 
  379.    as well as the IP and ICMP headers.
  380.  
  381.    All other types of sessions (i.e., other than TCP, UDP and ICMP)
  382.    are simply not permitted from local nodes.
  383.  
  384.  
  385.  
  386.  
  387.  
  388. Srisuresh & Egevang                                             [Page 7]
  389.  
  390. Internet Draft         Network Address Translator         September 1997
  391.  
  392.  
  393.  
  394. 4.0. Translation phases of a session.
  395.  
  396.    There are three phases to Address translation, as follows.
  397.  
  398. 4.1. Address binding:
  399.  
  400.    Address binding is the phase in which a local node IP address is 
  401.    associated with a global address for purposes of translation. For
  402.    addresses that have static mapping, the binding happens at startup 
  403.    time. Otherwise, a local address is bound to a global address 
  404.    dynamically at the time of session initiation from the local node. 
  405.    Once a local address is bound to a global address, all subsequent 
  406.    sessions originating from the same local address will use the same 
  407.    binding for session based packet translation. 
  408.  
  409.    In the case of NAPT, where many local addresses are mapped to a 
  410.    single globally unique address, the binding would be from (local 
  411.    IP addr, TU port#) to a TU port of Registered IP address.  As 
  412.    with Basic NAT, this binding is determined at the time of session 
  413.    initiation. 
  414.  
  415. 4.2. Address lookup and translation:
  416.  
  417.    Once address binding is established for a connection setup 
  418.    through a NAT port, all subsequent packets belonging to the same 
  419.    connection will be subject to address lookup (and TU port lookup, 
  420.    in the case of NAPT) for translation purposes.
  421.  
  422.    For outbound packets of a session, the source IP address (and 
  423.    source TU port, in case of NAPT) and related fields (such as 
  424.    IP, TCP, UDP and ICMP header checksums) will undergo translation. 
  425.    For inbound packets of a session, the destination IP address 
  426.    (and destination TU port, in case of NAPT) and related fields
  427.    such as IP, TCP, UDP and ICMP header checksums) will undergo 
  428.    translation.
  429.  
  430. 4.3. Address unbinding:
  431.  
  432.    Address unbinding is the phase in which a local node IP address is 
  433.    no longer associated with a global address for purposes of 
  434.    translation. When the last session based on an address binding is 
  435.    terminated, it is safe to do the address unbinding after session 
  436.    termination.  
  437.  
  438.    The end of a TCP session is detected when FIN is acknowledged by 
  439.    both halves of the session or when either half sets RST bit in 
  440.    TCP flags field. Within a couple seconds after this, the session 
  441.  
  442.  
  443.  
  444. Srisuresh & Egevang                                             [Page 8]
  445.  
  446. Internet Draft         Network Address Translator         September 1997
  447.  
  448.  
  449.    can be safely assumed to have been terminated. Dynamically bound 
  450.    TCP entries that have not been used for say, 24 hours, should 
  451.    also be safe to delete from the bound list. Dynamically bound 
  452.    non-TCP entries that have not been used for say, 1 minute, should 
  453.    also be safe to delete from the bound list. Session timeouts for 
  454.    TCP and non-TCP sessions could optionally be made user  
  455.    configurable. Another good way to handle session terminations is 
  456.    to timestamp entries and keep them as long as possible and retire 
  457.    the longest idle session when it becomes necessary. 
  458.  
  459. 5.0. Header Manipulations
  460.  
  461.    In Basic NAT model, the IP header of every packet must be 
  462.    modified. This modification includes IP address (source IP 
  463.    address for outbound packets and destination IP address for 
  464.    inbound packets) and the IP checksum. 
  465.  
  466.    For TCP/UDP sessions, modifications must include update of 
  467.    checksum in the TCP/UDP headers. This is because TCP/UDP 
  468.    checksum also covers a pseudo header which contains the source 
  469.    and destination IP addresses. As an exception, UDP headers 
  470.    with 0 checksum should not be modified. Basic NAT must also look 
  471.    out for ICMP and FTP and modify the places where the IP address 
  472.    appears. There may be other places, where modifications must be 
  473.    done. Those are not widely known applications. 
  474.  
  475.    In NAPT model, modifications to IP header are similar to that of
  476.    Basic NAT. For TCP/UDP sessions, modifications must be extended
  477.    to include translation of TU port (source TU port for outbound 
  478.    packets and destination TU port for inbound packets) in the 
  479.    TCP/UDP header.  In general, NAPT must look for IP address as well 
  480.    as TU port and modify all places in the packet where IP address 
  481.    and TU port appear.
  482.  
  483.    NAT modifications are per packet based and can be very compute 
  484.    intensive, as they involve one or more checksum modifications
  485.    in addition to simple field translations. Luckily, we have
  486.    an algorithm below, which makes checksum adjustment to IP, TCP,
  487.    UDP and ICMP headers very simple and efficient. Since all these
  488.    headers use a one's complement sum, it is sufficient to calculate
  489.    the arithmetic difference between the before-translation and after-
  490.    translation addresses and add this to the checksum. The algorithm 
  491.    below is applicable only for even offsets (i.e., optr must be at
  492.    an even offset from start of header) and even lengths (i.e., olen 
  493.    and nlen below must be even). Sample code (in C) for this is as 
  494.    follows. 
  495.  
  496.  
  497.  
  498.  
  499.  
  500. Srisuresh & Egevang                                             [Page 9]
  501.  
  502. Internet Draft         Network Address Translator         September 1997
  503.  
  504.  
  505.    void checksumadjust(unsigned char *chksum, unsigned char *optr,
  506.    int olen, unsigned char *nptr, int nlen)
  507.    /* assuming: unsigned char is 8 bits, long is 32 bits.
  508.      - chksum points to the chksum in the packet
  509.      - optr points to the old data in the packet
  510.      - nptr points to the new data in the packet
  511.    */
  512.    {
  513.      long x, old, new;
  514.      x=chksum[0]*256+chksum[1];
  515.      x=~x & 0xFFFF;
  516.      while (olen) 
  517.      {
  518.          old=optr[0]*256+optr[1]; optr+=2;
  519.          x-=old & 0xffff;
  520.          if (x<=0) { x--; x&=0xffff; }
  521.          olen-=2;
  522.      }
  523.      while (nlen) 
  524.      {
  525.          new=nptr[0]*256+nptr[1]; nptr+=2;
  526.          x+=new & 0xffff;
  527.          if (x & 0x10000) { x++; x&=0xffff; }
  528.          nlen-=2;
  529.      }
  530.      x=~x & 0xFFFF;
  531.      chksum[0]=x/256; chksum[1]=x & 0xff;
  532.    }
  533.  
  534.  
  535.  
  536. 5.1. FTP sessions
  537.  
  538.    The arguments to the File Transfer Protocol (FTP) PORT command and 
  539.    PASV response include an IP address and a TCP port (in ASCII!). If 
  540.    the IP address in PORT command or PASV response is local to the 
  541.    stub domain, then NAT must substitute this.  Because the address 
  542.    and TCP port are encoded in ASCII, this may result in a change in 
  543.    the size of packet.  For instance, 10,18,177,42,64,87 is 18 ASCII 
  544.    characters, whereas 193,45,228,137,64,87 is 20 ASCII characters. 
  545.    If the new size is same as the previous, only the TCP checksum 
  546.    needs adjustment as a result of change of data. If the new size 
  547.    is less than or greater than the previous, TCP sequence numbers 
  548.    must also be changed to reflect the change in length of FTP control 
  549.    data portion.
  550.  
  551.    A special table is used to correct the TCP sequence and acknowledge
  552.    numbers with source port FTP or destination port FTP. The table
  553.  
  554.  
  555.  
  556. Srisuresh & Egevang                                            [Page 10]
  557.  
  558. Internet Draft         Network Address Translator         September 1997
  559.  
  560.  
  561.    entries should have source, destination, source port, destination
  562.    port, delta for sequence numbers and a timestamp. New entries are 
  563.    created only when FTP PORT commands or PASV responses are seen. The 
  564.    sequence number delta may be increased or decreased for every FTP 
  565.    PORT command or PASV response. Sequence numbers are incremented 
  566.    and acknowledge numbers are decremented by this delta. 
  567.  
  568.    The sequence number adjustment must be coded carefully, not to harm
  569.    performance for TCP in general. Of course, if the FTP session is
  570.    encrypted, PORT command and/or PASV response will fail.
  571.  
  572. 5.2. ICMP packet modifications
  573.  
  574.    All ICMP error messages (with the exception of Redirect message type)
  575.    will need to be modified, when passed through NAT. The ICMP error 
  576.    message types needing NAT modification would include 
  577.    Destination-Unreachable, Source-Quench, Time-Exceeded and 
  578.    Parameter-Problem.  NAT should not attempt to modify a Redirect 
  579.    message type.
  580.  
  581.    Changes to ICMP error message will include a minimum of two address 
  582.    modifications and three checksum modifications. This is because these
  583.    ICMP messages contain part of the original IP packet in the payload.
  584.    In order for NAT to be completely transparent to the host, the IP 
  585.    address of the IP header embedded in the payload of the ICMP packet 
  586.    must be modified, the checksum field of the same IP header must 
  587.    correspondingly be modified, and the ICMP header checksum must also
  588.    be modified to reflect changes made to the IP header and checksum in 
  589.    the payload. Furthermore, the normal IP header must also be 
  590.    modified. In a NAPT setup, if the IP message embedded within ICMP 
  591.    happens to be a TCP or UDP packet, you will also need to modify 
  592.    the appropriate TU port number within the TCP/UDP header.
  593.  
  594.  
  595. 5.3. IP option handling
  596.  
  597.    An IP datagram with any of the IP options Record Route, Strict 
  598.    Source Route or Loose Source Route would involve IP addresses of the 
  599.    intermediate routers. A NAT intermediate router would simply leave 
  600.    the addresses untranslated and essentially not participate in the 
  601.    processing of these options.  The reason is simply that NAT is not
  602.    a full solution, but just a hack (a nice hack, may be). 
  603.  
  604.    An ICMP datagram with record route option is very likely intended
  605.    for debugging purposes. Hence, leaving the local addresses 
  606.    untranslated will likely not break the application.
  607.  
  608.  
  609.  
  610.  
  611.  
  612. Srisuresh & Egevang                                            [Page 11]
  613.  
  614. Internet Draft         Network Address Translator         September 1997
  615.  
  616.  
  617. 5.4. Applications with IP-address Content
  618.  
  619.    Any application that carries (and uses) the IP address (and
  620.    TU port, in case of NAPT) inside the application will not work
  621.    through NAT unless NAT knows of such instances and knows to do
  622.    the appropriate translation. For example, NAT routers would
  623.    not even attempt to translate IP addresses within SNMP and SMTP 
  624.    payloads. At some point, it must be left to application specific 
  625.    proxy agents to do the translations as appropriate to the 
  626.    application.  It is not possible or even necessarily desirable 
  627.    for NAT to know of all such applications.  And, if encryption 
  628.    is used, then it is impossible for NAT to make the translation.
  629.               
  630.  
  631. 6. Miscellaneous issues
  632.  
  633. 6.1. Partitioning of Local and Global Addresses
  634.  
  635.    For NAT to operate properly, it is necessary to partition the IP
  636.    address space into two parts - the local addresses used internal
  637.    to stub domains, and the globally unique addresses.  Any given 
  638.    address must either be a local address or a global address. 
  639.    There is no overlap.
  640.  
  641.    The problem with overlap is the following. Say a host in stub A
  642.    wished to send packets to a host in stub B, but the global 
  643.    addresses of stub B overlapped the local addressees of stub A. In 
  644.    this case, the routers in stub A would not be able to distinguish 
  645.    the global address of stub B from its own local addresses.
  646.  
  647. 6.2. Private address space recommendation
  648.  
  649.    The RFC listed in ref[1] has recommendations on address space 
  650.    allocation for private networks. Internet Assigned Numbers 
  651.    Authority (IANA) has three blocks of IP address space, namely 
  652.    10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16 for private 
  653.    internets. In pre-CIDR notation, the first block is nothing but 
  654.    a single class A network number, while the second block is a set 
  655.    of 16 contiguous class B networks, and the third block is a set of 
  656.    256 contiguous class C networks.
  657.  
  658.    An organization that decides to use IP addresses in the address 
  659.    space defined above can do so without any coordination with IANA 
  660.    or an Internet registry. The address space can thus be used 
  661.    privately by many independent organizations at the same time, 
  662.    with NAT operation enabled on their border routers.
  663.  
  664. 6.3. Routing Across NAT
  665.  
  666.  
  667.  
  668. Srisuresh & Egevang                                            [Page 12]
  669.  
  670. Internet Draft         Network Address Translator         September 1997
  671.  
  672.  
  673.  
  674.    The router running NAT should not advertise the local networks to
  675.    the backbone. Only the networks with global addresses may be known
  676.    outside the stub. However, global information that NAT receives from
  677.    the stub border router can be advertised in the stub the usual way.
  678.  
  679.    Typically, the NAT stub router will have a static route configured
  680.    to forward all external traffic to service provider router over WAN 
  681.    link, and the service provider router will have a static route 
  682.    configured to forward NAT packets (i.e., those whose destination 
  683.    IP address fall within the range of NAT managed global address list) 
  684.    to NAT router over WAN link.
  685.  
  686. 6.4. Private Networks that Span Backbones
  687.  
  688.    In many cases, a private network (such as a corporate network) will
  689.    be spread over different locations and will use a public backbone 
  690.    for communications between those locations. In this case, it is not
  691.    desirable to do address translation, both because large numbers of
  692.    hosts may want to communicate across the backbone, thus requiring
  693.    large address tables, and because there will be more applications
  694.    that depend on configured addresses, as opposed to going to a name
  695.    server. We call such a private network a backbone-partitioned stub.
  696.  
  697.    Backbone-partitioned stubs should behave as though they were a non-
  698.    partitioned stub. That is, the routers in all partitions should
  699.    maintain routes to the local address spaces of all partitions. Of
  700.    course, the (public) backbones do not maintain routes to any local
  701.    addresses. Therefore, the border routers must tunnel through the
  702.    backbones using encapsulation. To do this, each NAT box will set
  703.    aside one global address for tunneling. When a NAT box x in stub
  704.    partition X wishes to deliver a packet to stub partition Y, it will
  705.    encapsulate the packet in an IP header with destination address set
  706.    to the global address of NAT box y that has been reserved for
  707.    encapsulation. When NAT box y receives a packet with that destination
  708.    address, it decapsulates the IP header and routes the packet
  709.    internally.
  710.  
  711.  
  712. 6.5. Switch-over from Basic NAT to NAPT
  713.  
  714.    In Basic NAT setup, when local network nodes outnumber global 
  715.    addresses available for mapping (say, a class B local network 
  716.    mapped to a class C global address block), external network 
  717.    access to some of the local nodes is abruptly cut off after the 
  718.    last global address from the address list is used up. This is 
  719.    very inconvenient and constraining. Such an incident can be 
  720.    safely avoided by optionally allowing the Basic NAT router to 
  721.  
  722.  
  723.  
  724. Srisuresh & Egevang                                            [Page 13]
  725.  
  726. Internet Draft         Network Address Translator         September 1997
  727.  
  728.  
  729.    switch over to NAPT setup for the last global address in the 
  730.    address list.  Doing this will guarantee that hosts on local 
  731.    network will have continued, uninterrupted access to the external 
  732.    nodes and services.  
  733.  
  734.  
  735. 7.0. NAT limitations
  736.  
  737. 7.1. Privacy, Security, and Debugging Considerations
  738.  
  739.    Unfortunately, NAT reduces the number of options for providing
  740.    security. With NAT, nothing that carries an IP address or TU port or 
  741.    information derived from an IP address or TU port (such as the 
  742.    IP/TCP/UDP/ICMP header checksum) can be encrypted. While most 
  743.    application-level encryption should be ok, this prevents encryption 
  744.    of TCP/UDP headers.
  745.  
  746.    On the other hand, NAT itself can be seen as providing a kind of
  747.    privacy mechanism. This comes from the fact that machines on the
  748.    backbone cannot monitor which hosts are sending and receiving traffic
  749.    (assuming of course that the application data is encrypted).
  750.  
  751.    The same characteristic that enhances privacy potentially makes
  752.    debugging problems (including security violations) more difficult. 
  753.    If a host is abusing the Internet in some way (such as trying to 
  754.    attack another machine or even sending large amounts of junk mail
  755.    or something) it is more difficult to pinpoint the source of the 
  756.    trouble because the IP address of the host is hidden in a NAT router.
  757.  
  758.  
  759. 7.2. ARP responses to NAT mapped global addresses on a LAN interface
  760.  
  761.    NAT must be enabled only on border routers of a stub domain. The 
  762.    examples provided in the document to illustrate Basic NAT and 
  763.    NAPT have maintained a WAN link for connection to external router 
  764.    (i.e., service provider router) from NAT router. However, if the 
  765.    WAN link were to be replaced by a LAN connection and if part or 
  766.    all of the global address space used for NAT mapping belongs to 
  767.    the same IP subnet as the LAN segment, the NAT router would be 
  768.    expected to provide ARP support for the address range that belongs 
  769.    to the same subnet.  Responding to ARP requests for the NAT 
  770.    mapped global addresses with its own MAC address is a must in 
  771.    such a situation with Basic NAT setup. If the NAT router did 
  772.    not respond to these requests, there is no other node in the 
  773.    network that has ownership to these addresses and hence will
  774.    go unresponded. 
  775.  
  776.    This scenario is unlikely with NAPT setup except when the single 
  777.  
  778.  
  779.  
  780. Srisuresh & Egevang                                            [Page 14]
  781.  
  782. Internet Draft         Network Address Translator         September 1997
  783.  
  784.  
  785.    address used in NAPT mapping is not the interface address of the 
  786.    NAT router (as in the case of a switch-over from Basic NAT to NAPT 
  787.    explained in 6.5 above, for example).
  788.  
  789.    Using an address range from a directly connected subnet for NAT 
  790.    address mapping would obviate static route configuration on the 
  791.    service provider router.
  792.  
  793.    It is the opinion of the authors that a LAN link to a service 
  794.    provider router is not very common. However, vendors may be 
  795.    interested to optionally support proxy ARP just in case.
  796.  
  797.  
  798. 7.3. Translation of fragmented FTP control packets
  799.  
  800.    Translation of fragmented FTP control packets is tricky when the 
  801.    packets contain "PORT" command or response to "PASV" command. 
  802.    Clearly, this is a pathological case. It may be fine to simply
  803.    discard the fragments. Alternately, NAT router could attempt
  804.    to assemble fragments first and then translate prior to 
  805.    forwarding.
  806.  
  807.    Yet another pathological case would be when each character of 
  808.    packets containing "PORT" command or response to "PASV" is sent 
  809.    in a separate datagram, unfragmented. In this case, NAT would 
  810.    simply have to let the packets through, untranslated.
  811.  
  812.  
  813. 7.4. Translation of outbound TCP/UDP fragmented packets in NAPT setup
  814.  
  815.    Translation of outbound TCP/UDP fragments (i.e., those originating
  816.    from private hosts) in NAPT setup are doomed to fail. The reason is 
  817.    as follows. Only the first fragment contains the TCP/UDP header that 
  818.    would be necessary to associate the packet to a session for transla-
  819.    tion purposes. Subsequent fragments do not contain TCP/UDP port 
  820.    information, but simply carry the same fragmentation identifier 
  821.    specified in the first fragment. Say, two private hosts originated
  822.    fragmented TCP/UDP packets to the same destination host.  And, they
  823.    happened to use the same fragmentation identifier. When the
  824.    target host receives the two unrelated datagrams, carrying same 
  825.    fragmentation id, and from the same assigned host address, it 
  826.    is unable to determine which of the two sessions the datagrams 
  827.    belong to. Consequently, both sessions will be corrupted.
  828.  
  829.  
  830. 7.5. Negative characteristics:
  831.  
  832.    1. NAT is compute intensive even with the help of a clever 
  833.  
  834.  
  835.  
  836. Srisuresh & Egevang                                            [Page 15]
  837.  
  838. Internet Draft         Network Address Translator         September 1997
  839.  
  840.  
  841.       checksum adjust algorithm, as each data packet is subject to 
  842.       NAT lookup and modifications.  As a result, router forwarding 
  843.       throughput will be slowed considerably. 
  844.  
  845.    2. NAT increases the probability of mis-addressing. For example, 
  846.       same local address may be bound to different global address at 
  847.       different times and vice versa. As a result, any traffic flow 
  848.       study based purely on global addresses and TU ports could be 
  849.       confused and might misinterpret the results.
  850.  
  851.    3. It breaks certain applications or at least makes them more 
  852.       difficult to run.
  853.  
  854.       With the exception of FTP, NAT will not do address and TU port 
  855.       translations outside of the IP and the TCP/UDP headers. This 
  856.       includes DNS request and response messages. It is expected that 
  857.       internal DNS servers maintain mapping of names to IP addresses 
  858.       for internal hosts as well as some external hosts. External DNS 
  859.       servers would be expected to maintain name mapping for external 
  860.       hosts alone and not for any of the internal hosts. If the local 
  861.       network does not have an internal DNS server, all DNS requests 
  862.       may be directed to the external DNS server to get address 
  863.       mapping for the external hosts.
  864.  
  865.       There may be issues with SNMP  as well.
  866.  
  867.    4. It hides the identity of hosts. This is not to be confused with 
  868.       security however. Security on a router must be relegated to 
  869.       firewall functionality, independent of or in conjunction with 
  870.       NAT operation.
  871.  
  872.  
  873. 8.0. Current Implementations
  874.  
  875.    Many commercial implementations are available in the industry that
  876.    adhere to the NAT description provided in this document. Linux
  877.    public domain software contains NAT under the name of "IP 
  878.    masquerade". FreeBSD public domain software has NAPT implementation
  879.    running as a daemon. Note however that Linux source is covered 
  880.    under the GNU license and  FreeBSD software is covered under the 
  881.    UC Berkeley license.
  882.  
  883.    Both Linux and FreeBSD software are free, so you can buy CD-ROMs 
  884.    for these for little more than the cost of distribution. They are
  885.    also available on-line from a lot of FTP sites with the latest 
  886.    patches.
  887.  
  888.  
  889.  
  890.  
  891.  
  892. Srisuresh & Egevang                                            [Page 16]
  893.  
  894. Internet Draft         Network Address Translator         September 1997
  895.  
  896.  
  897. 9.0. Acknowledgements
  898.  
  899.    The first author Srisuresh would like to express his thanks 
  900.    and sincere gratitude to Der-hwa Gan for the knowledge and 
  901.    insight gained during the many probing discussions they had 
  902.    held. Der-hwa has a wide spread knowledge of routers and 
  903.    applications alike and was instrumental in making the author 
  904.    appreciate the many uses of NATs. 
  905.  
  906.  
  907. 10.0. Security Considerations
  908.  
  909.    Below are some of the security considerations associated with 
  910.    NAT routers.
  911.  
  912.    1. UDP sessions are inherently unsafe. Responses to a datagram
  913.       could come from an address different from the target address 
  914.       used by sender. Below is a quote from RFC 1123, section 2.3 
  915.       that confirms this.
  916.       
  917.           When the local host is multihomed, a UDP-based request/
  918.       response application SHOULD send the response with 
  919.       an IP source address that is the same as the specific 
  920.       destination address of the UDP request datagram.  The 
  921.       "specific destination address" is defined in the 
  922.       "IP Addressing" section of the companion RFC [INTRO:1].
  923.           
  924.       NAT implementations that do not track datagrams on a 
  925.       per-session basis but lump states of multiple UDP sessions 
  926.       into a single state could compromise the security even further.
  927.  
  928.    2. Multicast sessions (UDP based) are another source for security
  929.       weaknesses. 
  930.  
  931.       Say, a host on private network initiated a multicast session.
  932.       Datagram sent by the the private host could trigger responses
  933.       in the reverse direction from multiple external hosts. NAT 
  934.       implementations that use a single state to track the multicast
  935.       responses in a multicast session could potentially be the 
  936.       target of security attacks. This multicast specific security 
  937.       concern, however, is not unique to NAT implementations, and 
  938.       exists across all hosts supporting multicast applications. 
  939.  
  940.    3. NAT takes away end-to-end significance of IP addresses, TU 
  941.       ports, etc. and makes up for their loss by maintaining a 
  942.       state for each of the sessions it supports. This type of 
  943.       state management for sessions makes NAT a target for security 
  944.       break-ins that hosts have had to deal with. E.g., SYN attacks.
  945.  
  946.  
  947.  
  948. Srisuresh & Egevang                                            [Page 17]
  949.  
  950. Internet Draft         Network Address Translator         September 1997
  951.  
  952.  
  953.  
  954.       In a SYN flood attack, an attacker host sends many SYN packets 
  955.       and does not respond with an ACK to the (SYN | ACK)s sent by 
  956.       the receiving host. As the receiving host is waiting for more 
  957.       and more ACKs, the buffer queue will fill up and the receiving 
  958.       host can no longer accept legitimate connections. This means 
  959.       that attackers can block e-mail, web or any other services that 
  960.       may have been provided by the receiving host.
  961.  
  962.       When a NAT router is in between the attacker and the target 
  963.       host, NAT is maintaining a state for each new session that 
  964.       attacker is initiating. Each new SYN packet sent by the 
  965.       attacker causes a new buffer to be allocated within NAT for 
  966.       management of that new session.  Soon, the buffer queue will 
  967.       fill up and the NAT router can no longer support any 
  968.       legitimate connections. This means that attacker is now able 
  969.       to block all services that may have been provided by any of 
  970.       the private hosts, not just the host that is the target of 
  971.       attack. 
  972.  
  973.       One solution may be for NAT implementations to monitor 
  974.       half-open sessions, and set a ceiling on the maximum number 
  975.       of half-open sessions and free up buffers that were allocated 
  976.       for connections that have been half-open for longer than a 
  977.       certain time period.
  978.  
  979.  
  980. REFERENCES
  981.  
  982.    [1] Rekhter, Y., Moskowitz, B., Karrenberg, D., G. de Groot, and, 
  983.        Lear, E.  "Address Allocation for Private Internets", RFC 1918 
  984.        or its successor.
  985.  
  986.    [2] J. Reynolds and J. Postel, "Assigned Numbers", RFC 1700 or 
  987.        its successor.
  988.  
  989.    [3] R. Braden, "Requirements for Internet Hosts -- Communication 
  990.        Layers", RFC 1122 or its successor.
  991.  
  992.    [4] R. Braden, "Requirements for Internet Hosts -- Application   
  993.        and Support", RFC 1123 or its successor.
  994.  
  995.    [5] F. Baker, "Requirements for IP Version 4 Routers",  RFC 1812 
  996.        or its successor.
  997.  
  998.    [6] J. Postel, J. Reynolds, "FILE TRANSFER PROTOCOL (FTP)",  
  999.        RFC 959 or its successor.
  1000.  
  1001.  
  1002.  
  1003.  
  1004. Srisuresh & Egevang                                            [Page 18]
  1005.  
  1006. Internet Draft         Network Address Translator         September 1997
  1007.  
  1008.  
  1009.    [7] "TRANSMISSION CONTROL PROTOCOL (TCP) SPECIFICATION",  RFC 793
  1010.        or its successor.
  1011.  
  1012.    [8] J. Postel, "INTERNET CONTROl MESSAGE (ICMP) SPECIFICATION",  
  1013.        RFC 793 or its successor.
  1014.  
  1015.    [9] J. Postel, "User Datagram Protocol (UDP)",  RFC 768 or its 
  1016.        successor.
  1017.  
  1018.    [10] J. Mogul, J. Postel, "Internet Standard Subnetting Procedure",  
  1019.     RFC 950 or its successor.
  1020.  
  1021.  
  1022.  
  1023. Authors' Addresses
  1024.  
  1025.    Pyda Srisuresh
  1026.    Livingston Enterprises, Inc.
  1027.    Pleasanton, CA 94588-8519
  1028.    U.S.A.
  1029.  
  1030.    Voice: (510) 737-2153
  1031.    Fax:   (510) 737-2110 
  1032.    EMail: suresh@livingston.com
  1033.  
  1034.    Kjeld Borch Egevang
  1035.    Intel Denmark ApS
  1036.  
  1037.    Voice: +45 44530100
  1038.    Fax:   +45 44531415
  1039.    EMail: kbe@casetech.dk
  1040.    http:  //www.geocities.com/Paris/2610
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. Srisuresh & Egevang                                            [Page 19]
  1061.  
  1062.  
  1063.